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: Failed to scan int64 value #12401

Closed
libnat opened this issue Aug 30, 2015 · 1 comment
Closed

database/sql: Failed to scan int64 value #12401

libnat opened this issue Aug 30, 2015 · 1 comment
Milestone

Comments

@libnat
Copy link

@libnat libnat commented Aug 30, 2015

Version is v1.5

type Id int64

//....
var msgId Id
err = rows.Scan(&msgId)
//...

A panic error:

http: panic serving [::1]:51143: reflect.Set: value of type int64 is not assignable to type Id  
net/http.(*conn).serve.func1(0xc8200de000, 0x11a00a8, 0xc8200ba018)
    /usr/local/go/src/net/http/server.go:1287 +0xb5
reflect.Value.assignTo(0x2f9520, 0xc8200a6710, 0x46, 0x40fb50, 0xb, 0x2f91a0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/go/src/reflect/value.go:2158 +0x3be
reflect.Value.Set(0x2f91a0, 0xc8200a6770, 0xc6, 0x2f9520, 0xc8200a6710, 0x46)
    /usr/local/go/src/reflect/value.go:1327 +0x95
database/sql.convertAssign(0x2de5c0, 0xc8200a6770, 0x2f9520, 0xc8200a6710, 0x0, 0x0)
    /usr/local/go/src/database/sql/convert.go:207 +0x7ca
database/sql.(*Rows).Scan(0xc8200be240, 0xc8200f7780, 0x8, 0x8, 0x0, 0x0)
    /usr/local/go/src/database/sql/sql.go:1692 +0x47a

If change Id to :

 type Id uint64

everything goes all right

@libnat libnat changed the title Failed to scan int64 value in sql.Rows.scan Failed to scan int64 value in sql.Rows.scan [golang v1.5] Aug 30, 2015
@libnat libnat changed the title Failed to scan int64 value in sql.Rows.scan [golang v1.5] database/sql: Failed to scan int64 value Aug 30, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Aug 30, 2015
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 5, 2015

CL https://golang.org/cl/15420 mentions this issue.

@bradfitz bradfitz closed this in 4045774 Oct 6, 2015
@golang golang locked and limited conversation to collaborators Oct 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.