File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
src/spaceone/core/model/mongo_model Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -645,7 +645,12 @@ def _stat_with_pipeline(
645
645
)
646
646
647
647
if sort :
648
- aggregate .append ({"sort" : sort })
648
+ # 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 })
649
654
650
655
response = cls .stat (
651
656
aggregate = aggregate ,
@@ -724,7 +729,7 @@ def query(
724
729
_order_by .append (f'{ sort_option ["key" ]} ' )
725
730
726
731
if sort :
727
- _order_by .append ("_id " )
732
+ _order_by .append ("id " )
728
733
729
734
try :
730
735
vos = cls ._get_target_objects (target ).filter (_filter )
You can’t perform that action at this time.
0 commit comments