Return ErrNotFound when no row matches the query, fixes tux21b/gocql#41
@@ -5,3 +5,4 @@ Jonathan Rudenberg <jonathan@titanous.com>
Thorsten von Eicken <tve@rightscale.com>
Matt Robenolt <mattr@disqus.com>
Phillip Couto <phillip.couto@stemstudios.com>
+Niklas Korz <korz.niklask@gmail.com>
@@ -161,6 +161,12 @@ func (q *Query) Iter() *Iter {
// were selected, ErrNotFound is returned.
func (q *Query) Scan(dest ...interface{}) error {
iter := q.Iter()
+ if iter.err != nil {
+ return iter.err
+ }
+ if len(iter.rows) == 0 {
+ return ErrNotFound
iter.Scan(dest...)
return iter.Close()
}