Skip to content

Commit 0464890

Browse files
Abel Milashclaude
andcommitted
Mirror PR #183 (CreateEntities API) in async client
Sync side was updated to use the new CreateEntities API in PR #183. The async client has its own copy of _create_entity and _create_table, so we need to mirror those changes manually: - _AsyncODataClient._create_entity(): URL EntityDefinitions -> CreateEntities, payload wrapped in Entities[0] array with @odata.type ComplexEntityMetadata - _AsyncODataClient._create_table(): pass complex=True to _attribute_payload calls so attribute metadata uses the Complex*Metadata variants required by CreateEntities The shared base (_odata_base.py) changes from PR #183 -- including the _attribute_payload(complex=...) parameter and Complex*Metadata output -- flow into the async client automatically via inheritance. This is a clean re-apply of the legitimate diff after reverting commit c1f1237, which accidentally committed many untracked scratch/build files alongside this change. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 2c12658 commit 0464890

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

src/PowerPlatform/Dataverse/aio/data/_async_odata.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -845,18 +845,22 @@ async def _create_entity(
845845
attributes: List[Dict[str, Any]],
846846
solution_unique_name: Optional[str] = None,
847847
) -> Dict[str, Any]:
848-
url = f"{self.api}/EntityDefinitions"
848+
url = f"{self.api}/CreateEntities"
849849
payload = {
850-
"@odata.type": "Microsoft.Dynamics.CRM.EntityMetadata",
851-
"SchemaName": table_schema_name,
852-
"DisplayName": self._label(display_name),
853-
"DisplayCollectionName": self._label(display_name + "s"),
854-
"Description": self._label(f"Custom entity for {display_name}"),
855-
"OwnershipType": "UserOwned",
856-
"HasActivities": False,
857-
"HasNotes": True,
858-
"IsActivity": False,
859-
"Attributes": attributes,
850+
"Entities": [
851+
{
852+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexEntityMetadata",
853+
"SchemaName": table_schema_name,
854+
"DisplayName": self._label(display_name),
855+
"DisplayCollectionName": self._label(display_name + "s"),
856+
"Description": self._label(f"Custom entity for {display_name}"),
857+
"OwnershipType": "UserOwned",
858+
"HasActivities": False,
859+
"HasNotes": True,
860+
"IsActivity": False,
861+
"Attributes": attributes,
862+
}
863+
]
860864
}
861865
params = None
862866
if solution_unique_name:
@@ -1339,9 +1343,9 @@ async def _create_table(
13391343
)
13401344

13411345
attributes: List[Dict[str, Any]] = []
1342-
attributes.append(self._attribute_payload(primary_attr_schema, "string", is_primary_name=True))
1346+
attributes.append(self._attribute_payload(primary_attr_schema, "string", is_primary_name=True, complex=True))
13431347
for col_name, dtype in schema.items():
1344-
payload = self._attribute_payload(col_name, dtype)
1348+
payload = self._attribute_payload(col_name, dtype, complex=True)
13451349
if not payload:
13461350
raise ValueError(f"Unsupported column type '{dtype}' for '{col_name}'.")
13471351
attributes.append(payload)

0 commit comments

Comments
 (0)