-
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
Convert VARCHAR, VARBINARY type to string #1281
Conversation
@methane can you please review this? |
I know that scanning into |
See also: jmoiron/sqlx#225 (comment) |
There are two sides for this issue (correct me If I am wrong here)
By mapping There are many cases where we can't define |
Correct.
Correct. But database/sql doesn't support
It is not Go way, because it may cause unnecessary allocations.
It makes allocation unavoidable in some situations.
For such cases, database/sql and this driver provide ColumnType.
Avoid unnecessary allocation, convertion, and memcpy. |
@@ -93,9 +93,6 @@ func (mf *mysqlField) typeDatabaseName() string { | |||
} | |||
return "TINYBLOB" | |||
case fieldTypeVarChar: | |||
if mf.charSet == collations[binaryCollation] { | |||
return "VARBINARY" | |||
} |
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.
Why did you remove it.
Description
Currently driver returns
VARCHAR
columns as[]byte
.When using
MapScan
, the specific column contains only byte information where it can be represented asstring
(similar issue golang/go#22544)For example: MySQL Java driver maps this properly to
string
https://github.com/mysql/mysql-connector-j/blob/4f7120a617b9d5efb9dedda9064b9896db424a60/src/main/core-api/java/com/mysql/cj/MysqlType.java#L277-L280
Similarly other
sql vendor
go clients mapVARCHAR
type tostring
.This PR fix the mapping of
VARCHAR
tostring
.Checklist