-
Notifications
You must be signed in to change notification settings - Fork 131
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
Feature Request: More qrm error constants #109
Comments
@go-jet If you can show me how to correctly implement something like this within the lib I don't mind adding more. |
What do you mean by |
On databases you can put constraints to help maintain correct data and in some cases optimize searches.
Would add a constraint so that any ticket name would have to be unique. |
Here is an overview of constraints from the documentation. |
SQL driver is responsible for those kind of errors. Query() and Exec() methods will just forward driver errors, if there any. func UniqueViolation(err error) bool {
var pgErr *pgconn.PgError //asuming pgx driver is used
if errors.As(err, &pgErr) {
if pgErr.Code == "23505" {
return true
}
}
return false
} Or for |
This is great information. Love the way you think @go-jet |
We have a qrm.ErrNoRows, perhaps we should have more of these common errors as constants, like violating constraints.
qrm.ErrDuplicate
forduplicate key value violates unique constraint
, as an example.If anyone runs into or can think of any more that are common usecase, add them to this thread!
If theres an existing way to accomplish this, let me know!
The text was updated successfully, but these errors were encountered: