Skip to content

Commit 1d469ed

Browse files
user/tpellissier/fix-get-single-select (#52)
* user/tpellissier/fix-get-single-select * UT update --------- Co-authored-by: Tim Pellissier <tpellissier@microsoft.com>
1 parent 8a2d8a3 commit 1d469ed

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/PowerPlatform/Dataverse/data/odata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,22 +456,22 @@ def _delete(self, logical_name: str, key: str) -> None:
456456
url = f"{self.api}/{entity_set}{self._format_key(key)}"
457457
self._request("delete", url, headers={"If-Match": "*"})
458458

459-
def _get(self, logical_name: str, key: str, select: Optional[str] = None) -> Dict[str, Any]:
459+
def _get(self, logical_name: str, key: str, select: Optional[List[str]] = None) -> Dict[str, Any]:
460460
"""Retrieve a single record.
461461
462462
:param logical_name: Singular logical entity name.
463463
:type logical_name: ``str``
464464
:param key: Record GUID (with or without parentheses) or alternate key syntax.
465465
:type key: ``str``
466-
:param select: Comma separated columns for ``$select`` (optional).
467-
:type select: ``str`` | ``None``
466+
:param select: Columns to select; joined with commas into $select.
467+
:type select: ``list[str]`` | ``None``
468468
469469
:return: Retrieved record dictionary (may be empty if no selected attributes).
470470
:rtype: ``dict[str, Any]``
471471
"""
472472
params = {}
473473
if select:
474-
params["$select"] = select
474+
params["$select"] = ",".join(select)
475475
entity_set = self._entity_set_from_logical(logical_name)
476476
url = f"{self.api}/{entity_set}{self._format_key(key)}"
477477
r = self._request("get", url, params=params)

tests/unit/data/test_logical_crud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_single_create_update_delete_get():
8080
entity_set = c._entity_set_from_logical("account")
8181
rid = c._create(entity_set, "account", {"name": "Acme"})
8282
assert rid == guid
83-
rec = c._get("account", rid, select="accountid,name")
83+
rec = c._get("account", rid, select=["accountid", "name"])
8484
assert rec["accountid"] == guid and rec["name"] == "Acme"
8585
c._update("account", rid, {"telephone1": "555"}) # returns None
8686
c._delete("account", rid) # returns None

0 commit comments

Comments
 (0)