mysql
mysql copied to clipboard
ColumnType.Length() Support
The README states "This driver supports the ColumnType interface introduced in Go 1.8, with the exception of ColumnType.Length(), which is currently not supported."
I found the ColumnTypeLength
function commented out here: https://github.com/go-sql-driver/mysql/blob/578c4c8066964679ef44f45de2b6c7e811cc665e/rows.go#L66-L68
Based on the discussion in #667, it appears there were no limiting factors preventing this from being implemented: https://github.com/go-sql-driver/mysql/pull/667#issuecomment-334969273.
@julienschmidt can you confirm? Is this something that no one has gotten to yet? Or did you find some sort of limitation trying to implement this?
As written in the discussion at #667, the length MySQL reports is not the same as a string in Go with the same content would have. It seems to be the internal space requirement for storing it within MySQL, which is rather useless IMO. If you think you can implement in a way, which produces reliable and useful lengths: go for it!