diff --git a/activerecord/lib/active_record/relation/where_clause.rb b/activerecord/lib/active_record/relation/where_clause.rb index 1bf5cacca38edba17384873fc2d3a60ef385795f..46f064416ff54e0ff0fb7ea8d10644417d9fa4ee 100644 --- a/activerecord/lib/active_record/relation/where_clause.rb +++ b/activerecord/lib/active_record/relation/where_clause.rb @@ -87,7 +87,14 @@ def self.empty end def contradiction? - predicates.any? { |x| Arel::Nodes::In === x && Array === x.right && x.right.empty? } + predicates.any? do |x| + case x + when Arel::Nodes::In + Array === x.right && x.right.empty? + when Arel::Nodes::Equality + x.right.respond_to?(:unboundable?) && x.right.unboundable? + end + end end protected diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 8c99db9619408e05a33f93feef4fd567c80a6b6f..88b053ea83ba8b3a2cdbd97842baa79bf91de22e 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -905,14 +905,18 @@ def test_pluck_loaded_relation_sql_fragment def test_pick_one assert_equal "The First Topic", Topic.order(:id).pick(:heading) - assert_nil Topic.none.pick(:heading) - assert_nil Topic.where(id: 9999999999999999999).pick(:heading) + assert_no_queries do + assert_nil Topic.none.pick(:heading) + assert_nil Topic.where(id: 9999999999999999999).pick(:heading) + end end def test_pick_two assert_equal ["David", "david@loudthinking.com"], Topic.order(:id).pick(:author_name, :author_email_address) - assert_nil Topic.none.pick(:author_name, :author_email_address) - assert_nil Topic.where(id: 9999999999999999999).pick(:author_name, :author_email_address) + assert_no_queries do + assert_nil Topic.none.pick(:author_name, :author_email_address) + assert_nil Topic.where(id: 9999999999999999999).pick(:author_name, :author_email_address) + end end def test_pick_delegate_to_all diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index de4f501c82a549c81203ae03ece7d92d106c549b..a0572ae095e935cce263e7913efe494b3860cca2 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -397,15 +397,24 @@ def test_find_by_ids_with_limit_and_offset end def test_find_with_large_number - assert_raises(ActiveRecord::RecordNotFound) { Topic.find("9999999999999999999999999999999") } + Topic.send(:load_schema) + assert_no_queries do + assert_raises(ActiveRecord::RecordNotFound) { Topic.find("9999999999999999999999999999999") } + end end def test_find_by_with_large_number - assert_nil Topic.find_by(id: "9999999999999999999999999999999") + Topic.send(:load_schema) + assert_no_queries do + assert_nil Topic.find_by(id: "9999999999999999999999999999999") + end end def test_find_by_id_with_large_number - assert_nil Topic.find_by_id("9999999999999999999999999999999") + Topic.send(:load_schema) + assert_no_queries do + assert_nil Topic.find_by_id("9999999999999999999999999999999") + end end def test_find_on_relation_with_large_number