aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engines/sql/relations/writes/delete.rb
blob: b22ee51e24e6c191c4831131c1d5bae22f37246c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
module Arel
  class Deletion < Compound
    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
  end
end