aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2013-02-08 05:22:38 -0800
committerGuillermo Iguaran <guilleiguaran@gmail.com>2013-02-08 05:22:38 -0800
commit85e1c4a058b32e3d1358ca5e24b469bdd658fc9c (patch)
tree91d115ad295551d0f6e75c08047ccdbe01e6f59b /activerecord/lib
parentbcf0e08a8df372ef1be376587e5bc206c740e5ef (diff)
parent16f6f2592e4e6c22f06d75eb8a6ec0cb68c9404b (diff)
downloadrails-85e1c4a058b32e3d1358ca5e24b469bdd658fc9c.tar.gz
rails-85e1c4a058b32e3d1358ca5e24b469bdd658fc9c.tar.bz2
rails-85e1c4a058b32e3d1358ca5e24b469bdd658fc9c.zip
Merge pull request #9216 from robertomiranda/where-with-empty-array
Activer Record: Change behaviour with empty array in where clause
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb2
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb
index d1458f30ba..2099effbeb 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -136,7 +136,7 @@ module ActiveRecord
records = load_target if records == :all
scope = through_association.scope
- scope.where! construct_join_attributes(*records)
+ scope.where! construct_join_attributes(*records) unless records.empty?
case method
when :destroy
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb
index 24cbae83de..db2588e725 100644
--- a/activerecord/lib/active_record/relation/predicate_builder.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder.rb
@@ -17,6 +17,8 @@ module ActiveRecord
queries.concat expand(association && association.klass, table, k, v)
end
end
+ elsif value.is_a?(Array) && value.empty?
+ raise ArgumentError, "Condition value in SQL clause can't be an empty array"
else
column = column.to_s