-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add upsert ability to SaveOperations #298
Comments
I had an idea to get this 99% of the way there and maintain type safety! Here's the rough sketch for how I think it would work: Add
|
Also worth noting that this does lock you in to one set of conflict keys per operation. After much research and thought I think that's ok. Typically you only use upsert/find_or_create in a few spots and the keys are typically the same. Secondly you could/should create a new operation if you want something with different conflict keys. Something like |
I love this and would simplify some stuff I am working on. I like the interface and how it mimics other interfaces used. Super small think is |
@wontruefree Glad to hear that this would be helpful! I am definitely not sold on
Honestly that's it. I'm having trouble thinking of anything else that better describes what this does |
After reading a little it seems like there is more then a 'uniqueness' constraint you can put on a key. Which is why I am guessing why postrgres used the term conflict. I like the idea of using |
Yeah good point on columns. We tend to use that more so I think |
I think the interface has the potential to be confusing if you leave the word conflict in it. Also I like columns better now that I see them. |
Hmm maybe |
The more I think about it and the reasons behind on conflict I feel like the term conflict makes sense. But for the base case the one that people will most likely use is uniqueness. So having |
Probably |
Sometimes you want to save a record, sometimes you want to create a record. But there's also some cases when you're not sure which one you need, so an
upsert
.The SQL would end up looking something like this using
ON CONFLICT
The text was updated successfully, but these errors were encountered: