Skip to content
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

DB.onconflict() requires a primary key #56

Open
justinpryzby opened this issue Dec 11, 2020 · 0 comments
Open

DB.onconflict() requires a primary key #56

justinpryzby opened this issue Dec 11, 2020 · 0 comments
Milestone

Comments

@justinpryzby
Copy link
Contributor

justinpryzby commented Dec 11, 2020

It'd be more flexible and simpler to pass to postgres the list of columns or index name itself. But I guess you'd want to continue supporting the old way, too, so it wouldn't actually simplify anything.

I noticed this while adding something similar in telsasoft-specific db layer. We use unique indexes but not primary keys. There may be other reasons why we wouldn't use DB.insert(), too, but it'd be nice if this supported non-primary keys, and also multiple combinations of unique indexes.

Edit: of course I mean DB.upsert()
Edit: also, ON CONFLICT DO NOTHING needs no pkey nor columns nor unique index at all (even though in my experience that may be a bad idea since if an unique index is missing it causes no error)
Edit: also, ON CONFLICT allows WHERE clauses in two different places (in the ON CONFLICT and in the DO UPDATE SET). And some other syntactic cases. But, I'm actually using the where clauses now, but some of these are maybe "pie in the sky" and maybe of maybe marginal value.

@Cito Cito added this to the 6.1 milestone Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants