Skip to content
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

database/sql/driver: update documentation on what types drivers can return from Scan calls #14621

Closed
pib opened this issue Mar 3, 2016 · 1 comment

Comments

@pib
Copy link

pib commented Mar 3, 2016

src/database/sql/driver/driver.go says

// Value is a value that drivers must be able to handle.
// It is either nil or an instance of one of these types:
//
// int64
// float64
// bool
// []byte
// string [*] everywhere except from Rows.Next.
// time.Time

and then in the driver.Rows.Scan spec it says:

// The dest slice may be populated only with
// a driver Value type, but excluding string.
// All string values must be converted to []byte.

But in sql.convertAssign which is called by sql.Rows.Scan, it actually handles values of pretty much every type depending on the type the value is being scanned into.

According to the spec, this fix for the go-sql-driver/mysql driver shouldn't work, but it does: go-sql-driver/mysql#434

It seems like the docs should be updated to reflect the actual behavior, or at least include all the types which are handled by asString and asBytes for values which are allowed to be returned from driver.Rows.Scan implementations.

@bradfitz
Copy link
Contributor

Fixed already in #6497

@golang golang locked and limited conversation to collaborators Apr 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants