aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/table_metadata.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-07-04 06:18:37 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-08-16 18:47:16 +0900
commitc6a62dc327c54baec87306f5c381e13cacc00a19 (patch)
treee1fce0374a899b49a00afb987ddfdb1686a43b7a /activerecord/lib/active_record/table_metadata.rb
parentc6900ce1bb3dc2daf7cd1ecfdeeb276f2e9645b5 (diff)
downloadrails-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/table_metadata.rb')
-rw-r--r--activerecord/lib/active_record/table_metadata.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/table_metadata.rb b/activerecord/lib/active_record/table_metadata.rb
index e8d6a144f9..0ca880e635 100644
--- a/activerecord/lib/active_record/table_metadata.rb
+++ b/activerecord/lib/active_record/table_metadata.rb
@@ -37,6 +37,10 @@ module ActiveRecord
end
end
+ def has_column?(column_name)
+ klass && klass.columns_hash.key?(column_name.to_s)
+ end
+
def associated_with?(association_name)
klass && klass._reflect_on_association(association_name)
end