diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-07-04 06:18:37 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-08-16 18:47:16 +0900 |
commit | c6a62dc327c54baec87306f5c381e13cacc00a19 (patch) | |
tree | e1fce0374a899b49a00afb987ddfdb1686a43b7a /activerecord/lib/active_record/relation | |
parent | c6900ce1bb3dc2daf7cd1ecfdeeb276f2e9645b5 (diff) | |
download | rails-c6a62dc327c54baec87306f5c381e13cacc00a19.tar.gz rails-c6a62dc327c54baec87306f5c381e13cacc00a19.tar.bz2 rails-c6a62dc327c54baec87306f5c381e13cacc00a19.zip |
Do not handle as an associated predicate if a table has the column
If handled as an associated predicate even though a table has the
column, will generate invalid SQL by valid column name treated as a
table name.
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index 0c8282de8e..780a1ee422 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -74,7 +74,7 @@ module ActiveRecord return ["1=0"] if attributes.empty? attributes.flat_map do |key, value| - if value.is_a?(Hash) + if value.is_a?(Hash) && !table.has_column?(key) associated_predicate_builder(key).expand_from_hash(value) else build(table.arel_attribute(key), value) @@ -88,7 +88,7 @@ module ActiveRecord attributes.each do |column_name, value| case - when value.is_a?(Hash) + when value.is_a?(Hash) && !table.has_column?(column_name) attrs, bvs = associated_predicate_builder(column_name).create_binds_for_hash(value) result[column_name] = attrs binds += bvs |