From 270e38c518260be891e227bbfd7521728aeb5309 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 29 Nov 2021 14:23:10 +0800 Subject: [PATCH] Fix duplicated error when Scan, close #4525 --- finisher_api.go | 4 +--- scan.go | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/finisher_api.go b/finisher_api.go index 920ea739..633a7fa0 100644 --- a/finisher_api.go +++ b/finisher_api.go @@ -454,9 +454,7 @@ func (db *DB) Scan(dest interface{}) (tx *DB) { tx = db.getInstance() tx.Config = &config - if rows, err := tx.Rows(); err != nil { - tx.AddError(err) - } else { + if rows, err := tx.Rows(); err == nil { defer rows.Close() if rows.Next() { tx.ScanRows(rows, dest) diff --git a/scan.go b/scan.go index b931aff4..b03b79b4 100644 --- a/scan.go +++ b/scan.go @@ -102,9 +102,9 @@ func (db *DB) scanIntoStruct(sch *schema.Schema, rows *sql.Rows, reflectValue re type ScanMode uint8 const ( - ScanInitialized ScanMode = 1 << 0 // 1 - ScanUpdate ScanMode = 1 << 1 // 2 - ScanOnConflictDoNothing ScanMode = 1 << 2 // 4 + ScanInitialized ScanMode = 1 << 0 // 1 + ScanUpdate ScanMode = 1 << 1 // 2 + ScanOnConflictDoNothing ScanMode = 1 << 2 // 4 ) func Scan(rows *sql.Rows, db *DB, mode ScanMode) {