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

PrimaryKeyViolationError is needed #11

Open
vsnal opened this issue Aug 13, 2019 · 4 comments
Open

PrimaryKeyViolationError is needed #11

vsnal opened this issue Aug 13, 2019 · 4 comments

Comments

@vsnal
Copy link

vsnal commented Aug 13, 2019

Possible use case:
Inserting duplicate key into a many-to-many relation table with a composite primary key.
Unique constraint not work here.

@koskimas
Copy link
Collaborator

This could make sense. Which db did you test this on?

@koskimas
Copy link
Collaborator

Maybe we just need to make that case throw UniqueViolationError too instead of adding a new error type.

@vsnal
Copy link
Author

vsnal commented Aug 13, 2019

Test on the MSSQL database:
error.nativeError.info = { number: 2627, state: 1, class: 14, message: 'Violation of PRIMARY KEY constraint '...'. Cannot insert duplicate key in object '...'. The duplicate key value is (1, 1).' }

Throw UniqueViolationError is an acceptable solution for that case.

@koskimas
Copy link
Collaborator

Thanks. If other databases throw UniqueViolationError in that case, I'll make MSSQL throw one too for consistency. If none of them do, maybe a separate PrimaryKeyViolationError is better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants