aboutsummaryrefslogtreecommitdiffstats
path: root/test/collectors
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-11-17 14:52:38 -0800
committerSean Griffin <sean@thoughtbot.com>2014-11-17 14:52:38 -0800
commit590c784a30b13153667f8db7915998d7731e24e5 (patch)
tree4ac5e5ed038cb6c57c453909b344231603ee2928 /test/collectors
parent5035526b534a5d7c9d95eb6b66ade349c3a947f0 (diff)
downloadrails-590c784a30b13153667f8db7915998d7731e24e5.tar.gz
rails-590c784a30b13153667f8db7915998d7731e24e5.tar.bz2
rails-590c784a30b13153667f8db7915998d7731e24e5.zip
Add order to BindParams in the ToSql collector
This removes the need for us to do the re-ordering by walking the AST in ActiveRecord. We're using a block to communicate with the collector, since the collector needs to be the thing which knows about the index, while the visitor is the thing that needs to know the syntax. The BindParam needs to know about neither of these things, so it's been changed to stop being a subclass of SqlLiteral I could also see an alternative implementation using format strings if for some reason blocks cause a problem.
Diffstat (limited to 'test/collectors')
-rw-r--r--test/collectors/test_bind_collector.rb8
-rw-r--r--test/collectors/test_sql_string.rb2
2 files changed, 5 insertions, 5 deletions
diff --git a/test/collectors/test_bind_collector.rb b/test/collectors/test_bind_collector.rb
index 60532f061c..da55244a82 100644
--- a/test/collectors/test_bind_collector.rb
+++ b/test/collectors/test_bind_collector.rb
@@ -27,14 +27,14 @@ module Arel
end
def test_leaves_binds
- node = Nodes::BindParam.new 'omg'
+ node = Nodes::BindParam.new
list = compile node
assert_equal node, list.first
assert_equal node.class, list.first.class
end
def test_adds_strings
- bv = Nodes::BindParam.new('?')
+ bv = Nodes::BindParam.new
list = compile ast_with_binds bv
assert_operator list.length, :>, 0
assert_equal bv, list.grep(Nodes::BindParam).first
@@ -42,7 +42,7 @@ module Arel
end
def test_substitute_binds
- bv = Nodes::BindParam.new('?')
+ bv = Nodes::BindParam.new
collector = collect ast_with_binds bv
values = collector.value
@@ -59,7 +59,7 @@ module Arel
end
def test_compile
- bv = Nodes::BindParam.new('?')
+ bv = Nodes::BindParam.new
collector = collect ast_with_binds bv
sql = collector.compile ["hello", "world"]
diff --git a/test/collectors/test_sql_string.rb b/test/collectors/test_sql_string.rb
index 6d2e23151b..cd121a1364 100644
--- a/test/collectors/test_sql_string.rb
+++ b/test/collectors/test_sql_string.rb
@@ -27,7 +27,7 @@ module Arel
end
def test_compile
- bv = Nodes::BindParam.new('?')
+ bv = Nodes::BindParam.new
collector = collect ast_with_binds bv
sql = collector.compile ["hello", "world"]