-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 SQLState to MySQLError #1321
Add SQLState to MySQLError #1321
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it needs some little memory allocations, but not so frequently.
#1322 is acceptable for me.
@jmhodges @arnehormann @methane How do you think about it?
4ab8a7a
to
14893f1
Compare
14893f1
to
c0031c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove IsWithSQLState.
to allow library users to distinguish user-defined from client / server errors
c0031c2
to
0e8599a
Compare
Thank you @shogo82148 and @methane for your patience and thorough review. |
Why you add it as a field instead of a method? |
@iseki0 thank you for that input. but even if you are right - first, we cannot change it now. second, that would have been a wonderful code review comment. why did you sadly have to add it more than a year after it was merged and not when it was still open? Honestly, this is passive aggressive and not constructive and it contributes to maintainer burnout. why? something like: "To bad it's too late now, but for similar future consideration: making it a method instead of a function would have helped for situation xyz." which still gets the point across and helps. but without one-upping. |
@arnehormann My native language is not English. Sorry for my poor English. |
In Go, we often use var errorWithSQLState interface{ SQLState() string }
if errors.As(e, &errorWithSQLState) {
fmt.Println(errorWithSQLState.SQLState())
} If we use the |
Because I never think about such use cases. Your comment is the first time I heard about using SQLState as DB-independent error code. Both of database/sql and DB API in Python defines SQLState. sqlite3 error code doesn't mention about SQLState. They are my only experience. Is there any famous ORM implementation (not limited to Go) using SQLState as DB-independent error code?
Could you list several other SQL drivers? Currently, I feel abusing Unrap() for this is not worth enough. |
https://pkg.go.dev/github.com/godror/godror#OraErr.SQLState
😦Could you show me where the definition in the database/sql? I haven't found. I think if go standarized it, we should obey the standards. Just like the JDBC |
You can see the function in hibernate: |
Fortunately, we have |
|
Is there any Go ORM that want to use SQLState for DB-independent error handler? |
|
No paragraph at all. I meant database/sql doesn't provide a way to DB-independent API for SQLState. And this driver is based on it. And there is no feature request to support SQLState on database/sql nor PyMySQL nor mysqlclient-python. I doubt that using SQLState is common practice. |
thank you for this, it's the basis for a more constructive discussion. |
That's the problem. 😥😫 |
@iseki0 this driver aligns to database/sql. There might be capabilities not included there (e.g. providing io.Reader for LOAD DATA INFILE LOCAL), but we decide on an api without any global standard. |
Your reply is helpful. I'm also afraid that the Go team might give a standard which conflict with the current behaviour. The problem is Go's. |
Description
Allow library users to distinguish user-defined from client / server errors.
Checklist