diff options
author | Dylan Smith <Dylan.Smith@shopify.com> | 2013-02-06 13:19:09 -0500 |
---|---|---|
committer | Dylan Smith <Dylan.Smith@shopify.com> | 2013-02-07 04:59:33 -0500 |
commit | a712e08ebe21f6d8653a0e6602df2e0f5d40d9ca (patch) | |
tree | 7cde9049f55e039627b3cb6bfcc45e58bcadd4a8 /activerecord/lib/active_record/relation | |
parent | 1b75666f7f4ec7f013182d24b919ca27b0ca0068 (diff) | |
download | rails-a712e08ebe21f6d8653a0e6602df2e0f5d40d9ca.tar.gz rails-a712e08ebe21f6d8653a0e6602df2e0f5d40d9ca.tar.bz2 rails-a712e08ebe21f6d8653a0e6602df2e0f5d40d9ca.zip |
active_record: Quote numeric values compared to string columns.
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index 537ebbef28..68d960f2b1 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -98,6 +98,11 @@ module ActiveRecord when Class # FIXME: I think we need to deprecate this behavior attribute.eq(value.name) + when Integer, ActiveSupport::Duration + # Arel treats integers as literals, but they should be quoted when compared with strings + table = attribute.relation + column = table.engine.connection.schema_cache.columns_hash(table.name)[attribute.name.to_s] + attribute.eq(Arel::Nodes::SqlLiteral.new(table.engine.connection.quote(value, column))) else attribute.eq(value) end |