diff options
Diffstat (limited to 'lib/arel/visitors/mysql.rb')
-rw-r--r-- | lib/arel/visitors/mysql.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/arel/visitors/mysql.rb b/lib/arel/visitors/mysql.rb index ee8483372a..4db5a94019 100644 --- a/lib/arel/visitors/mysql.rb +++ b/lib/arel/visitors/mysql.rb @@ -2,19 +2,19 @@ module Arel module Visitors class MySQL < Arel::Visitors::ToSql private - def visit_Arel_Nodes_Union o, suppress_parens = false + def visit_Arel_Nodes_Union o, a, suppress_parens = false left_result = case o.left when Arel::Nodes::Union - visit_Arel_Nodes_Union o.left, true + visit_Arel_Nodes_Union o.left, a, true else - visit o.left + visit o.left, a end right_result = case o.right when Arel::Nodes::Union - visit_Arel_Nodes_Union o.right, true + visit_Arel_Nodes_Union o.right, a, true else - visit o.right + visit o.right, a end if suppress_parens @@ -24,30 +24,30 @@ module Arel end end - def visit_Arel_Nodes_Bin o - "BINARY #{visit o.expr}" + def visit_Arel_Nodes_Bin o, a + "BINARY #{visit o.expr, a}" end ### # :'( # http://dev.mysql.com/doc/refman/5.0/en/select.html#id3482214 - def visit_Arel_Nodes_SelectStatement o + def visit_Arel_Nodes_SelectStatement o, a o.limit = Arel::Nodes::Limit.new(18446744073709551615) if o.offset && !o.limit super end - def visit_Arel_Nodes_SelectCore o + def visit_Arel_Nodes_SelectCore o, a o.froms ||= Arel.sql('DUAL') super end - def visit_Arel_Nodes_UpdateStatement o + def visit_Arel_Nodes_UpdateStatement o, a [ - "UPDATE #{visit o.relation}", - ("SET #{o.values.map { |value| visit value }.join ', '}" unless o.values.empty?), - ("WHERE #{o.wheres.map { |x| visit x }.join ' AND '}" unless o.wheres.empty?), - ("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?), - (visit(o.limit) if o.limit), + "UPDATE #{visit o.relation, a}", + ("SET #{o.values.map { |value| visit value, a }.join ', '}" unless o.values.empty?), + ("WHERE #{o.wheres.map { |x| visit x, a }.join ' AND '}" unless o.wheres.empty?), + ("ORDER BY #{o.orders.map { |x| visit x, a }.join(', ')}" unless o.orders.empty?), + (visit(o.limit, a) if o.limit), ].compact.join ' ' end |