Explorar el Código

Merge pull request #49 from niklaskorz/patch-1

Return ErrNotFound when no row matches the query, fixes tux21b/gocql#41
Christoph Hack hace 12 años
padre
commit
d4b09e6a97
Se han modificado 2 ficheros con 7 adiciones y 0 borrados
  1. 1 0
      AUTHORS
  2. 6 0
      session.go

+ 1 - 0
AUTHORS

@@ -5,3 +5,4 @@ Jonathan Rudenberg <jonathan@titanous.com>
 Thorsten von Eicken <tve@rightscale.com>
 Thorsten von Eicken <tve@rightscale.com>
 Matt Robenolt <mattr@disqus.com>
 Matt Robenolt <mattr@disqus.com>
 Phillip Couto <phillip.couto@stemstudios.com>
 Phillip Couto <phillip.couto@stemstudios.com>
+Niklas Korz <korz.niklask@gmail.com>

+ 6 - 0
session.go

@@ -161,6 +161,12 @@ func (q *Query) Iter() *Iter {
 // were selected, ErrNotFound is returned.
 // were selected, ErrNotFound is returned.
 func (q *Query) Scan(dest ...interface{}) error {
 func (q *Query) Scan(dest ...interface{}) error {
 	iter := q.Iter()
 	iter := q.Iter()
+	if iter.err != nil {
+		return iter.err
+	}
+	if len(iter.rows) == 0 {
+		return ErrNotFound
+	}
 	iter.Scan(dest...)
 	iter.Scan(dest...)
 	return iter.Close()
 	return iter.Close()
 }
 }