File tree Expand file tree Collapse file tree 2 files changed +256
-181
lines changed Expand file tree Collapse file tree 2 files changed +256
-181
lines changed Original file line number Diff line number Diff line change @@ -305,17 +305,25 @@ def select_statement_lock?
305
305
# FETCH cannot be used without an order. If an order is not given then try to use the projections for the ordering.
306
306
# If no suitable projection are present then fallback to using the primary key of the table.
307
307
def make_Fetch_Possible_And_Deterministic ( o )
308
+ binding . pry if $DEBUG
309
+
308
310
return if o . limit . nil? && o . offset . nil?
309
311
return if o . orders . any?
310
312
311
- if ( projection = projection_to_order_by_for_fetch ( o ) )
313
+
314
+
315
+ if any_groupings? ( o ) && ( projection = projection_to_order_by_for_fetch ( o ) )
312
316
o . orders = [ projection . asc ]
313
317
else
314
318
pk = primary_Key_From_Table ( table_From_Statement ( o ) )
315
319
o . orders = [ pk . asc ] if pk
316
320
end
317
321
end
318
322
323
+ def any_groupings? ( o )
324
+ o . cores . any? { |core | core . groups . present? }
325
+ end
326
+
319
327
# Find the first projection or part of projection that can be used for ordering. Cannot use
320
328
# projections with '*' or '1 AS one' in them.
321
329
def projection_to_order_by_for_fetch ( o )
You can’t perform that action at this time.
0 commit comments