Repository navigation
Conversation
| - CXX=clang++ | ||
| - npm_config_clang=1 | ||
| - COVERALLS_REPO_TOKEN=751SiA6QhY5EH4P2ygq7JFWulqiD2ETXO | ||
| - COVERALLS_PARALLEL=true |
|
@mickhansen This pull request is mainly for ON CONFLICT usage before API is confirmed, For Please focus on API design first. |
|
@inDream Roger that. We detect the version on first database connect: https://github.com/sequelize/sequelize/blob/master/lib/dialects/abstract/connection-manager.js#L198 |
|
Anyone would like to review the proposed API? |
|
@janmeier ping |
|
Great! THX for the update! Have a try now. |
|
Maybe use Also, yay travis-ci/travis-cookbooks#651! |
|
@janmeier Changed back to If |
|
@mickhansen Any plans on backporting this feature to 3.x ? |
|
@inDream I don't fully understand what |
|
@JLHwung I can also work on v3 branch. @janmeier @mickhansen where can I get the generated unique index key so user don't need to specify it. |
|
|
|
Arrived from: http://stackoverflow.com/questions/29063232/sequelize-upsert/29071422?noredirect=1#comment68297657_29071422 - I'm looking for a way to create or update an object and return it. At the moment I'm using findOrCreate with where and defaults the same, then setting the fields I want to set manually and calling save once that's finished. This seems like something the library should just do for me? Or am I asking too much? |
52d5980 to
d04a8db
Compare
|
Any update on this? |
|
It would be so awesome if this got merged in. Now I have to implement something on my own instead of using sequelize. |
|
Tests are failing |
|
@felixfbecker Tests are failing due to reasons not related to my codes. |
|
It must be related to the code, the failures are all related to |
|
|
72202c9 to
44fc829
Compare
44fc829 to
5676a3e
Compare
|
@inDream have you been continuing work on this? I'd be interested in seeing this get merged. |
|
After 2 years - don't hold your breath! 😉 |
|
@davidadas @IanIsFluent I would be available to work on it after next week. |
|
Excited to see some recent movement on this! |
5676a3e to
3735c5c
Compare
|
Any updates on this? |
1 similar comment
|
Any updates on this? |
|
wow.... any chance this will make it into sequelize? |
3735c5c to
577231d
Compare
577231d to
cf4ddd9
Compare
|
I'll give another +1 on hoping this someday makes it into sequelize. Looking at the failing travis-ci, seems like the only failing test is specifically it looks like upsert creates, but doesnt update the test column. Im pretty new to this (awesome) project, but I'll help how I can |
|
Yeah, I would like to know if I can actually help to deliver this faster? What needs to be done? @inDream |
|
i think this PR should be really looked, the gain of performance with postgres is impressive and now v9.5 is not young anymore |
|
Is there an update on this issue? I know people maintain Sequelize without compensation, which is incredible, but as heavy users of Sequelize in production, this issue is by far our number one ask and has been for years. Sounds like we're not alone We have seen database instability (Postgres on RDS), with rising CPUs due to blocking queries. This was AWS's official support response:
We're at the point where we're going to wrap all of our upserts in a custom function that performs a native postgres upsert directly (and properly calls the hooks afterwards), which is definitely gross. We feel that this is a more effective use of our team's time than (1) onboarding ourselves to the entire Seuqelize codebase, (2) submitting a substantial PR like #6325, and most critically (3) getting the community to accept it without nitpicking it like they did with this one for so long. We're also going to try out forking sequelize and merge this PR to our fork to see if it works properly. Reading through this whole thread, I'm still not fully clear on why this is not able to be merged. |
|
There was also #7174 which @sushantdhiman closed in favor of this PR over two years ago |
|
Looks like if #11163 is merged this PR may be closed, does anyone disagree? We are waiting for @thaddeusmt on that PR. |
|
Closing this in favor of #11163, if anyone disagrees please ping me. |
Pull Request check-list
npm run testornpm run test-DIALECTpass with this change (including linting)?Futurein the changelog?NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
Description of change
Implement `ON CONFLICT for postgres 9.5, Fix #4132 #3354.
It's a draft version since it's a breaking change.
I've used @ncwhale suggestion on
.upsert(), but review is needed.API: Model.upsert()
options.conflict.constraintandoptions.conflict.targetplease refer to https://www.postgresql.org/docs/9.5/static/sql-insert.htmloption.conflictis provided, auto detection for primary key is applied.bulkInsertuse the same options but underoptions.updateOnConflictnamespace.Usage
Todo
constraint_nameforoptions.conflict.constraint