aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/relations/deletion.rb
blob: add6440c2aee57b32c0fd1ea2e6b01e025504e22 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module ActiveRelation
  module Relations
    class Deletion < Compound
      def initialize(relation)
        @relation = relation
      end
  
      def to_sql(strategy = nil)
        [
          "DELETE",
          "FROM #{table_sql}",
          ("WHERE #{selects.collect(&:to_sql).join('\n\tAND ')}" unless selects.blank?)
        ].compact.join("\n")
      end  
    end
  end
end