diff options
author | gmile <iamexile@gmail.com> | 2011-02-12 14:42:20 +0200 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-04-29 09:43:18 -0700 |
commit | 66a18855eafa71c11a37333ce1314889cbd0f742 (patch) | |
tree | cd49f3e6ff28b5f972ba34d1a89ac7f2d0df48f1 /activerecord | |
parent | 3331166b48281be27d10b59e2441cb06dc3fc740 (diff) | |
download | rails-66a18855eafa71c11a37333ce1314889cbd0f742.tar.gz rails-66a18855eafa71c11a37333ce1314889cbd0f742.tar.bz2 rails-66a18855eafa71c11a37333ce1314889cbd0f742.zip |
Test that passing nil member of array in conditions retrieves records with nil
value on a selected field.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/finder_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index 655437318f..9b6363902e 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -1045,6 +1045,28 @@ class FinderTest < ActiveRecord::TestCase :order => ' author_addresses_authors.id DESC ', :limit => 3).size end + def test_find_with_nil_inside_set_passed_for_attribute + client_of = Company.find( + :all, + :conditions => { + :client_of => [2, 1, nil], + :name => ['37signals', 'Summit', 'Microsoft'] }, + :order => 'client_of DESC' + ).map { |x| x.client_of } + + assert_equal [2, 1, nil], client_of + end + + def test_find_with_nil_inside_set_passed_for_attribute + client_of = Company.find( + :all, + :conditions => { :client_of => [nil] }, + :order => 'client_of DESC' + ).map { |x| x.client_of } + + assert_equal [nil], client_of + end + def test_with_limiting_with_custom_select posts = Post.find(:all, :include => :author, :select => ' posts.*, authors.id as "author_id"', :limit => 3, :order => 'posts.id') assert_equal 3, posts.size |