Skip to content

Commit b395b02

Browse files
committed
feat(Instances API): wire sort preparation at PostgreSQL-backed call sites
1 parent 0e39b76 commit b395b02

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

cognite/client/_api/data_modeling/instances.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ async def subscribe(
894894
>>> subscription_context.cancel()
895895
896896
"""
897+
query._prepare_sorts()
897898
subscription_context = SubscriptionContext()
898899

899900
async def _poll_loop() -> None:
@@ -968,10 +969,11 @@ def _create_other_params(
968969
f"Received in `sources` argument for views: {with_properties}."
969970
)
970971
if sort:
971-
if isinstance(sort, (InstanceSort, dict)):
972-
other_params["sort"] = [cls._dump_instance_sort(sort)]
973-
else:
974-
other_params["sort"] = [cls._dump_instance_sort(s) for s in sort]
972+
sorts_seq = [sort] if isinstance(sort, (InstanceSort, dict)) else list(sort)
973+
for s in sorts_seq:
974+
if isinstance(s, InstanceSort):
975+
s._apply_postgres_defaults_or_maybe_warn()
976+
other_params["sort"] = [cls._dump_instance_sort(s) for s in sorts_seq]
975977
if instance_type:
976978
other_params["instanceType"] = instance_type
977979
if debug:
@@ -1647,6 +1649,7 @@ async def query(
16471649
>>> res = client.data_modeling.instances.query(query, debug=debug_params)
16481650
>>> print(res.debug)
16491651
"""
1652+
query._prepare_sorts()
16501653
return await self._query_or_sync(query, "query", include_typing=include_typing, debug=debug)
16511654

16521655
async def sync(
@@ -1749,6 +1752,7 @@ async def sync(
17491752
>>> res = client.data_modeling.instances.sync(query, debug=debug_params)
17501753
>>> print(res.debug)
17511754
"""
1755+
query._prepare_sorts()
17521756
return await self._query_or_sync(query, "sync", include_typing=include_typing, debug=debug)
17531757

17541758
async def _query_or_sync(

cognite/client/_sync_api/data_modeling/instances.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
===============================================================================
3-
c0af4f83cd8ffa0aaed6fa641bde9a98
3+
f57e38da23620654d634c19560399f41
44
This file is auto-generated from the Async API modules, - do not edit manually!
55
===============================================================================
66
"""

0 commit comments

Comments
 (0)