SeaQL/sea-query

Support delete with join `DELETE alias FROM tbl alias JOIN other_tbl ...`

LeoniePhiline opened this issue · 1 comments

Motivation

A MariaDB/MySQL query like:

DELETE `activity` FROM `activity`
LEFT JOIN `subscription`
    ON `subscription`.`uid` = `activity`.`subscription`
WHERE 
  ...;

Proposed Solutions

DeleteStatement supports only from_table (https://docs.rs/sea-query/latest/sea_query/query/struct.DeleteStatement.html#method.from_table) but there is no support for stating from which table rows should be deleted when there are multiple tables involved in the query.

I propose to add DeleteStatement::table(table_ref) (or similarly named) to build the above query.

I also propose to add join support to DeleteStatement.

Additional Information

Note that DELETE FROM tbl LEFT JOIN other_tbl is a syntax error, as with joins "delete from which table" must is part of the syntax; i.e. DELETE tbl FROM tbl LEFT JOIN other_tbl.

This feature request for DELETE ... FROM ... JOIN ... is related to #608 - a feature request for UPDATE TABLE ... JOIN ... SET ....