1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/arel/visitors/mysql.rb

17 lines
535 B
Ruby
Raw Normal View History

2010-09-23 18:26:08 -04:00
module Arel
module Visitors
class MySQL < Arel::Visitors::ToSql
def visit_Arel_Nodes_UpdateStatement o
[
"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?),
("LIMIT #{o.limit}" if o.limit),
].compact.join ' '
end
end
end
end