knex: Documentation for returning functionality in MySQL is not clear enough in all cases
Environment
Knex version: 0.16.5 Database + version: MySQL 5.7
Bug
db.insert({data}, 'an_id').into('foobar')
That sort of statement is giving returning() is not supported by mysql and will not have any effect. Note that this statement is not using returning() but is relying on Knex’s internal version of it for MySQL.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 30 (10 by maintainers)
The documentation promotes this syntax:
Tip: If you’re mutating a record in the database, and you have the input data, just return that directly upon a successful mutation.
ExpressJS example:
I think this is correct, but someone feel free to correct me.
@rijkvanzanten probably the easiest and fastest way for you is to write knex plugin, which implements crossdb insert that works in your case.
Something like:
Wow.
@jsumners Why are you passing second param to
insert? It is literally areturningargument.