Skip to content

Commit 1cfdac0

Browse files
tpellissierclaude
andcommitted
Fix PR review comments: docstrings, error docs, and create() validation
- Document type aliases in tables.create() columns param (#4) - Clarify SQL description in client namespace summary (#8) - Add :raises: for HttpError, ValidationError, ValueError across all operation methods (#6) - Fix query.sql() to document ValidationError instead of incorrect SQLParseError - Restore post-call validation in records.create() matching original client.create() behavior (#9) - Improve deprecated get() docstring with explicit guidance on when to use records.get() vs query.get() (#10) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 15e7287 commit 1cfdac0

4 files changed

Lines changed: 29 additions & 14 deletions

File tree

src/PowerPlatform/Dataverse/client.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,16 @@ class DataverseClient:
4545
.. note::
4646
The client lazily initializes its internal OData client on first use, allowing lightweight construction without immediate network calls.
4747
48+
.. note::
49+
All methods that communicate with the Dataverse Web API may raise
50+
:class:`~PowerPlatform.Dataverse.core.errors.HttpError` on non-successful
51+
HTTP responses (e.g. 401, 403, 404, 429, 500). Individual method
52+
docstrings document only domain-specific exceptions.
53+
4854
Operations are organized into namespaces:
4955
5056
- ``client.records`` -- create, update, delete, get individual records
51-
- ``client.query`` -- paginated queries and SQL
57+
- ``client.query`` -- paginated OData queries and read-only SQL queries (via Web API ``?sql=`` parameter)
5258
- ``client.tables`` -- table and column metadata management
5359
5460
Example:
@@ -277,8 +283,10 @@ def get(
277283
) -> Union[Dict[str, Any], Iterable[List[Dict[str, Any]]]]:
278284
"""
279285
.. note::
280-
Deprecated. Use :meth:`~PowerPlatform.Dataverse.operations.records.RecordOperations.get`
281-
or :meth:`~PowerPlatform.Dataverse.operations.query.QueryOperations.get` instead.
286+
Deprecated. This method has been split into two:
287+
288+
- **Single record by ID** -- use ``client.records.get(table, record_id)``
289+
- **Query / filter multiple records** -- use ``client.query.get(table, filter=..., select=...)``
282290
283291
Fetch a single record by ID or query multiple records.
284292

src/PowerPlatform/Dataverse/operations/query.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ def sql(self, sql: str) -> List[Dict[str, Any]]:
140140
rows match.
141141
:rtype: list[dict[str, Any]]
142142
143-
:raises ~PowerPlatform.Dataverse.core.errors.SQLParseError:
144-
If the SQL query uses unsupported syntax.
145-
:raises ~PowerPlatform.Dataverse.core.errors.HttpError:
146-
If the Web API returns an error.
143+
:raises ~PowerPlatform.Dataverse.core.errors.ValidationError:
144+
If ``sql`` is not a string or is empty.
147145
148146
Example:
149147
Basic SQL query::

src/PowerPlatform/Dataverse/operations/records.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,19 @@ def create(
8888
])
8989
print(f"Created {len(guids)} accounts")
9090
"""
91-
if not isinstance(data, (dict, list)):
92-
raise TypeError("data must be dict or list[dict]")
9391
with self._client._scoped_odata() as od:
9492
entity_set = od._entity_set_from_schema_name(table)
9593
if isinstance(data, dict):
96-
return od._create(entity_set, table, data)
97-
return od._create_multiple(entity_set, table, data)
94+
rid = od._create(entity_set, table, data)
95+
if not isinstance(rid, str):
96+
raise TypeError("_create (single) did not return GUID string")
97+
return rid
98+
if isinstance(data, list):
99+
ids = od._create_multiple(entity_set, table, data)
100+
if not isinstance(ids, list) or not all(isinstance(x, str) for x in ids):
101+
raise TypeError("_create (multi) did not return list[str]")
102+
return ids
103+
raise TypeError("data must be dict or list[dict]")
98104

99105
# ------------------------------------------------------------------ update
100106

src/PowerPlatform/Dataverse/operations/tables.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ def create(
6969
(e.g. ``"new_MyTestTable"``).
7070
:type table: str
7171
:param columns: Mapping of column schema names (with customization
72-
prefix) to their types. Supported types include ``"string"``,
73-
``"int"``, ``"decimal"``, ``"float"``, ``"datetime"``, ``"bool"``,
74-
``"file"``, and ``Enum`` subclasses (for local option sets).
72+
prefix) to their types. Supported types include ``"string"``
73+
(or ``"text"``), ``"int"`` (or ``"integer"``), ``"decimal"``
74+
(or ``"money"``), ``"float"`` (or ``"double"``), ``"datetime"``
75+
(or ``"date"``), ``"bool"`` (or ``"boolean"``), ``"file"``, and
76+
``Enum`` subclasses
77+
(for local option sets).
7578
:type columns: dict[str, Any]
7679
:param solution: Optional solution unique name that should own the new
7780
table. When omitted the table is created in the default solution.

0 commit comments

Comments
 (0)