Repository navigation
feat(upsert): return upserted record with options.returning=true - #8924
Conversation
| * @param {String} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only) | ||
| * | ||
| * @return {Promise<created>} Returns a boolean indicating whether the row was created or updated. | ||
| * @return {Promise<created>} Returns a boolean indicating whether the row was created or updated. For Postgres with (options.returning=true), it returns record and created boolean with signature `<Model, created>`. |
There was a problem hiding this comment.
In v5, we can set this Promise<record, created> by setting returning=true by default. One caveat is null is now first argument for other dialects. May be should set this as Promise<created, record>, but that doesn't match with other method's API. Any ideas?
There was a problem hiding this comment.
I have added support for MSSQL as well, so now may be current order make sense.
|
In issue #3354 there is discussion about MySQL support, but I find that Currently we support MSSQL and Postgres for this feature |
392ba45 to
81dd103
Compare
If they're using non-incrementing primary keys, they most probably won't need LAST_INSERTED_ID. Those who use auto-incremented primary keys (absolute majority) on MySql (#1 rdbms) have no use of the current upsert method. Please fix it! :) |
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
Close #3354
Sequelize still doesnot support
ON CONFLICT, but with usingRETURNINGits now possible for return upserted record.