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

Only try to update if the insert error was a unique constraint violation #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brendanlong
Copy link
Contributor

This fixes a problem I just ran into where I hadn't given my app the right permissions,
so it tried to do an insert and failed, then tried to do an update and didn't get an
error (but also didn't update any rows).

There are two levels of fixes:

  • Only try to do an update if the error was a unique constraint violation,
    since other errors should cause us to just stop immediately.
  • If we do an update and it doesn't actually update anything, return an error.

This fixes a problem I just ran into where I hadn't given my app the right permissions,
so it tried to do an insert and failed, then tried to do an update and didn't get an
error (but also didn't update any rows).

There are two levels of fixes:

 - Only try to do an update if the error was a unique constraint violation,
   since other errors should cause us to just stop immediately.
 - If we do an update and it doesn't actually update anything, return an error.
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

Successfully merging this pull request may close these issues.

1 participant