Sha256: c1b4c637568759906a89e2e23e29a5abe76cb37ab0971a4680e7e062d602b513

Contents?: true

Size: 961 Bytes

Versions: 4

Compression:

Stored size: 961 Bytes

Contents

module Arel
  module Visitors
    class MySQL < Arel::Visitors::ToSql
      private
      def visit_Arel_Nodes_Lock o
        visit o.expr
      end

      ###
      # :'(
      # http://dev.mysql.com/doc/refman/5.0/en/select.html#id3482214
      def visit_Arel_Nodes_SelectStatement o
        o.limit = Arel::Nodes::Limit.new(18446744073709551615) if o.offset && !o.limit
        super
      end

      def visit_Arel_Nodes_SelectCore o
        o.froms ||= Arel.sql('DUAL')
        super
      end

      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?),
          (visit(o.limit) if o.limit),
        ].compact.join ' '
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
arel-2.0.10 lib/arel/visitors/mysql.rb
square-arel-2.0.9.20110222133018 lib/arel/visitors/mysql.rb
arel-2.0.9 lib/arel/visitors/mysql.rb
arel-2.0.9.rc1 lib/arel/visitors/mysql.rb