support mysql DELETE FROM ... JOIN / Postgresql DELETE..USING ?

Issue #959 resolved
created an issue

delete(table-or-join) should be acceptable with the mysql dialect and produce the expected DELETE FROM basetable JOIN etc. currently:

>>> metadata.bind = 'mysql:///test'
>>> print delete(parents_table)
>>> print delete(parents_table.join(children_table))
Traceback (most recent call last):
AttributeError: 'Join' object has no attribute 'name'
>>> print delete(parents_table.join(children_table).alias('x'))

Comments (7)

  1. Michael Bayer repo owner

    Allow delete where clause to refer multiple tables.

    Implemented "DELETE..FROM" syntax for Postgresql, MySQL, MS SQL Server (as well as within the unsupported Sybase dialect) in a manner similar to how "UPDATE..FROM" works. A DELETE statement that refers to more than one table will switch into "multi-table" mode and render the appropriate "USING" or multi-table "FROM" clause as understood by the database. Pull request courtesy Pieter Mulder.

    For SQL syntaxes see:

    Postgresql: MySQL: MSSQL: Sybase:

    Co-authored by: Mike Bayer Change-Id: I6dfd57b49e44a095d076dc493cd2360bb5d920d3 Pull-request: Fixes: #959

    → <<cset d12b37f90ef5>>

  2. Log in to comment