gorm icon indicating copy to clipboard operation
gorm copied to clipboard

PostgreSQL how to check if returned error is "Violates foreign key constraint" in GORM?

Open amirejaz75 opened this issue 1 year ago • 6 comments

Though I can check with the postgres returned error code but I don't want not to depend on postgres database and would like to handle with gorm. Recently, the support of ErrDuplicatedKey added that really helped to check the duplication using gorm.

I checked the following errors but nothing seems to check foreign key violates error. Am I missing something?

image

amirejaz75 avatar May 17 '23 16:05 amirejaz75