1
0
Fork 0
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:
Aaron Patterson 2011-04-11 10:02:28 -07:00
parent 0505df1dbf
commit d7ed2338b1
4 changed files with 32 additions and 0 deletions

View file

@ -10,6 +10,7 @@ module Arel
end
%w{
Bin
Group
Grouping
Having

View file

@ -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

View file

@ -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
View 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