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
rows, err := db.Query("SELECT optional FROM t LIMIT 1?")
for rows.Next() {
var o mo.Option[string]
if err := rows.Scan(&o); err != nil {
t.Errorf("Failed scanning row: %s", err.Error())
continue
}
}
then will got Failed scanning row: sql: Scan error on column index 1, name "optional": failed to scan Option[T], and the reason is
that type of arg src of Scan is []uint8, and failed here when assert type is string, refer to sql.NullString, we can use the function sql.convertAssign to replace the driver.DefaultParameterConverter.ConvertValue to resolve it, but the convertAssign is private, and maybe won't be public(refer to golang/go#24258), so we can copy out the convertAssign and make some modification or write a new convert function? what do you think? Or have some other solution?
The text was updated successfully, but these errors were encountered:
For example
CREATE TABLE
t(
optionalVARCHAR(64));
then will got
Failed scanning row: sql: Scan error on column index 1, name "optional": failed to scan Option[T]
, and the reason isthat type of arg
src
of Scan is []uint8, and failed here when assert type isstring
, refer to sql.NullString, we can use the functionsql.convertAssign
to replace thedriver.DefaultParameterConverter.ConvertValue
to resolve it, but the convertAssign is private, and maybe won't be public(refer to golang/go#24258), so we can copy out the convertAssign and make some modification or write a new convert function? what do you think? Or have some other solution?The text was updated successfully, but these errors were encountered: