Cannot use FROM with multiple table names
designermonkey opened this issue · 3 comments
The following is expected:
UPDATE "themes", "entities"
SET
"themes"."name" = :themes.name
WHERE
"entities"."uuid" = :uuid
instead when doing ->table(Tables::THEMES . ', ' . Tables::ENTITIES)
I get:
UPDATE "themes," "entities"
SET
"themes"."name" = :themes.name
WHERE
"entities"."uuid" = :uuid
and when doing ->table(Tables::THEMES . ' , ' . Tables::ENTITIES)
I get:
UPDATE "themes" "," "entities"
SET
"themes"."name" = :themes.name
WHERE
"entities"."uuid" = :uuid
Interesting. Have never used something like this before.
What are you actually trying to do here?
Do you have any extra things in the where clause ? If not I believe all themes.name
will be replaced.
Normally we can keep themes.entities_uuid if we need to only update one . But I am not completely aware of what you are doing here.
The expected query is a way of getting around not being able to do joins in update statements. While it is valid for MySQL, it isn't for SQLite, so the alternative is a subselect.
I thought it best to mention this though. Could things like this be documented as 'not possible'?
I could see where the relevant Update classes could be modified to handle multiple calls to table()
and comma-separate them on output. @designermonkey if you want to submit a PR for that I'd be happy to review.