-
Notifications
You must be signed in to change notification settings - Fork 6
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
One()/Next() : Unable to detect empty results #17
base: master
Are you sure you want to change the base?
Conversation
… single NULL datum
Looks good, I'll try it out and merge it when I get the chance. |
In the current version of the driver, you can always:
Similarly, for |
@elithrar I'm leaning toward adding this in, because otherwise it seems a bit hard to detect. What do you think? |
Seems awkward to test Also, if Id is an integer, you would have to test |
@jfbus Note that I'm assuming that @christopherhesse The Python & Ruby drivers return null—which doesn't really map across to the Go implementation—so I'm not too fussed. Note that I'm not against having more descriptive errors—I'm just wanting to make sure this is fully fleshed out and/or less verbose than the current option. I also think |
IMHO, The expected result for As far as the name is concerned, I started with |
Another option might be to do what the sql module does: http://golang.org/pkg/database/sql/#NullString This would presumably mean the user would have to make these container types, which doesn't sound like the greatest. |
Doesn't look good indeed. The error approach (used by the mongodb driver mgo) is much cleaner. |
} | ||
|
||
func (e ErrNullResult) Error() string { | ||
return "rethinkdb: Not found" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "rethinkdb: Null result", not found may be confusing in certain situations.
I gave you access so you can merge it when it's good to go. |
So I like this idea, but what about .All()? I think it would be confusing if you're iterating through a stream that may contain a null in it. If you got [item1 null item2] you'd end up with [item]. |
Also what if you try to scan into a type that does support being nil? Maybe there shouldn't be an error in that case. |
You are right. Here is a new proposal :
|
But should All() return an empty slice if I'm, for instance, scanning into []interface{} or (not sure if this works) []*string? |
nothing tells me if the row exists or not
Wouldn't it be better for One (+ Scan) to return an error in this case ?
returns true, even if there is nothing in the DB
one would expect to get false