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

Add new error for "Violation Check Constraint" #6992

Merged
merged 1 commit into from Apr 26, 2024

Conversation

anilsenay
Copy link
Contributor

@anilsenay anilsenay commented Apr 25, 2024

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Add new error for "Check Constraint Violation"

User Case Description

I added a check constraint in my table in PostgreSQL such as:
CONSTRAINT path_check CHECK (path ~ '^/[a-zA-Z0-9\-]+$')

When an error occurs when I try to add a new row to the table, I want to be sure that it is a rule violation error or another type of error.

if errors.Is(result.Error, gorm.ErrCheckConstraintViolated) {
  // handle check constraint violation error
}

Pull request for go-gorm/postgres: go-gorm/postgres#271

@jinzhu jinzhu merged commit ac59252 into go-gorm:master Apr 26, 2024
36 checks passed
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.

None yet

2 participants