Skip to content

Commit

Permalink
low-code-connectors: handle single records (#15346)
Browse files Browse the repository at this point in the history
* handle single records

* comment

* comment
  • Loading branch information
girarda authored Aug 5, 2022
1 parent 5031e72 commit c5c13f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def select_records(
next_page_token: Optional[Mapping[str, Any]] = None,
) -> List[Record]:
all_records = self.extractor.extract_records(response)
# Some APIs don't wrap single records in a list
if not isinstance(all_records, list):
all_records = [all_records]
if self.record_filter:
return self.record_filter.filter_records(
all_records, stream_state=stream_state, stream_slice=stream_slice, next_page_token=next_page_token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
{"data": [{"id": 1, "created_at": "06-06-21"}, {"id": 2, "created_at": "06-07-21"}, {"id": 3, "created_at": "06-08-21"}]},
[{"id": 3, "created_at": "06-08-21"}],
),
(
"test_read_single_record",
"_.data",
None,
{"data": {"id": 1, "created_at": "06-06-21"}},
[{"id": 1, "created_at": "06-06-21"}],
),
],
)
def test_record_filter(test_name, transform_template, filter_template, body, expected_records):
Expand Down

0 comments on commit c5c13f0

Please sign in to comment.