You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of right now, that's probably your best bet. It might be worth checking with your sql driver (github.com/lib/pq I assume) to see if they have sentinel errors or something to compare against or type check with. Or maybe you can add a PR. Something like if dupErr, ok := err.(pq.DuplicateKey); ok { would be helpful in a lot of scenarios.
err:=dbm.Insert(foo)
ifpqerror, _:=err.(*pq.Error); pqerror.Code=="23505" {
err:=dbm.SelectOne(f, "select * from foo where a=$1 and b=$2", a, b)
iferr!=nil {
}
}
I am currently using this to
Is there a better way to handle a failed uniq constraint?
The text was updated successfully, but these errors were encountered: