Skip to content
Browse files

just wrap as a sql literal

  • Loading branch information...
1 parent d33dcba commit 8e8fb8a4291cc288b1189338f0de643c409eb028 @tenderlove tenderlove committed
Showing with 1 addition and 2 deletions.
  1. +1 −2 activerecord/lib/active_record/relation/predicate_builder.rb
View
3 activerecord/lib/active_record/relation/predicate_builder.rb
@@ -26,8 +26,7 @@ def self.build_from_hash(engine, attributes, default_table)
when Range, Arel::Relation
attribute.in(value)
when ActiveRecord::Base
- sanitized_id = attribute.class == Arel::Attributes::String ? value.id : value.quoted_id
- attribute.eq(sanitized_id)
+ attribute.eq(Arel.sql(value.quoted_id))
when Class
# FIXME: I think we need to deprecate this behavior
attribute.eq(value.name)

2 comments on commit 8e8fb8a

@neerajdotname
Ruby on Rails member

I should really learn the Arel API. Thanks for cleaning up.

@tenderlove
Ruby on Rails member

No problem. If you wrap something with Arel.sql(), it will keep arel from doing anything to the value.

Please sign in to comment.
Something went wrong with that request. Please try again.