We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ddc92cd + b480cc1 commit c956ee4Copy full SHA for c956ee4
1 file changed
src/spaceone/core/model/mongo_model/__init__.py
@@ -645,7 +645,12 @@ def _stat_with_pipeline(
645
)
646
647
if sort:
648
- aggregate.append({"sort": sort})
+ # Add id as default sort if not already specified
649
+ sort_with_id = sort.copy()
650
+ has_id_sort = any(s.get("key") == "id" for s in sort_with_id)
651
+ if not has_id_sort:
652
+ sort_with_id.append({"key": "id", "desc": False})
653
+ aggregate.append({"sort": sort_with_id})
654
655
response = cls.stat(
656
aggregate=aggregate,
@@ -724,7 +729,7 @@ def query(
724
729
_order_by.append(f'{sort_option["key"]}')
725
730
726
731
727
- _order_by.append("_id")
732
+ _order_by.append("id")
728
733
734
try:
735
vos = cls._get_target_objects(target).filter(_filter)
0 commit comments