Explorar el Código

Return ErrNotFound when no row matches the query

Niklas Korz hace 12 años
padre
commit
c60915c4c7
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      session.go

+ 3 - 0
session.go

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