I've been experimenting with database/sql with two different drivers
(go-mysql-driver and mymysql). If I have a NULL value in an integer
column, I'm getting strconv errors when scanning into an &int32.
With go-mysql-driver, I get:
sql: Scan error on column index 6: converting string "" to a int32:
strconv.ParseInt: parsing "": invalid syntax
(the driver code says it returns nil or []byte for every column in
rows.Next, so I would think driver.Value would be nil, but it looks
like []byte instead).
With mymysql/godrv, I get:
sql: Scan error on column index 6: converting string "<nil>" to a
int32: strconv.ParseInt: parsing "<nil>": invalid syntax
With mymysql/godrv, I can scan using a database/sql.NullInt64 as the
destination.
In this case, I'd prefer a null column to be scanned as a zero value
for the destination. Is that possible? Is that up to the driver or
is there something in database/sql that I'm missing?
Thanks,
Patrick
--
http://www.stathat.com
Invent stats on the fly. Track data instantly, up to the minute, accurately.