Skip to content

Conversation

hurrba
Copy link
Contributor

@hurrba hurrba commented Feb 20, 2025

adds DuplicateKeyException and ForeignKeyViolationException

@isoos isoos merged commit 42059ed into isoos:master Feb 20, 2025
1 check passed
@isoos
Copy link
Owner

isoos commented Feb 20, 2025

Thank you! I've added a note in the changelog, bumped the version, but would delay publishing just a bit: in case we have something more over the next days, I'd rather bundle it up to get more change in a version. However, if you feel strongly about it, let me know and I can publish it any time.

@isoos
Copy link
Owner

isoos commented Feb 20, 2025

@hurrba:
Hm, I've just checked this page: https://www.postgresql.org/docs/current/errcodes-appendix.html
and the error code for 23505 is unique_violation. I think I will rename the exception to UniqueViolationException if you don't mind.

@hurrba
Copy link
Contributor Author

hurrba commented Feb 21, 2025

ah, yes that probably a good idea

@isoos
Copy link
Owner

isoos commented Feb 21, 2025

Published as 3.5.3.

@davidmartos96
Copy link
Contributor

davidmartos96 commented Feb 21, 2025

@isoos Could this PR implementation be reconsidered to be less breaking?

We have several instances where we handle PG errors as follows. I assume other people would have similar code, since 99% of the times the library throws ServerExceptions with all the fields.
On top of this error handling, we have other places which actually detect which constraintName failed, which is available in the ServerException class.
With this implementation those extra fields are not available.

Maybe the new exceptions could extend ServerException?

image

@isoos
Copy link
Owner

isoos commented Feb 21, 2025

Maybe the new exceptions could extend ServerException?

That's a very good point, I'll fix it shortly.

@isoos
Copy link
Owner

isoos commented Feb 21, 2025

Fixed the class hierarchy, published a new version, also retracted the previous one.

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.

3 participants