Skip to content

Support delete with join DELETE alias FROM tbl alias JOIN other_tbl ... #627

@LeoniePhiline

Description

@LeoniePhiline

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 ....

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions