-
Notifications
You must be signed in to change notification settings - Fork 499
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
QueryRow doesn't work as documented #126
Comments
@mikewilliamson what is the database type of Event.EventId ? |
@mikewilliamson I can reproduce it with the code: func TestBug126(t *testing.T) {
conn := open(t)
defer conn.Close()
var Id int
err := conn.QueryRow("select null").Scan(&Id)
if err != nil {
t.Fatal("Cannot scan to int: ", err.Error())
}
} select max(EventId) from Event is going to return null when there are no records in Event. select max(EventId) from Event where exists (select 1 from Event) |
Ah, got it, thanks. I was mistakenly thinking that the query would return no rows rather than one row with a null. My mistake. Actually what I want is something like:
|
Include details about migration locking in the FAQ
…er (denisenkom#126) * Added MarshalText() and UnmarshalJSON interfaces - The existing MarshalText() for the UniqueIdentifier type had a bad signature. It omitted returning an error that the interface expects. - Added UnmarshalJSON() interface to the UniqueIdentifier type with a test as well * use strings.Replace instead of ReplaceAll
I'm using this fragment of code, which is taken almost verbatim from the example given in the QueryRow documentation:
According to the docs, you would expect the message
No EventId
, but what you get is this:2015/09/11 10:38:53 sql: Scan error on column index 0: converting string "<nil>" to a int: strconv.ParseInt: parsing "<nil>": invalid syntax
Is this a bug in the driver, or in the sql package?
The text was updated successfully, but these errors were encountered: