-
Notifications
You must be signed in to change notification settings - Fork 2.3k
added scan string type #976
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
Conversation
fields.go
Outdated
fieldTypeMediumBLOB, fieldTypeLongBLOB, fieldTypeBLOB, | ||
fieldTypeVarString, fieldTypeString, fieldTypeGeometry, fieldTypeJSON, | ||
fieldTypeTime: | ||
case fieldTypeVarChar, fieldTypeString, fieldTypeVarString: |
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.
Both of VARBINARY and VARCHAR uses VARCHAR field type.
This case statement should be merged in the next case.
fields.go
Outdated
if mf.charSet == collations[defaultCollation] { | ||
return scanTypeString | ||
} | ||
fallthrough |
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.
See https://dev.mysql.com/doc/refman/8.0/en/c-api-data-structures.html
To distinguish between binary and nonbinary data for string data types, check whether the charsetnr value is 63.
So correct code is this:
// charsetnr == 63 means this column is binary.
// https://dev.mysql.com/doc/refman/8.0/en/c-api-data-structures.html
if mf.charSet == 63 {
return scanTypeRawBytes
}
return scanTypeString
Added scanTypeString and scanTypeNullString.
I added the changes that @methane noted. Checklist
|
Would you merge master branch? |
Uuuhm. This is a breaking change! |
This reverts commit 5ee934f.
ColumnTypeScanType() now returns string and sql.NullString.
ColumnTypeScanType() now returns string and sql.NullString.
Description
The changes cover multiple issues:
#366
#407
jmoiron/sqlx#349
The ScanType for VARCHAR, TEXT, TINYTEXT and other string-like types correctly scans to go internal string type.
Checklist