kysely
kysely copied to clipboard
Support "returning" functionality for MySQL dialect
Hi everyone! Thanks for such a great library! Could you please add "returning" functionality for MySQL? MySQL supports it from version 8.0.27 Thanks!
Yep, let's do this.
For now you should be able to enable it by overriding one property of MysqlAdapter https://kyse.link/MYZCF.
Where is the source on this? Can you provide a link to the docs? I'm on MySQL 8.0.31 and if I try to use RETURNING on INSERT it throws an error.
No mention of RETURNING here: https://dev.mysql.com/doc/refman/8.4/en/insert.html
No such thing in MySQL. https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-27.html
Sorry to raise an old thread, but using a mysql adapter and chaining a returning or returningAll method, it seems as though Kysely produces invalid SQL
input
await db
.insertInto("pet")
.values({
name: "Fluffy",
owner_id: 1,
species: "hamster",
})
.returningAll()
.executeTakeFirstOrThrow();
output
INSERT INTO
`pet` (`name`, `owner_id`, `species`)
VALUES
(?, ?, ?) returning *
AFAICT there are no versions of mysql which support RETURNING, so I would expect, at the very least, for this to raise a type error.
I'm running MySQL 8.4.3 and the above SQL query returns the following error:
Query 1 ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'returning *' at line 4
Just wanted to double check before opening a new issue, I rarely work with mysql so my knowledge may be inaccurate.
Hey @christiannaths 👋
Kysely outputs what you want it to. WYSIWYG and Bring Your Own SQL Knowledge are core principles.
@igalklebanov Ok, got it. Thanks for the reply :)