Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Test that passing nil member of array in conditions retrieves records…

… with nil

value on a selected field.
  • Loading branch information...
commit 66a18855eafa71c11a37333ce1314889cbd0f742 1 parent 3331166
@gmile gmile authored tenderlove committed
Showing with 22 additions and 0 deletions.
  1. +22 −0 activerecord/test/cases/finder_test.rb
View
22 activerecord/test/cases/finder_test.rb
@@ -1045,6 +1045,28 @@ def test_find_with_order_on_included_associations_with_construct_finder_sql_for_
: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
Please sign in to comment.
Something went wrong with that request. Please try again.