diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-09-09 19:16:26 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-09-11 08:04:48 +0200 |
commit | 16868b53f9533ba48ca33bb694fade390f0ffe7e (patch) | |
tree | d25723db2b73ae81b4878f88c15ba27d519eff8d /activerecord/test | |
parent | 1245a9e06c66e77813fda621e825afdeacf2cd49 (diff) | |
download | rails-16868b53f9533ba48ca33bb694fade390f0ffe7e.tar.gz rails-16868b53f9533ba48ca33bb694fade390f0ffe7e.tar.bz2 rails-16868b53f9533ba48ca33bb694fade390f0ffe7e.zip |
A `NullRelation` should represent nothing. Closes #15176.
[Matthew Draper & Yves Senn]
Closes #16860. (pull request to discuss the implementation)
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relation/mutation_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation/mutation_test.rb b/activerecord/test/cases/relation/mutation_test.rb index 1da5c36e1c..4c94c2fd0d 100644 --- a/activerecord/test/cases/relation/mutation_test.rb +++ b/activerecord/test/cases/relation/mutation_test.rb @@ -18,6 +18,10 @@ module ActiveRecord def attribute_alias?(name) false end + + def sanitize_sql(sql) + sql + end end def relation diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 7163697a68..3bfbf95b0a 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -420,6 +420,11 @@ class RelationTest < ActiveRecord::TestCase assert_equal nil, ac.engines.maximum(:id) end + def test_null_relation_in_where_condition + assert_operator 0, :<, Comment.count # precondition, make sure there are comments. + assert_equal 0, Comment.where(post_id: Post.none).to_a.size + end + def test_joins_with_nil_argument assert_nothing_raised { DependentFirm.joins(nil).first } end |