Skip to content

Commit 479f0b1

Browse files
committed
Refactor $select parameter handling in _ODataClient and normalize empty select list in TableOperations
1 parent af88733 commit 479f0b1

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,10 +1519,12 @@ def _get_table_metadata(
15191519
params: Dict[str, str] = {}
15201520
if select is not None and isinstance(select, str):
15211521
raise TypeError("select must be a list of property names, not a bare string")
1522+
base_fields = {"MetadataId", "LogicalName", "SchemaName", "EntitySetName"}
15221523
if select:
1523-
base_fields = {"MetadataId", "LogicalName", "SchemaName", "EntitySetName"}
15241524
merged = list(base_fields | set(select))
1525-
params["$select"] = ",".join(merged)
1525+
else:
1526+
merged = list(base_fields)
1527+
params["$select"] = ",".join(merged)
15261528
expand_parts: List[str] = []
15271529
if include_attributes:
15281530
expand_parts.append("Attributes")

src/PowerPlatform/Dataverse/operations/tables.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ def get(
208208
# Extended with relationships
209209
info = client.tables.get("account", include_relationships=True)
210210
"""
211+
# Normalize empty list to None so callers passing select=[] get the
212+
# lightweight path instead of an expensive full-entity-definition fetch.
213+
if select is not None and len(select) == 0:
214+
select = None
215+
211216
# When no extra parameters are passed, use the original lightweight lookup.
212217
# This ensures backward compatibility -- existing callers get identical behavior.
213218
if not include_columns and not include_relationships and select is None:

0 commit comments

Comments
 (0)