1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
module Arel class Deletion < Compound attributes :relation deriving :initialize, :== def to_sql(formatter = nil) [ "DELETE", "FROM #{table_sql}", ("WHERE #{wheres.collect(&:to_sql).join('\n\tAND ')}" unless wheres.blank? ), ("LIMIT #{taken}" unless taken.blank? ), ].compact.join("\n") end def call engine.delete(self) end end end