aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-27 12:07:06 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-27 12:07:06 -0700
commit6c235dd95812a7c4e8123b6d34d6f3433805ee1c (patch)
tree9c148b9d42c13a88fe646494529d9f756e391405 /activerecord/test/cases/relation
parent102a5272c5944a6f715da8332d18e7e0380727d1 (diff)
downloadrails-6c235dd95812a7c4e8123b6d34d6f3433805ee1c.tar.gz
rails-6c235dd95812a7c4e8123b6d34d6f3433805ee1c.tar.bz2
rails-6c235dd95812a7c4e8123b6d34d6f3433805ee1c.zip
Use an `Attribute` object to represent a bind value
The column is primarily used for type casting, which we're trying to separate from the idea of a column. Since what we really need is the combination of a name, type, and value, let's use the object that we already have to represent that concept, rather than this tuple. No consumers of the bind values have been changed, only the producers (outside of tests which care too much about internals). This is *finally* possible since the bind values are now produced from a reasonable number of lcoations.
Diffstat (limited to 'activerecord/test/cases/relation')
-rw-r--r--activerecord/test/cases/relation/merging_test.rb11
-rw-r--r--activerecord/test/cases/relation/where_clause_test.rb16
2 files changed, 8 insertions, 19 deletions
diff --git a/activerecord/test/cases/relation/merging_test.rb b/activerecord/test/cases/relation/merging_test.rb
index eb76ef6328..fe0854b7b4 100644
--- a/activerecord/test/cases/relation/merging_test.rb
+++ b/activerecord/test/cases/relation/merging_test.rb
@@ -91,17 +91,6 @@ class RelationMergingTest < ActiveRecord::TestCase
assert merged.to_sql.include?("bbq")
end
- def test_merging_keeps_lhs_bind_parameters
- column = Post.columns_hash['id']
- binds = [[column, 20]]
-
- right = Post.where(id: 20)
- left = Post.where(id: 10)
-
- merged = left.merge(right)
- assert_equal binds, merged.bind_values
- end
-
def test_merging_reorders_bind_params
post = Post.first
right = Post.where(id: 1)
diff --git a/activerecord/test/cases/relation/where_clause_test.rb b/activerecord/test/cases/relation/where_clause_test.rb
index f3644154b6..db18980e0b 100644
--- a/activerecord/test/cases/relation/where_clause_test.rb
+++ b/activerecord/test/cases/relation/where_clause_test.rb
@@ -47,15 +47,15 @@ class ActiveRecord::Relation
test "merge removes bind parameters matching overlapping equality clauses" do
a = WhereClause.new(
[table["id"].eq(bind_param), table["name"].eq(bind_param)],
- [[column("id"), 1], [column("name"), "Sean"]],
+ [attribute("id", 1), attribute("name", "Sean")],
)
b = WhereClause.new(
[table["name"].eq(bind_param)],
- [[column("name"), "Jim"]]
+ [attribute("name", "Jim")]
)
expected = WhereClause.new(
[table["id"].eq(bind_param), table["name"].eq(bind_param)],
- [[column("id"), 1], [column("name"), "Jim"]],
+ [attribute("id", 1), attribute("name", "Jim")],
)
assert_equal expected, a.merge(b)
@@ -103,10 +103,10 @@ class ActiveRecord::Relation
table["name"].eq(bind_param),
table["age"].gteq(bind_param),
], [
- [column("name"), "Sean"],
- [column("age"), 30],
+ attribute("name", "Sean"),
+ attribute("age", 30),
])
- expected = WhereClause.new([table["age"].gteq(bind_param)], [[column("age"), 30]])
+ expected = WhereClause.new([table["age"].gteq(bind_param)], [attribute("age", 30)])
assert_equal expected, where_clause.except("id", "name")
end
@@ -155,8 +155,8 @@ class ActiveRecord::Relation
Arel::Nodes::BindParam.new
end
- def column(name)
- ActiveRecord::ConnectionAdapters::Column.new(name, nil, nil)
+ def attribute(name, value)
+ ActiveRecord::Attribute.with_cast_value(name, value, ActiveRecord::Type::Value.new)
end
end
end