Merge branch 'master' into 4426-search-documentation
[arvados.git] / services / api / lib / load_param.rb
index 3f1a3b223a851f46c171a58d5b182a6790df12f1..35f1d0b640cbf9f8b7aa907b1336b5a61e1b5fa4 100644 (file)
@@ -47,10 +47,6 @@ module LoadParam
     end
   end
 
-  def default_orders
-    ["#{table_name}.modified_at desc"]
-  end
-
   # Load params[:limit], params[:offset] and params[:order]
   # into @limit, @offset, @orders
   def load_limit_offset_order_params
@@ -113,9 +109,11 @@ module LoadParam
       end
     end
 
-    if @orders.empty?
-      @orders = default_orders
-    end
+    # If the client-specified orders don't amount to a full ordering
+    # (e.g., [] or ['owner_uuid desc']), fall back on the default
+    # orders to ensure repeating the same request (possibly with
+    # different limit/offset) will return records in the same order.
+    @orders += model_class.default_orders
 
     case params[:select]
     when Array