diff --git a/activerecord/test/cases/associations/association_scope_test.rb b/activerecord/test/cases/associations/association_scope_test.rb index 3e0032ec7367be1aa7200d3f5bc7b61574c0504d..dd26a85e442a71bab15d5c398dc3763d3ca35131 100644 --- a/activerecord/test/cases/associations/association_scope_test.rb +++ b/activerecord/test/cases/associations/association_scope_test.rb @@ -8,9 +8,9 @@ class AssociationScopeTest < ActiveRecord::TestCase test 'does not duplicate conditions' do scope = AssociationScope.scope(Author.new.association(:welcome_posts), Author.connection) - wheres = scope.where_values.map(&:right) - binds = scope.bind_values.map(&:last) - wheres = scope.where_values.map(&:right).reject { |node| + wheres = scope.where_clause.predicates.map(&:right) + binds = scope.where_clause.binds.map(&:last) + wheres.reject! { |node| Arel::Nodes::BindParam === node } assert_equal wheres.uniq, wheres diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 3bd7506bb5344ed849ac28c8fa80a4f098aed2e9..5ef84562ad46cab20a1e5ea04a3aa347d8bfe6dc 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -316,16 +316,16 @@ def test_association_protect_foreign_key # would be convenient), because this would cause that scope to be applied to any callbacks etc. def test_build_and_create_should_not_happen_within_scope car = cars(:honda) - scoped_count = car.foo_bulbs.where_values.count + scoped_count = car.foo_bulbs.where_clause.predicates.count bulb = car.foo_bulbs.build - assert_not_equal scoped_count, bulb.scope_after_initialize.where_values.count + assert_not_equal scoped_count, bulb.scope_after_initialize.where_clause.predicates.count bulb = car.foo_bulbs.create - assert_not_equal scoped_count, bulb.scope_after_initialize.where_values.count + assert_not_equal scoped_count, bulb.scope_after_initialize.where_clause.predicates.count bulb = car.foo_bulbs.create! - assert_not_equal scoped_count, bulb.scope_after_initialize.where_values.count + assert_not_equal scoped_count, bulb.scope_after_initialize.where_clause.predicates.count end def test_no_sql_should_be_fired_if_association_already_loaded diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index 4df75adeb47c52648b7d3350758a8a3a81e1acd7..c02509db46b1d78d2ebd0146d627617a13b71665 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -237,16 +237,16 @@ def test_building_the_associated_object_with_an_unrelated_type def test_build_and_create_should_not_happen_within_scope pirate = pirates(:blackbeard) - scoped_count = pirate.association(:foo_bulb).scope.where_values.count + scoped_count = pirate.association(:foo_bulb).scope.where_clause.predicates.count bulb = pirate.build_foo_bulb - assert_not_equal scoped_count, bulb.scope_after_initialize.where_values.count + assert_not_equal scoped_count, bulb.scope_after_initialize.where_clause.predicates.count bulb = pirate.create_foo_bulb - assert_not_equal scoped_count, bulb.scope_after_initialize.where_values.count + assert_not_equal scoped_count, bulb.scope_after_initialize.where_clause.predicates.count bulb = pirate.create_foo_bulb! - assert_not_equal scoped_count, bulb.scope_after_initialize.where_values.count + assert_not_equal scoped_count, bulb.scope_after_initialize.where_clause.predicates.count end def test_create_association diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb index 72963fd56c18a9f529e323183301a17f0e859b00..705f86a69900f666a764002a52b8c45c3a9bb4d7 100644 --- a/activerecord/test/cases/associations_test.rb +++ b/activerecord/test/cases/associations_test.rb @@ -238,7 +238,7 @@ def test_proxy_association_accessor end def test_scoped_allows_conditions - assert developers(:david).projects.merge!(where: 'foo').where_values.include?('foo') + assert developers(:david).projects.merge!(where: 'foo').where_clause.predicates.include?('foo') end test "getting a scope from an association" do diff --git a/activerecord/test/cases/relation/mutation_test.rb b/activerecord/test/cases/relation/mutation_test.rb index 2443f10269ca68a71361f833452afafbd796ccd1..003d870045affc306916dde3555e632e4f040515 100644 --- a/activerecord/test/cases/relation/mutation_test.rb +++ b/activerecord/test/cases/relation/mutation_test.rb @@ -136,12 +136,12 @@ def relation end test 'test_merge!' do - assert relation.merge!(where: :foo).equal?(relation) - assert_equal [:foo], relation.where_values + assert relation.merge!(select: :foo).equal?(relation) + assert_equal [:foo], relation.select_values end test 'merge with a proc' do - assert_equal [:foo], relation.merge(-> { where(:foo) }).where_values + assert_equal [:foo], relation.merge(-> { select(:foo) }).select_values end test 'none!' do diff --git a/activerecord/test/cases/relation/where_chain_test.rb b/activerecord/test/cases/relation/where_chain_test.rb index 0f9019bb1b386afe61fb4fd6bbd81d3aa20ea733..00c9a001c016de220a87d0caeb6cc8817c36f8eb 100644 --- a/activerecord/test/cases/relation/where_chain_test.rb +++ b/activerecord/test/cases/relation/where_chain_test.rb @@ -14,10 +14,10 @@ def setup def test_not_eq relation = Post.where.not(title: 'hello') - assert_equal 1, relation.where_values.length + assert_equal 1, relation.where_clause.predicates.length - value = relation.where_values.first - bind = relation.bind_values.first + value = relation.where_clause.predicates.first + bind = relation.where_clause.binds.first assert_bound_ast value, Post.arel_table[@name], Arel::Nodes::NotEqual assert_equal 'hello', bind.last @@ -26,7 +26,7 @@ def test_not_eq def test_not_null expected = Post.arel_table[@name].not_eq(nil) relation = Post.where.not(title: nil) - assert_equal([expected], relation.where_values) + assert_equal([expected], relation.where_clause.predicates) end def test_not_with_nil @@ -38,25 +38,25 @@ def test_not_with_nil def test_not_in expected = Post.arel_table[@name].not_in(%w[hello goodbye]) relation = Post.where.not(title: %w[hello goodbye]) - assert_equal([expected], relation.where_values) + assert_equal([expected], relation.where_clause.predicates) end def test_association_not_eq expected = Comment.arel_table[@name].not_eq(Arel::Nodes::BindParam.new) relation = Post.joins(:comments).where.not(comments: {title: 'hello'}) - assert_equal(expected.to_sql, relation.where_values.first.to_sql) + assert_equal(expected.to_sql, relation.where_clause.predicates.first.to_sql) end def test_not_eq_with_preceding_where relation = Post.where(title: 'hello').where.not(title: 'world') - value = relation.where_values.first - bind = relation.bind_values.first + value = relation.where_clause.predicates.first + bind = relation.where_clause.binds.first assert_bound_ast value, Post.arel_table[@name], Arel::Nodes::Equality assert_equal 'hello', bind.last - value = relation.where_values.last - bind = relation.bind_values.last + value = relation.where_clause.predicates.last + bind = relation.where_clause.binds.last assert_bound_ast value, Post.arel_table[@name], Arel::Nodes::NotEqual assert_equal 'world', bind.last end @@ -64,13 +64,13 @@ def test_not_eq_with_preceding_where def test_not_eq_with_succeeding_where relation = Post.where.not(title: 'hello').where(title: 'world') - value = relation.where_values.first - bind = relation.bind_values.first + value = relation.where_clause.predicates.first + bind = relation.where_clause.binds.first assert_bound_ast value, Post.arel_table[@name], Arel::Nodes::NotEqual assert_equal 'hello', bind.last - value = relation.where_values.last - bind = relation.bind_values.last + value = relation.where_clause.predicates.last + bind = relation.where_clause.binds.last assert_bound_ast value, Post.arel_table[@name], Arel::Nodes::Equality assert_equal 'world', bind.last end @@ -78,23 +78,23 @@ def test_not_eq_with_succeeding_where def test_not_eq_with_string_parameter expected = Arel::Nodes::Not.new("title = 'hello'") relation = Post.where.not("title = 'hello'") - assert_equal([expected], relation.where_values) + assert_equal([expected], relation.where_clause.predicates) end def test_not_eq_with_array_parameter expected = Arel::Nodes::Not.new("title = 'hello'") relation = Post.where.not(['title = ?', 'hello']) - assert_equal([expected], relation.where_values) + assert_equal([expected], relation.where_clause.predicates) end def test_chaining_multiple relation = Post.where.not(author_id: [1, 2]).where.not(title: 'ruby on rails') expected = Post.arel_table['author_id'].not_in([1, 2]) - assert_equal(expected, relation.where_values[0]) + assert_equal(expected, relation.where_clause.predicates[0]) - value = relation.where_values[1] - bind = relation.bind_values.first + value = relation.where_clause.predicates[1] + bind = relation.where_clause.binds.first assert_bound_ast value, Post.arel_table[@name], Arel::Nodes::NotEqual assert_equal 'ruby on rails', bind.last @@ -103,9 +103,9 @@ def test_chaining_multiple def test_rewhere_with_one_condition relation = Post.where(title: 'hello').where(title: 'world').rewhere(title: 'alone') - assert_equal 1, relation.where_values.size - value = relation.where_values.first - bind = relation.bind_values.first + assert_equal 1, relation.where_clause.predicates.size + value = relation.where_clause.predicates.first + bind = relation.where_clause.binds.first assert_bound_ast value, Post.arel_table[@name], Arel::Nodes::Equality assert_equal 'alone', bind.last end @@ -113,15 +113,15 @@ def test_rewhere_with_one_condition def test_rewhere_with_multiple_overwriting_conditions relation = Post.where(title: 'hello').where(body: 'world').rewhere(title: 'alone', body: 'again') - assert_equal 2, relation.where_values.size + assert_equal 2, relation.where_clause.predicates.size - value = relation.where_values.first - bind = relation.bind_values.first + value = relation.where_clause.predicates.first + bind = relation.where_clause.binds.first assert_bound_ast value, Post.arel_table['title'], Arel::Nodes::Equality assert_equal 'alone', bind.last - value = relation.where_values[1] - bind = relation.bind_values[1] + value = relation.where_clause.predicates[1] + bind = relation.where_clause.binds[1] assert_bound_ast value, Post.arel_table['body'], Arel::Nodes::Equality assert_equal 'again', bind.last end @@ -135,16 +135,16 @@ def assert_bound_ast value, table, type def test_rewhere_with_one_overwriting_condition_and_one_unrelated relation = Post.where(title: 'hello').where(body: 'world').rewhere(title: 'alone') - assert_equal 2, relation.where_values.size + assert_equal 2, relation.where_clause.predicates.size - value = relation.where_values.first - bind = relation.bind_values.first + value = relation.where_clause.predicates.first + bind = relation.where_clause.binds.first assert_bound_ast value, Post.arel_table['body'], Arel::Nodes::Equality assert_equal 'world', bind.last - value = relation.where_values.second - bind = relation.bind_values.second + value = relation.where_clause.predicates.second + bind = relation.where_clause.binds.second assert_bound_ast value, Post.arel_table['title'], Arel::Nodes::Equality assert_equal 'alone', bind.last @@ -153,28 +153,28 @@ def test_rewhere_with_one_overwriting_condition_and_one_unrelated def test_rewhere_with_range relation = Post.where(comments_count: 1..3).rewhere(comments_count: 3..5) - assert_equal 1, relation.where_values.size + assert_equal 1, relation.where_clause.predicates.size assert_equal Post.where(comments_count: 3..5), relation end def test_rewhere_with_infinite_upper_bound_range relation = Post.where(comments_count: 1..Float::INFINITY).rewhere(comments_count: 3..5) - assert_equal 1, relation.where_values.size + assert_equal 1, relation.where_clause.predicates.size assert_equal Post.where(comments_count: 3..5), relation end def test_rewhere_with_infinite_lower_bound_range relation = Post.where(comments_count: -Float::INFINITY..1).rewhere(comments_count: 3..5) - assert_equal 1, relation.where_values.size + assert_equal 1, relation.where_clause.predicates.size assert_equal Post.where(comments_count: 3..5), relation end def test_rewhere_with_infinite_range relation = Post.where(comments_count: -Float::INFINITY..Float::INFINITY).rewhere(comments_count: 3..5) - assert_equal 1, relation.where_values.size + assert_equal 1, relation.where_clause.predicates.size assert_equal Post.where(comments_count: 3..5), relation end end diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index 75d74ddc7ba4de0d066184ec1ef0859ee04372c6..d75c5435c6c58abb5aaea866f0e4e26793052b50 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -156,12 +156,12 @@ def test_references_values_dont_duplicate relation = Relation.new(FakeKlass, :b, nil) relation = relation.merge where: :lol, readonly: true - assert_equal [:lol], relation.where_values + assert_equal [:lol], relation.where_clause.predicates assert_equal true, relation.readonly_value end test 'merging an empty hash into a relation' do - assert_equal [], Relation.new(FakeKlass, :b, nil).merge({}).where_values + assert_equal Relation::WhereClause.empty, Relation.new(FakeKlass, :b, nil).merge({}).where_clause end test 'merging a hash with unknown keys raises' do @@ -173,7 +173,7 @@ def test_references_values_dont_duplicate values = relation.values values[:where] = nil - assert_not_nil relation.where_values + assert_not_nil relation.where_clause end test 'relations can be created with a values hash' do @@ -191,7 +191,7 @@ def self.sanitize_sql(args) relation = Relation.new(klass, :b, nil) relation.merge!(where: ['foo = ?', 'bar']) - assert_equal ['foo = bar'], relation.where_values + assert_equal ['foo = bar'], relation.where_clause.predicates end def test_merging_readonly_false diff --git a/activerecord/test/cases/scoping/default_scoping_test.rb b/activerecord/test/cases/scoping/default_scoping_test.rb index 0738df1b541e385771c339dcd34ca194cce935cc..d0835ba3e5def5cbeb580fa206b731134c98b0f3 100644 --- a/activerecord/test/cases/scoping/default_scoping_test.rb +++ b/activerecord/test/cases/scoping/default_scoping_test.rb @@ -284,8 +284,8 @@ def test_unscope_errors_with_non_symbol_or_hash_arguments def test_unscope_merging merged = Developer.where(name: "Jamis").merge(Developer.unscope(:where)) - assert merged.where_values.empty? - assert !merged.where(name: "Jon").where_values.empty? + assert merged.where_clause.empty? + assert !merged.where(name: "Jon").where_clause.empty? end def test_order_in_default_scope_should_not_prevail @@ -426,19 +426,19 @@ def test_default_scope_is_threadsafe test "additional conditions are ANDed with the default scope" do scope = DeveloperCalledJamis.where(name: "David") - assert_equal 2, scope.where_values.length + assert_equal 2, scope.where_clause.predicates.length assert_equal [], scope.to_a end test "additional conditions in a scope are ANDed with the default scope" do scope = DeveloperCalledJamis.david - assert_equal 2, scope.where_values.length + assert_equal 2, scope.where_clause.predicates.length assert_equal [], scope.to_a end test "a scope can remove the condition from the default scope" do scope = DeveloperCalledJamis.david2 - assert_equal 1, scope.where_values.length + assert_equal 1, scope.where_clause.predicates.length assert_equal Developer.where(name: "David").map(&:id), scope.map(&:id) end end diff --git a/activerecord/test/cases/scoping/named_scoping_test.rb b/activerecord/test/cases/scoping/named_scoping_test.rb index 41f344982810d0eb08ad3139322c3b06ab736fa0..57c9ff6a8d52771b04730ce4a91c19930fa520b3 100644 --- a/activerecord/test/cases/scoping/named_scoping_test.rb +++ b/activerecord/test/cases/scoping/named_scoping_test.rb @@ -380,7 +380,7 @@ def test_size_should_use_length_when_results_are_loaded end def test_should_not_duplicates_where_values - where_values = Topic.where("1=1").scope_with_lambda.where_values + where_values = Topic.where("1=1").scope_with_lambda.where_clause.predicates assert_equal ["1=1"], where_values end diff --git a/activerecord/test/cases/scoping/relation_scoping_test.rb b/activerecord/test/cases/scoping/relation_scoping_test.rb index d7bcbf62032dd86261dad8775b31e4b245438a8f..73760e628b72cc099fd114243dcd456ca088e716 100644 --- a/activerecord/test/cases/scoping/relation_scoping_test.rb +++ b/activerecord/test/cases/scoping/relation_scoping_test.rb @@ -184,7 +184,7 @@ def test_ensure_that_method_scoping_is_correctly_restored rescue end - assert !Developer.all.where_values.include?("name = 'Jamis'") + assert !Developer.all.where_clause.predicates.include?("name = 'Jamis'") end def test_default_scope_filters_on_joins