Skip to content

Commit

Permalink
Merge pull request #417 from mesozoic/release-2.3.7
Browse files Browse the repository at this point in the history
Release 2.3.7
  • Loading branch information
mesozoic authored Dec 6, 2024
2 parents 2dc1bba + 15026a8 commit a50cadb
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
8 changes: 8 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog
=========

2.3.7 (2024-12-06)
------------------------

* Fix for `#415 <https://github.com/gtalarico/pyairtable/issues/415>`_
which caused an endless loop when making a request via `POST /listRecords`.
- `PR #416 <https://github.com/gtalarico/pyairtable/pull/416>`_,
`PR #417 <https://github.com/gtalarico/pyairtable/pull/417>`_

2.3.6 (2024-11-11)
------------------------

Expand Down
2 changes: 1 addition & 1 deletion pyairtable/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.3.6"
__version__ = "2.3.7"

from .api import Api, Base, Table
from .api.enterprise import Enterprise
Expand Down
2 changes: 1 addition & 1 deletion pyairtable/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def _get_offset_field(response: Dict[str, Any]) -> Optional[str]:
return
if not (offset := _get_offset_field(response)):
return
params = {**params, offset_field: offset}
options = {**options, offset_field: offset}

def chunked(self, iterable: Sequence[T]) -> Iterator[Sequence[T]]:
"""
Expand Down
3 changes: 3 additions & 0 deletions pyairtable/api/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def field_names_to_sorting_dict(field_names: List[str]) -> List[Dict[str, str]]:
# get webhook payloads
"limit": "limit",
"cursor": "cursor",
# get audit log events
"next": "next",
"previous": "previous",
}


Expand Down
36 changes: 36 additions & 0 deletions tests/test_api_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,42 @@ def test_iterate_requests(api: Api, requests_mock):
assert responses == [response["json"] for response in response_list]


def test_iterate_requests__post(api: Api, requests_mock):
url = "https://example.com"
# prepare a few pages of dummy responses
response_list = [
{"json": {"page": 0, "offset": 1}},
{"json": {"page": 1, "offset": 2}},
{"json": {"page": 2}},
]
m = requests_mock.post(url, response_list=response_list)
# construct a request that will get converted from GET to POST
formula = "X" * (api.MAX_URL_LENGTH + 1)
pages = list(
api.iterate_requests(
"GET",
url=url,
fallback=("POST", url),
options={"formula": formula},
)
)
# ensure we got the responses we expected
assert pages == [
{"page": 0, "offset": 1},
{"page": 1, "offset": 2},
{"page": 2},
]
# ensure we made three POST requests
assert m.call_count == 3
assert len(pages) == 3
requests = [r.json() for r in m.request_history]
assert requests == [
{"filterByFormula": formula},
{"filterByFormula": formula, "offset": "1"},
{"filterByFormula": formula, "offset": "2"},
]


def test_iterate_requests__invalid_type(api: Api, requests_mock):
url = "https://example.com"
response_list = [{"json": {"page": n, "offset": n + 1}} for n in range(1, 3)]
Expand Down

0 comments on commit a50cadb

Please sign in to comment.