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

upsert bug? #1333

Open
strarsis opened this issue Aug 8, 2016 · 4 comments
Open

upsert bug? #1333

strarsis opened this issue Aug 8, 2016 · 4 comments

Comments

@strarsis
Copy link

strarsis commented Aug 8, 2016

When saving a bookshelf record more than one time but with same id, it fails with a postgre sql error:

Unhandled rejection error: insert into "article" ("reference", "title") values ($1, $2) returning "reference" - duplicate key value violates unique constraint "article_reference_unique"
[...]

I prepared a sample for reproducing this issue: https://github.com/strarsis/bookshelf-upsert-issue

@dmlittle
Copy link

UPSERT was added to PostgreSQL in version 9.5 but the sample reproduction code is using v9.1. I believe you're not allowed to insert any records with the same unique id more than once in v9.1.

@strarsis
Copy link
Author

Thank you for looking into this issue.

Now I tried this also with 9.5/9.6/latest postgres version, but I still get the same error.
You can clone and try it here: https://github.com/strarsis/bookshelf-upsert-issue/tree/postgres_latest

@strarsis
Copy link
Author

So this issue also persists with a recent postgresql server.
How can I further debug this?

@strarsis strarsis mentioned this issue Sep 9, 2016
@strarsis
Copy link
Author

So the reason why this fails is that upsert isn't even implemented in underlying knex yet: knex/knex#54

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