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 restriction on Scan value type seems useless #5066

Closed
gopherbot opened this issue Mar 17, 2013 · 5 comments
Closed

database/sql: driver restriction on Scan value type seems useless #5066

gopherbot opened this issue Mar 17, 2013 · 5 comments

Comments

@gopherbot
Copy link

by gtreguier:

What steps will reproduce the problem?

Just look at the existing tests in database/sql/convert_test.go where the source type is
string.

What is the expected output?

According to the documentation, the tests should fail:
a) "IsScanValue reports whether v is a valid Value scan type. Unlike IsValue,
IsScanValue does not permit the string type."
b) And driver.Rows.Next: "The dest slice may be populated only with a driver Value
type, but excluding string. All string values must be converted to []byte."

What do you see instead?

All tests pass.

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Linux

Which version are you using?  (run 'go version')
go version devel +77e6fc536a7d Thu Mar 14 14:35:47 2013 -0400 linux/amd64

Please provide any additional information below.

Maybe the documentation should be updated to remove the restriction on string type.
@gopherbot
Copy link
Author

Comment 1 by gtreguier:

There is another reference in the documentation to the restriction:
"string   [*] everywhere except from Rows.Next."

@gopherbot
Copy link
Author

Comment 2 by gtreguier:

These drivers return only []byte (no string).
- github.com/ziutek/mymysql
- github.com/Go-SQL-Driver/MySQL
- github.com/lxn/go-pgsql
- github.com/bmizerany/pq
- github.com/gwenn/gosqlite
- code.google.com/p/go-sqlite
- bitbucket.org/phiggins/go-db2-cli
These drivers may return string:
- github.com/weigj/go-odbc
- github.com/jgallagher/go-libpq
- github.com/mattn/go-sqlite3
- github.com/mattn/go-oci8
- github.com/mattn/go-adodb

@gopherbot
Copy link
Author

Comment 3 by gtreguier:

Here is a patch.
No regression in standard library test suite.
No regression in 'github.com/bradfitz/go-sql-test/src/sqltest'.
I don't know if the change made to 'IsScanValue' method can be considered as a Go1 api
break or not.

Attachments:

  1. driver.patch (1560 bytes)

@bradfitz
Copy link
Contributor

Comment 4:

I don't see the problem.  The rules are documented and implemented.
This bug and patch seems to be about changing the driver interface.
Closing this issue but feel free to elaborate and I could reopen if I'm not seeing the
problem.

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Author

Comment 5 by gtreguier:

Please,
Could you explain why the 'string' type is not allowed as Scan Value type?
And why 'convertAssign' correctly handles 'string' type as 'src' type?
Thanks.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

2 participants