Skip to content

Commit 8945f10

Browse files
authored
Merge pull request rails#54823 from skipkayhil/hm-retry-join-symbols
Enable join table references to stay retryable
2 parents d61a69c + 0df779b commit 8945f10

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

activerecord/lib/active_record/relation/query_methods.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1996,8 +1996,10 @@ def arel_column(field)
19961996
yield field
19971997
elsif Arel.arel_node?(field)
19981998
field
1999+
elsif is_symbol
2000+
Arel.sql(model.adapter_class.quote_table_name(field), retryable: true)
19992001
else
2000-
Arel.sql(is_symbol ? model.adapter_class.quote_table_name(field) : field)
2002+
Arel.sql(field)
20012003
end
20022004
end
20032005

activerecord/lib/arel/select_manager.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ def on(*exprs)
7474
def group(*columns)
7575
columns.each do |column|
7676
# FIXME: backwards compat
77-
column = Nodes::SqlLiteral.new(column) if String === column
78-
column = Nodes::SqlLiteral.new(column.to_s) if Symbol === column
77+
case column
78+
when Nodes::SqlLiteral
79+
when String
80+
column = Nodes::SqlLiteral.new(column)
81+
when Symbol
82+
column = Nodes::SqlLiteral.new(column.name)
83+
end
7984

8085
@ctx.groups.push Nodes::Group.new column
8186
end

activerecord/test/cases/adapter_test.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,12 +708,13 @@ def teardown
708708
assert Post.find_by(title: "Welcome to the weblog")
709709
assert_predicate Post, :exists?
710710
a.books.to_a
711+
Author.select(:status).joins(:books).group(:status).to_a
711712
end.select { |n| n.payload[:name] != "SCHEMA" }
712713

713-
assert_equal 6, notifications.length
714+
assert_equal 7, notifications.length
714715

715716
notifications.each do |n|
716-
assert n.payload[:allow_retry]
717+
assert n.payload[:allow_retry], "#{n.payload[:sql]} was not retryable"
717718
end
718719
end
719720

@@ -727,9 +728,10 @@ def teardown
727728
assert_not_nil Post.find_by(title: "Welcome to the weblog")
728729
assert_predicate Post, :exists?
729730
a.books.to_a
731+
Author.select(:status).joins(:books).group(:status).to_a
730732
end.select { |n| n.payload[:name] != "SCHEMA" }
731733

732-
assert_equal 6, notifications.length
734+
assert_equal 7, notifications.length
733735

734736
notifications.each do |n|
735737
assert n.payload[:allow_retry], "#{n.payload[:sql]} was not retryable"

0 commit comments

Comments
 (0)