diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-06-01 00:43:02 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-06-01 00:43:02 +0000 |
commit | 9fcc0654c37772a3d6884c5d6f7099a39fe88f73 (patch) | |
tree | ad4da3182056c22fac7492f315e5d71cee514b29 /activerecord | |
parent | 24a5a803f3d01d1b6d72e1fb22a97b3922848cae (diff) | |
download | rails-9fcc0654c37772a3d6884c5d6f7099a39fe88f73.tar.gz rails-9fcc0654c37772a3d6884c5d6f7099a39fe88f73.tar.bz2 rails-9fcc0654c37772a3d6884c5d6f7099a39fe88f73.zip |
Fixed that Base.find :all, :conditions => [ "id IN (?)", collection ] would fail if collection was empty [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4390 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 6 | ||||
-rwxr-xr-x | activerecord/test/base_test.rb | 4 |
3 files changed, 9 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 0ddefd8e92..f141c4b4b8 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that Base.find :all, :conditions => [ "id IN (?)", collection ] would fail if collection was empty [DHH] + * Add a list of regexes assert_queries skips in the ActiveRecord test suite. [Rick] * Fix the has_and_belongs_to_many #create doesn't populate the join for new records. Closes #3692 [josh@hasmanythrough.com] diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 511af69428..4d878e6a1d 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1309,7 +1309,11 @@ module ActiveRecord #:nodoc: def quote_bound_value(value) #:nodoc: if (value.respond_to?(:map) && !value.is_a?(String)) - value.map { |v| connection.quote(v) }.join(',') + if value.empty? + "null" + else + value.map { |v| connection.quote(v) }.join(',') + end else connection.quote(value) end diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 094d533a22..70035d6b4e 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -933,10 +933,10 @@ class BasicsTest < Test::Unit::TestCase end def test_quoting_arrays - replies = Reply.find(:all, :conditions => [ "id IN (?)", topics(:first).replies.to_s(:db) ]) + replies = Reply.find(:all, :conditions => [ "id IN (?)", topics(:first).replies.collect(&:id) ]) assert_equal topics(:first).replies.size, replies.size - replies = Reply.find(:all, :conditions => [ "id IN (?)", [].to_s(:db) ]) + replies = Reply.find(:all, :conditions => [ "id IN (?)", [] ]) assert_equal 0, replies.size end |