Skip to content

Commit f4be98b

Browse files
author
Abel Milash
committed
Update based on comments
1 parent c1f46e6 commit f4be98b

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,14 +1229,14 @@ def _request_metadata_with_retry(self, method: str, url: str, **kwargs):
12291229
continue
12301230
raise RuntimeError(f"Metadata request failed after {max_attempts} retries (404): {url}") from err
12311231
raise
1232-
raise RuntimeError(f"Metadata request failed: {url}")
12331232

12341233
def _bulk_fetch_picklists(self, table_schema_name: str) -> None:
12351234
"""Fetch all picklist attributes and their options for a table in one API call.
12361235
12371236
Uses collection-level PicklistAttributeMetadata cast to retrieve every picklist
12381237
attribute on the table, including its OptionSet options. Populates the nested
12391238
cache so that ``_convert_labels_to_ints`` resolves labels without further API calls.
1239+
The Dataverse metadata API does not page results.
12401240
"""
12411241
table_key = self._normalize_cache_key(table_schema_name)
12421242
now = time.time()

tests/unit/data/test_odata_internal.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,21 @@ def test_bulk_fetch_makes_single_api_call(self):
670670
self.od._bulk_fetch_picklists("account")
671671
self.assertEqual(self.od._request.call_count, 1)
672672

673+
def test_bulk_fetch_stress_large_workload(self):
674+
"""Bulk fetch correctly parses a response with a large number of picklist attributes."""
675+
num_picklists = 5000
676+
picklists = [(f"new_pick{i}", [(100000000 + j, f"Option {j}") for j in range(4)]) for i in range(num_picklists)]
677+
resp = self._bulk_response(*picklists)
678+
self.od._request.return_value = resp
679+
680+
self.od._bulk_fetch_picklists("account")
681+
682+
self.assertEqual(self.od._request.call_count, 1)
683+
cached = self.od._picklist_label_cache["account"]["picklists"]
684+
self.assertEqual(len(cached), num_picklists)
685+
self.assertEqual(cached["new_pick0"]["option 0"], 100000000)
686+
self.assertEqual(cached[f"new_pick{num_picklists - 1}"]["option 3"], 100000003)
687+
673688
# ---- _request_metadata_with_retry ----
674689

675690
def test_retry_succeeds_on_first_try(self):

0 commit comments

Comments
 (0)