prisma / quaint

SQL Query AST and Visitor for Rust
Apache License 2.0
582 stars 61 forks source link

Wrap MySql subselects for update/delete #399

Closed garrensmith closed 1 year ago

garrensmith commented 1 year ago

MySql will error if a Update or Delete query has a subselect that references a table that is being updated or deleted to get around that, we need to wrap the table in a tmp table name

UPDATE `crabbywilderness` SET `val` = ?
WHERE (`crabbywilderness`.`id`)
IN (SELECT `t1`.`id` FROM `crabbywilderness` AS `t1` INNER JOIN `breakabletomatoes` AS `j` ON `j`.`id` = `t1`.`id2`)