Browse Source

Return ErrNotFound when no row matches the query

Niklas Korz 12 years ago
parent
commit
c60915c4c7
1 changed files with 3 additions and 0 deletions
  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()
 }