Skip to content

Commit 0591188

Browse files
committed
more naming updates
1 parent 9a6dc4e commit 0591188

6 files changed

Lines changed: 19 additions & 19 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ The SDK provides a simple, pythonic interface for Dataverse operations:
104104
| **Bulk Operations** | Efficient bulk processing for multiple records with automatic optimization |
105105
| **Paging** | Automatic handling of large result sets with iterators |
106106
| **Structured Errors** | Detailed exception hierarchy with retry guidance and diagnostic information |
107-
| **Customization prefix values** | Custom tables and columns require a customization prefix values to be included for all operations (e.g., `"new_Title"`, not `"Title"`). See: [Table definitions in Microsoft Dataverse](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/entity-metadata) |
107+
| **Customization prefix values** | Custom tables and columns require a customization prefix value to be included for all operations (e.g., `"new_Title"`, not `"Title"`). See: [Table definitions in Microsoft Dataverse](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/entity-metadata) |
108108

109109
## Examples
110110

examples/advanced/walkthrough.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ def main():
8080
print(f" Entity Set: {table_info.get('entity_set_name')}")
8181
else:
8282
log_call(f"client.create_table('{table_name}', schema={{...}})")
83-
schema = {
83+
columns = {
8484
"new_Title": "string",
8585
"new_Quantity": "int",
8686
"new_Amount": "decimal",
8787
"new_Completed": "bool",
8888
"new_Priority": Priority
8989
}
90-
table_info = client.create_table(table_name, schema)
90+
table_info = client.create_table(table_name, columns)
9191
print(f"✓ Created table: {table_info.get('table_schema_name')}")
9292
print(f" Columns created: {', '.join(table_info.get('columns_created', []))}")
9393

examples/basic/functional_testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def ensure_test_table(client: DataverseClient) -> Dict[str, Any]:
9696
table_info = client.create_table(
9797
table_schema_name,
9898
primary_column_schema_name="test_name",
99-
schema=
99+
columns=
100100
{
101101
"test_description": "string", # Description field
102102
"test_count": "int", # Integer field

src/PowerPlatform/Dataverse/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def create(self, table_schema_name: str, records: Union[Dict[str, Any], List[Dic
134134
print(f"Created {len(ids)} accounts")
135135
"""
136136
od = self._get_odata()
137-
entity_set = od._entity_set_from_logical(table_schema_name)
137+
entity_set = od._entity_set_from_schema_name(table_schema_name)
138138
if isinstance(records, dict):
139139
rid = od._create(entity_set, table_schema_name, records)
140140
# _create returns str on single input
@@ -420,7 +420,7 @@ def get_table_info(self, table_schema_name: str) -> Optional[Dict[str, Any]]:
420420
def create_table(
421421
self,
422422
table_schema_name: str,
423-
schema: Dict[str, Any],
423+
columns: Dict[str, Any],
424424
solution_unique_name: Optional[str] = None,
425425
primary_column_schema_name: Optional[str] = None,
426426
) -> Dict[str, Any]:
@@ -491,7 +491,7 @@ class ItemStatus(IntEnum):
491491
"""
492492
return self._get_odata()._create_table(
493493
table_schema_name,
494-
schema,
494+
columns,
495495
solution_unique_name,
496496
primary_column_schema_name,
497497
)
@@ -662,7 +662,7 @@ def upload_file(
662662
)
663663
"""
664664
od = self._get_odata()
665-
entity_set = od._entity_set_from_logical(table_schema_name)
665+
entity_set = od._entity_set_from_schema_name(table_schema_name)
666666
od.upload_file(
667667
entity_set,
668668
record_id,

src/PowerPlatform/Dataverse/data/odata.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def _primary_id_attr(self, table_schema_name: str) -> str:
278278
if pid:
279279
return pid
280280
# Resolve metadata (populates _logical_primaryid_cache or raises if table_schema_name unknown)
281-
self._entity_set_from_logical(table_schema_name)
281+
self._entity_set_from_schema_name(table_schema_name)
282282
pid2 = self._logical_primaryid_cache.get(cache_key)
283283
if pid2:
284284
return pid2
@@ -303,7 +303,7 @@ def _update_by_ids(self, table_schema_name: str, ids: List[str], changes: Union[
303303
if not ids:
304304
return None
305305
pk_attr = self._primary_id_attr(table_schema_name)
306-
entity_set = self._entity_set_from_logical(table_schema_name)
306+
entity_set = self._entity_set_from_schema_name(table_schema_name)
307307
if isinstance(changes, dict):
308308
batch = [{pk_attr: rid, **changes} for rid in ids]
309309
self._update_multiple(entity_set, table_schema_name, batch)
@@ -420,7 +420,7 @@ def _update(self, table_schema_name: str, key: str, data: Dict[str, Any]) -> Non
420420
# Lowercase all keys to match Dataverse LogicalName expectations
421421
data = self._lowercase_keys(data)
422422
data = self._convert_labels_to_ints(table_schema_name, data)
423-
entity_set = self._entity_set_from_logical(table_schema_name)
423+
entity_set = self._entity_set_from_schema_name(table_schema_name)
424424
url = f"{self.api}/{entity_set}{self._format_key(key)}"
425425
r = self._request("patch", url, headers={"If-Match": "*"}, json=data)
426426

@@ -481,7 +481,7 @@ def _update_multiple(self, entity_set: str, table_schema_name: str, records: Lis
481481

482482
def _delete(self, table_schema_name: str, key: str) -> None:
483483
"""Delete a record by GUID or alternate key."""
484-
entity_set = self._entity_set_from_logical(table_schema_name)
484+
entity_set = self._entity_set_from_schema_name(table_schema_name)
485485
url = f"{self.api}/{entity_set}{self._format_key(key)}"
486486
self._request("delete", url, headers={"If-Match": "*"})
487487

@@ -501,7 +501,7 @@ def _get(self, table_schema_name: str, key: str, select: Optional[str] = None) -
501501
if select:
502502
# Lowercase column names for case-insensitive matching
503503
params["$select"] = select.lower()
504-
entity_set = self._entity_set_from_logical(table_schema_name)
504+
entity_set = self._entity_set_from_schema_name(table_schema_name)
505505
url = f"{self.api}/{entity_set}{self._format_key(key)}"
506506
r = self._request("get", url, params=params)
507507
return r.json()
@@ -557,7 +557,7 @@ def _do_request(url: str, *, params: Optional[Dict[str, Any]] = None) -> Dict[st
557557
except ValueError:
558558
return {}
559559

560-
entity_set = self._entity_set_from_logical(table_schema_name)
560+
entity_set = self._entity_set_from_schema_name(table_schema_name)
561561
base_url = f"{self.api}/{entity_set}"
562562
params: Dict[str, Any] = {}
563563
if select:
@@ -627,7 +627,7 @@ def _query_sql(self, sql: str) -> list[dict[str, Any]]:
627627
# Extract logical table name via helper (robust to identifiers ending with 'from')
628628
logical = self._extract_logical_table(sql)
629629

630-
entity_set = self._entity_set_from_logical(logical)
630+
entity_set = self._entity_set_from_schema_name(logical)
631631
# Issue GET /{entity_set}?sql=<query>
632632
url = f"{self.api}/{entity_set}"
633633
params = {"sql": sql}
@@ -666,7 +666,7 @@ def _extract_logical_table(sql: str) -> str:
666666
return m.group(1).lower()
667667

668668
# ---------------------- Entity set resolution -----------------------
669-
def _entity_set_from_logical(self, logical: str) -> str:
669+
def _entity_set_from_schema_name(self, logical: str) -> str:
670670
"""Resolve entity set name (plural) from a logical (singular) name using metadata.
671671
672672
Caches results for subsequent queries. Case-insensitive.

tests/unit/data/test_logical_crud.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_single_create_update_delete_get():
7777
(204, {}, {}), # delete
7878
]
7979
c = TestableClient(responses)
80-
entity_set = c._entity_set_from_logical("account")
80+
entity_set = c._entity_set_from_schema_name("account")
8181
rid = c._create(entity_set, "account", {"name": "Acme"})
8282
assert rid == guid
8383
rec = c._get("account", rid, select="accountid,name")
@@ -97,7 +97,7 @@ def test_bulk_create_and_update():
9797
(204, {}, {}), # UpdateMultiple 1:1
9898
]
9999
c = TestableClient(responses)
100-
entity_set = c._entity_set_from_logical("account")
100+
entity_set = c._entity_set_from_schema_name("account")
101101
ids = c._create_multiple(entity_set, "account", [{"name": "A"}, {"name": "B"}])
102102
assert ids == [g1, g2]
103103
c._update_by_ids("account", ids, {"statecode": 1}) # broadcast
@@ -122,4 +122,4 @@ def test_unknown_logical_name_raises():
122122
]
123123
c = TestableClient(responses)
124124
with pytest.raises(MetadataError):
125-
c._entity_set_from_logical("nonexistent")
125+
c._entity_set_from_schema_name("nonexistent")

0 commit comments

Comments
 (0)