From 714ab8cb5976587470c8487720094c1efb2ba9a2 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Tue, 12 Apr 2016 10:39:32 -0600 Subject: Allow symbols using "dot notation" to be passed to where In 04ac5655be91f49cd4dfe2838df96213502fb274 I assumed that we would never want to pass the "table_name.column_name" form to where with a symbol. However, in Ruby 2.2 and later, you can quote symbols using the new hash syntax, so it's a semi-reasonable thing to do if we want to support the dot notation (which I'd rather deprecate, but that would be too painful of a migration). Instead we've changed the definition of "this is a table name with a dot" to when the value associated is a hash. It would make very little sense to write `where("table_name.column_name": { foo: :bar })` in any scenario (other than equality for a JSON column which we don't support through `where` in this way). Close #24514. --- activerecord/lib/active_record/associations/association_scope.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index 882f1225fc..48437a1c9e 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -64,11 +64,11 @@ module ActiveRecord foreign_key = join_keys.foreign_key value = transform_value(owner[foreign_key]) - scope = scope.where(table.name.to_sym => { key => value }) + scope = scope.where(table.name => { key => value }) if reflection.type polymorphic_type = transform_value(owner.class.base_class.name) - scope = scope.where(table.name.to_sym => { reflection.type => polymorphic_type }) + scope = scope.where(table.name => { reflection.type => polymorphic_type }) end scope -- cgit v1.2.3