From 66d5b42ee9d071458e9a430efeb135b29e51e896 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 24 Mar 2017 09:28:06 +0800 Subject: [PATCH] Add error if exists after parse raw query results, fix #1398 --- callback_query_preload.go | 4 ++++ scope.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/callback_query_preload.go b/callback_query_preload.go index b3fd4fb4..76d6f993 100644 --- a/callback_query_preload.go +++ b/callback_query_preload.go @@ -310,6 +310,10 @@ func (scope *Scope) handleManyToManyPreload(field *Field, conditions []interface } } + if err := rows.Err(); err != nil { + scope.Err(err) + } + // assign find results var ( indirectScopeValue = scope.IndirectValue() diff --git a/scope.go b/scope.go index 86fd1d42..29cb01b2 100644 --- a/scope.go +++ b/scope.go @@ -930,6 +930,10 @@ func (scope *Scope) pluck(column string, value interface{}) *Scope { scope.Err(rows.Scan(elem)) dest.Set(reflect.Append(dest, reflect.ValueOf(elem).Elem())) } + + if err := rows.Err(); err != nil { + scope.Err(err) + } } return scope }