diff options
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/arel.rb | 5 |
3 files changed, 7 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 701f19a6ae..42eba27b2a 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -194,9 +194,7 @@ module ActiveRecord def disallow_raw_sql!(args, permit: COLUMN_NAME) # :nodoc: unexpected = args.reject do |arg| - arg.kind_of?(Arel::Node) || - arg.is_a?(Arel::Nodes::SqlLiteral) || - arg.is_a?(Arel::Attributes::Attribute) || + Arel.arel_node?(arg) || arg.to_s.split(/\s*,\s*/).all? { |part| permit.match?(part) } end diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 2fc0cb0597..db06bd9e26 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -635,7 +635,7 @@ module ActiveRecord def _substitute_values(values) values.map do |name, value| attr = arel_attribute(name) - unless value.is_a?(Arel::Node) || value.is_a?(Arel::Attribute) || value.is_a?(Arel::Nodes::SqlLiteral) + unless Arel.arel_node?(value) type = klass.type_for_attribute(attr.name) value = predicate_builder.build_bind_attribute(attr.name, type.cast(value)) end diff --git a/activerecord/lib/arel.rb b/activerecord/lib/arel.rb index 7d04e1cac6..dab785738e 100644 --- a/activerecord/lib/arel.rb +++ b/activerecord/lib/arel.rb @@ -35,6 +35,11 @@ module Arel # :nodoc: all def self.star sql "*" end + + def self.arel_node?(value) + value.is_a?(Arel::Node) || value.is_a?(Arel::Attribute) || value.is_a?(Arel::Nodes::SqlLiteral) + end + ## Convenience Alias Node = Arel::Nodes::Node end |