diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-05-26 15:12:39 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-05-26 15:12:39 -0700 |
commit | f2135aceeb679a14f017cd677eeaf67b84a76582 (patch) | |
tree | 2ef63759efd7a845242249405ab7520d91c923e8 /activerecord | |
parent | 178448ae9d10a27773f548e4b71390391882480f (diff) | |
download | rails-f2135aceeb679a14f017cd677eeaf67b84a76582.tar.gz rails-f2135aceeb679a14f017cd677eeaf67b84a76582.tar.bz2 rails-f2135aceeb679a14f017cd677eeaf67b84a76582.zip |
Allow empty arrays in where predicates
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder/array_handler.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb b/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb index 7f937e1875..78dba8be06 100644 --- a/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb +++ b/activerecord/lib/active_record/relation/predicate_builder/array_handler.rb @@ -2,6 +2,8 @@ module ActiveRecord class PredicateBuilder class ArrayHandler # :nodoc: def call(attribute, value) + return attribute.in([]) if value.empty? + values = value.map { |x| x.is_a?(Base) ? x.id : x } ranges, values = values.partition { |v| v.is_a?(Range) } nils, values = values.partition(&:nil?) |