I am using the pq driver and I'm wondering why the pq.Error gives an empty Column when I face a unique constraint violation.
I could parse Detail
but is there any reason why Column
would be empty? It would be preferable if I could just get email
from Column
instead of parsing Detail
Here is what the error looks like:
Severity:"ERROR"
Code:"23505"
Message:"duplicate key value violates unique constraint "unique_users""
Detail:"Key (email)=(user3@email.com) already exists."
Hint:""
Position:""
InternalPosition:""
InternalQuery:""
Where:""
Schema:"public"
Table:"users"
Column:""
DataTypeName:""
Constraint:"unique_users"
File:"nbtinsert.c"
Line:"534"
Routine:"_bt_check_unique"
Unfortunately, the Column
value is empty. I'm trying to come up with error messaging for my application and I'm wondering if there is some way to get that information so I can enhance the message why the entity was not created and let the caller know the field (email
in this case) as well.