aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorDylan Smith <Dylan.Smith@shopify.com>2013-02-06 13:19:09 -0500
committerDylan Smith <Dylan.Smith@shopify.com>2013-02-07 05:02:38 -0500
commit04c2d2e2e4197a1564c33f09d3e52253d845925f (patch)
treec57b23a3197d773dcce73a322806f49833208dbf /activerecord/lib/active_record/relation
parentb4f189a162f4280b360dbc2a6635bbff6c6f09bc (diff)
downloadrails-04c2d2e2e4197a1564c33f09d3e52253d845925f.tar.gz
rails-04c2d2e2e4197a1564c33f09d3e52253d845925f.tar.bz2
rails-04c2d2e2e4197a1564c33f09d3e52253d845925f.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.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb
index b31fdfd981..5f311ed6d4 100644
--- a/activerecord/lib/active_record/relation/predicate_builder.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder.rb
@@ -51,6 +51,10 @@ 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
+ column = engine.connection.schema_cache.columns_hash(table.name)[attribute.name.to_s]
+ attribute.eq(Arel::Nodes::SqlLiteral.new(engine.connection.quote(value, column)))
else
attribute.eq(value)
end