Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bind parameters can be differentiated from sql literals

  • Loading branch information...
commit 33f03c5557526d54c2b0053c79ea0e837016aef5 1 parent cbdc7e7
@tenderlove tenderlove authored
View
3  lib/arel/nodes/sql_literal.rb
@@ -6,5 +6,8 @@ class SqlLiteral < String
include Arel::AliasPredication
include Arel::OrderPredications
end
+
+ class BindParam < SqlLiteral
+ end
end
end
View
1  lib/arel/visitors/depth_first.rb
@@ -109,6 +109,7 @@ def terminal o
alias :visit_Arel_Nodes_Lock :terminal
alias :visit_Arel_Nodes_Node :terminal
alias :visit_Arel_Nodes_SqlLiteral :terminal
+ alias :visit_Arel_Nodes_BindParam :terminal
alias :visit_Arel_SqlLiteral :terminal
alias :visit_BigDecimal :terminal
alias :visit_Bignum :terminal
View
1  lib/arel/visitors/dot.rb
@@ -65,6 +65,7 @@ def unary o
visit_edge o, "expr"
end
alias :visit_Arel_Nodes_Group :unary
+ alias :visit_Arel_Nodes_BindParam :unary
alias :visit_Arel_Nodes_Grouping :unary
alias :visit_Arel_Nodes_Having :unary
alias :visit_Arel_Nodes_Limit :unary
View
1  lib/arel/visitors/to_sql.rb
@@ -374,6 +374,7 @@ def visit_Arel_Attributes_Attribute o
def literal o; o end
+ alias :visit_Arel_Nodes_BindParam :literal
alias :visit_Arel_Nodes_SqlLiteral :literal
alias :visit_Arel_SqlLiteral :literal # This is deprecated
alias :visit_Bignum :literal
View
1  test/nodes/test_node.rb
@@ -11,6 +11,7 @@ def test_all_nodes_are_nodes
Nodes.const_get(k)
}.grep(Class).each do |klass|
next if Nodes::SqlLiteral == klass
+ next if Nodes::BindParam == klass
next if klass.name =~ /^Arel::Nodes::Test/
assert klass.ancestors.include?(Nodes::Node), klass.name
end
View
6 test/visitors/test_to_sql.rb
@@ -9,6 +9,12 @@ module Visitors
@attr = @table[:id]
end
+ it 'works with BindParams' do
+ node = Nodes::BindParam.new 'omg'
+ sql = @visitor.accept node
+ sql.must_be_like 'omg'
+ end
+
it 'can define a dispatch method' do
visited = false
viz = Class.new(Arel::Visitors::Visitor) {
Please sign in to comment.
Something went wrong with that request. Please try again.