File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -305,14 +305,14 @@ 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
308
+ # binding.pry if $DEBUG
309
309
310
310
return if o . limit . nil? && o . offset . nil?
311
311
return if o . orders . any?
312
312
313
313
314
314
315
- if any_groupings? ( o ) && ( projection = projection_to_order_by_for_fetch ( o ) )
315
+ if ( any_groupings? ( o ) || has_join_sources? ( o ) ) && ( projection = projection_to_order_by_for_fetch ( o ) )
316
316
o . orders = [ projection . asc ]
317
317
else
318
318
pk = primary_Key_From_Table ( table_From_Statement ( o ) )
@@ -324,6 +324,19 @@ def any_groupings?(o)
324
324
o . cores . any? { |core | core . groups . present? }
325
325
end
326
326
327
+ # TODO: Need this for "in the subquery the first projection is used for ordering if none provided" test.
328
+ def has_join_sources? ( o )
329
+ # binding.pry if $DEBUG
330
+
331
+
332
+ return false unless o . is_a? ( Arel ::Nodes ::SelectStatement )
333
+
334
+ # false
335
+ o . cores . any? { |core | core . source . is_a? ( Arel ::Nodes ::JoinSource ) }
336
+ rescue => e
337
+ binding . pry
338
+ end
339
+
327
340
# Find the first projection or part of projection that can be used for ordering. Cannot use
328
341
# projections with '*' or '1 AS one' in them.
329
342
def projection_to_order_by_for_fetch ( o )
You can’t perform that action at this time.
0 commit comments