mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
adding a Bin node to emit mysql BINARY keywords
This commit is contained in:
parent
0505df1dbf
commit
d7ed2338b1
4 changed files with 32 additions and 0 deletions
|
@ -10,6 +10,7 @@ module Arel
|
|||
end
|
||||
|
||||
%w{
|
||||
Bin
|
||||
Group
|
||||
Grouping
|
||||
Having
|
||||
|
|
|
@ -2,6 +2,10 @@ module Arel
|
|||
module Visitors
|
||||
class MySQL < Arel::Visitors::ToSql
|
||||
private
|
||||
def visit_Arel_Nodes_Bin o
|
||||
"BINARY #{visit o.expr}"
|
||||
end
|
||||
|
||||
def visit_Arel_Nodes_Lock o
|
||||
visit o.expr
|
||||
end
|
||||
|
|
|
@ -133,6 +133,10 @@ key on UpdateManager using UpdateManager#key=
|
|||
].compact.join ' '
|
||||
end
|
||||
|
||||
def visit_Arel_Nodes_Bin o
|
||||
visit o.expr
|
||||
end
|
||||
|
||||
def visit_Arel_Nodes_With o
|
||||
"WITH #{o.children.map { |x| visit x }.join(', ')}"
|
||||
end
|
||||
|
|
23
test/nodes/test_bin.rb
Normal file
23
test/nodes/test_bin.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'helper'
|
||||
|
||||
module Arel
|
||||
module Nodes
|
||||
class TestBin < MiniTest::Unit::TestCase
|
||||
def test_new
|
||||
assert Arel::Nodes::Bin.new('zomg')
|
||||
end
|
||||
|
||||
def test_default_to_sql
|
||||
viz = Arel::Visitors::ToSql.new Table.engine
|
||||
node = Arel::Nodes::Bin.new(Arel.sql('zomg'))
|
||||
assert_equal 'zomg', viz.accept(node)
|
||||
end
|
||||
|
||||
def test_mysql_to_sql
|
||||
viz = Arel::Visitors::MySQL.new Table.engine
|
||||
node = Arel::Nodes::Bin.new(Arel.sql('zomg'))
|
||||
assert_equal 'BINARY zomg', viz.accept(node)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue