File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -819,12 +819,19 @@ class Comment(Model):
819819 clone ._order = []
820820 return clone
821821
822- conditions = []
823- for colname in colnames :
824- conditions .append ('"{0}" {1}' .format (* self ._get_ordering_condition (colname )))
825-
826822 clone = copy .deepcopy (self )
827- clone ._order .extend (conditions )
823+
824+ for col_name in colnames :
825+ col_name , order = self ._get_ordering_condition (col_name )
826+ col_name = '"{0}"' .format (col_name )
827+ # Check if there is existing condition that targets same column and replace it if it's order is different
828+ for cond_id , existing_condition in enumerate (clone ._order ):
829+ if col_name in existing_condition :
830+ if not existing_condition .endswith (order ):
831+ clone ._order [cond_id ] = '{0} {1}' .format (col_name , order )
832+ break
833+ else :
834+ clone ._order .append ('{0} {1}' .format (col_name , order ))
828835 return clone
829836
830837 def count (self ):
You can’t perform that action at this time.
0 commit comments