diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-03-31 13:04:14 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2016-03-31 13:04:14 -0600 |
commit | 04ac5655be91f49cd4dfe2838df96213502fb274 (patch) | |
tree | 29df317be73e7e6f8c889c318809eddaff70b9f9 /activerecord/lib/active_record/relation/predicate_builder.rb | |
parent | 42cbd4ae1e5ccb654e1e522756188b28e4ab8347 (diff) | |
download | rails-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.rb | 5 |
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) |