iter: ErrNotFound bug fix

This commit is contained in:
Michał Matczuk
2017-09-22 15:02:12 +02:00
parent eef2c77a26
commit f2af2384ed
2 changed files with 31 additions and 5 deletions

View File

@@ -81,7 +81,7 @@ func (iter *Iterx) scanAny(dest interface{}, structOnly bool) bool {
return false
}
if iter.Iter.NumRows() == 0 {
iter.err = gocql.ErrNotFound
// no results or query error
return false
}
@@ -135,7 +135,7 @@ func (iter *Iterx) scanAll(dest interface{}, structOnly bool) bool {
return false
}
if iter.Iter.NumRows() == 0 {
iter.err = gocql.ErrNotFound
// no results or query error
return false
}
@@ -220,7 +220,7 @@ func (iter *Iterx) StructScan(dest interface{}) bool {
}
if iter.Iter.NumRows() == 0 {
iter.err = gocql.ErrNotFound
// no results or query error
return false
}
@@ -261,9 +261,15 @@ func columnNames(ci []gocql.ColumnInfo) []string {
// the query or the iteration.
func (iter *Iterx) Close() error {
err := iter.Iter.Close()
if err != nil && iter.err == nil {
iter.err = err
if iter.err == nil {
if err != nil {
iter.err = err
} else if iter.Iter.NumRows() == 0 {
iter.err = gocql.ErrNotFound
}
}
return iter.err
}