aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/predicate_builder.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-03-31 13:04:14 -0600
committerSean Griffin <sean@seantheprogrammer.com>2016-03-31 13:04:14 -0600
commit04ac5655be91f49cd4dfe2838df96213502fb274 (patch)
tree29df317be73e7e6f8c889c318809eddaff70b9f9 /activerecord/lib/active_record/relation/predicate_builder.rb
parent42cbd4ae1e5ccb654e1e522756188b28e4ab8347 (diff)
downloadrails-04ac5655be91f49cd4dfe2838df96213502fb274.tar.gz
rails-04ac5655be91f49cd4dfe2838df96213502fb274.tar.bz2
rails-04ac5655be91f49cd4dfe2838df96213502fb274.zip
Ensure associations still work when the table name contains a dot
This issue occured because associations now call `where` directly, and a dot in the key name for `where` means nested tables. For this fix, we now pass the table name as a symbol, and do not attempt to expand symbols containing a dot. This is a temporary fix. I do not think we should support table names containing a dot, as it has a special meaning in most backends, as well as most APIs that involve table names. This commit does not include a test, as I am going to deprecate table names containing dots in the following commit. Fixes #24367
Diffstat (limited to 'activerecord/lib/active_record/relation/predicate_builder.rb')
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb
index 953495a8b6..550416238f 100644
--- a/activerecord/lib/active_record/relation/predicate_builder.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder.rb
@@ -84,6 +84,7 @@ module ActiveRecord
return ["1=0"] if attributes.empty?
attributes.flat_map do |key, value|
+ key = key.to_s
if value.is_a?(Hash)
associated_predicate_builder(key).expand_from_hash(value)
else
@@ -136,7 +137,9 @@ module ActiveRecord
end
def convert_dot_notation_to_hash(attributes)
- dot_notation = attributes.keys.select { |s| s.include?(".".freeze) }
+ dot_notation = attributes.keys.select do |s|
+ s.respond_to?(:include?) && s.include?(".".freeze)
+ end
dot_notation.each do |key|
table_name, column_name = key.split(".".freeze)