diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-01-18 12:55:23 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-01-18 18:56:55 +0530 |
commit | 2a2bc8e84aa619089abcc4f9a4c2711a118e5fa9 (patch) | |
tree | 3ef933712b031887693528ae0657f2bf1448d56d /activerecord/lib | |
parent | 8bb527464845071ee72bcbcddcf860d4af1eda32 (diff) | |
download | rails-2a2bc8e84aa619089abcc4f9a4c2711a118e5fa9.tar.gz rails-2a2bc8e84aa619089abcc4f9a4c2711a118e5fa9.tar.bz2 rails-2a2bc8e84aa619089abcc4f9a4c2711a118e5fa9.zip |
Handle invalid query IN() generated when a blank array is supplied in hash conditions
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index 03f194c462..9e855209f9 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -24,7 +24,8 @@ module ActiveRecord case value when Array, ActiveRecord::Associations::AssociationCollection, ActiveRecord::NamedScope::Scope - attribute.in(value.to_a) + values = value.to_a + values.any? ? attribute.in(values) : attribute.eq(nil) when Range # TODO : Arel should handle ranges with excluded end. if value.exclude_end? |