Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPDATE with JOIN generates invalid query for MySQL #1077

Closed
overflowz opened this issue Jul 10, 2024 · 1 comment
Closed

UPDATE with JOIN generates invalid query for MySQL #1077

overflowz opened this issue Jul 10, 2024 · 1 comment
Labels
api Related to library's API duplicate This issue or pull request already exists mysql Related to MySQL

Comments

@overflowz
Copy link

the following query:

await db.updateTable("tableA")
  .innerJoin("tableB", "tableB.id", "tableA.tableB_id")
  .set({ foo: 1 })
  .where("tableB.field", "=", 1)
  .execute();

generates following SQL:

update tableA
set foo = 1
inner join tableB on tableB.id = tableA.tableB_id
where tableB.field = 1

while correct syntax (for MySQL) should be:

update tableA
inner join tableB on tableB.id = tableA.tableB_id -- <-- order of these swapped
set foo = 1                                       -- <-- order of these swapped
where tableB.field = 1

tested with latest Kysely version (0.27.4) and using MySQL driver.

@overflowz
Copy link
Author

woops, duplicate of #192 (was searching for UPDATE with JOIN)

@igalklebanov igalklebanov added duplicate This issue or pull request already exists mysql Related to MySQL api Related to library's API labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to library's API duplicate This issue or pull request already exists mysql Related to MySQL
Projects
None yet
Development

No branches or pull requests

2 participants