aboutsummaryrefslogtreecommitdiffstats
path: root/test/nodes
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2017-07-21 08:33:09 -0400
committerSean Griffin <sean@seantheprogrammer.com>2017-07-21 08:33:09 -0400
commitdb1bb4e9a728a437d16f8bdb48c3b772c3e4edb0 (patch)
treef0f7623e9b730679adcb0dfe97f9c8415a91328f /test/nodes
parentf031a3b9aa6a8093802e0188abce58e0b997078e (diff)
downloadrails-db1bb4e9a728a437d16f8bdb48c3b772c3e4edb0.tar.gz
rails-db1bb4e9a728a437d16f8bdb48c3b772c3e4edb0.tar.bz2
rails-db1bb4e9a728a437d16f8bdb48c3b772c3e4edb0.zip
Add a value field `Nodes::BindParam`
This is part of a greater refactoring to have the `BindParam` nodes hold onto their values. We want to generally keep the AST decoupled from what you're actually doing with those values, but ultimately the usage of `BindParam` is almost identical to how you'd use `Casted` or `Quoted`. Forcing consumers of Arel's API to maintain the bind values separately from the AST makes manipulating the AST essentially impossible, as you would need to perform a full walk of the AST to determine whether a given node contains bind parameters, and which value it maps to. By storing the value on the bind parameter directly, we can collect them in another AST pass (realistically it'll be part of the same pass that performs SQL construction for performance reasons). This will dramatically simplify AST manipulation for Rails or any other consumers that work with bind params. As part of this change I've removed the `BindVisitor`, which appears to be dead code, and had tests break from this change.
Diffstat (limited to 'test/nodes')
-rw-r--r--test/nodes/test_bind_param.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/test/nodes/test_bind_param.rb b/test/nodes/test_bind_param.rb
index 011de6410c..482bb24f33 100644
--- a/test/nodes/test_bind_param.rb
+++ b/test/nodes/test_bind_param.rb
@@ -4,12 +4,17 @@ require 'helper'
module Arel
module Nodes
describe 'BindParam' do
- it 'is equal to other bind params' do
- BindParam.new.must_equal(BindParam.new)
+ it 'is equal to other bind params with the same value' do
+ BindParam.new(1).must_equal(BindParam.new(1))
+ BindParam.new("foo").must_equal(BindParam.new("foo"))
end
it 'is not equal to other nodes' do
- BindParam.new.wont_equal(Node.new)
+ BindParam.new(nil).wont_equal(Node.new)
+ end
+
+ it 'is not equal to bind params with different values' do
+ BindParam.new(1).wont_equal(BindParam.new(2))
end
end
end