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(
645645 )
646646
647647 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 })
649654
650655 response = cls .stat (
651656 aggregate = aggregate ,
@@ -724,7 +729,7 @@ def query(
724729 _order_by .append (f'{ sort_option ["key" ]} ' )
725730
726731 if sort :
727- _order_by .append ("_id " )
732+ _order_by .append ("id " )
728733
729734 try :
730735 vos = cls ._get_target_objects (target ).filter (_filter )
You can’t perform that action at this time.
0 commit comments