rails/arel — pull request #145 by teleological (2012-09-30 12:45:50+00:00)
Title: Support for MySQL DELETE USING

Enables delete_all on has_many :through associations, e.g.

chapter_one.paragraphs.where(:editor_id => 1).delete_all

DELETE FROM `paragraphs` USING `paragraphs` INNER JOIN `sections` ON `paragraphs`.`section_id` = `sections`.`id` WHERE `sections`.`chapter_id` = 1 AND `paragraphs`.`editor_id` = 1

This could also be implemented for postgresql visitor, although the non-standard USING clause would only contain the names of join tables and the join condition would be merged into the WHERE clause.