Skip to content

Commit

Permalink
#816 Airtable.get_records() fields argument can be either str or list (
Browse files Browse the repository at this point in the history
…#892)

* all fields to be a str object

* remove newline
  • Loading branch information
angloyna authored Oct 25, 2023
1 parent 1e79926 commit 2f15a53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions parsons/airtable/airtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def get_records(
See :ref:`parsons-table` for output options.
"""

if isinstance(fields, str):
fields = [fields]
# Raises an error if sort is None type. Thus, only adding if populated.
kwargs = {
"fields": fields,
Expand Down
10 changes: 10 additions & 0 deletions test/test_airtable/test_airtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ def test_get_records_with_explicit_headers(self, m):

assert airtable_res.columns == ["id", "createdTime", "Name", "SecondColumn"]

@requests_mock.Mocker()
def test_get_records_with_single_field(self, m):
m.get(self.base_uri, json=records_response_with_more_columns)

fields = "Name"

airtable_res = self.at.get_records(fields, sample_size=1)

assert airtable_res.columns == ["id", "createdTime", "Name"]

@requests_mock.Mocker()
def test_insert_record(self, m):

Expand Down

0 comments on commit 2f15a53

Please sign in to comment.