jackc / pgx

PostgreSQL driver and toolkit for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PGXv4 returns ExclusionViolation (23P01) instead of UniqueViolation (23505) on unique field duplicates

DmitriyVTitov opened this issue · comments

When I insert duplicate value of field with UNIQUE constraint I get 23P01 error. I expect to get 23505 UniqueViolation instead.
Is that by design?

I would expect a 23505 as well. But that shouldn't have anything to do with pgx. It is simply reporting the error the server returned. You might want to try to produce the error in psql and see what happens there.

I would expect a 23505 as well. But that shouldn't have anything to do with pgx. It is simply reporting the error the server returned. You might want to try to produce the error in psql and see what happens there.

I thought so that pgx simply translates Postgres error codes but wanted to make sure. Thanks