mirror of https://github.com/go-gorm/gorm.git
Fix duplicated error when Scan, close #4525
This commit is contained in:
parent
e1b4c066a8
commit
270e38c518
|
@ -454,9 +454,7 @@ func (db *DB) Scan(dest interface{}) (tx *DB) {
|
||||||
tx = db.getInstance()
|
tx = db.getInstance()
|
||||||
tx.Config = &config
|
tx.Config = &config
|
||||||
|
|
||||||
if rows, err := tx.Rows(); err != nil {
|
if rows, err := tx.Rows(); err == nil {
|
||||||
tx.AddError(err)
|
|
||||||
} else {
|
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
if rows.Next() {
|
if rows.Next() {
|
||||||
tx.ScanRows(rows, dest)
|
tx.ScanRows(rows, dest)
|
||||||
|
|
6
scan.go
6
scan.go
|
@ -102,9 +102,9 @@ func (db *DB) scanIntoStruct(sch *schema.Schema, rows *sql.Rows, reflectValue re
|
||||||
type ScanMode uint8
|
type ScanMode uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ScanInitialized ScanMode = 1 << 0 // 1
|
ScanInitialized ScanMode = 1 << 0 // 1
|
||||||
ScanUpdate ScanMode = 1 << 1 // 2
|
ScanUpdate ScanMode = 1 << 1 // 2
|
||||||
ScanOnConflictDoNothing ScanMode = 1 << 2 // 4
|
ScanOnConflictDoNothing ScanMode = 1 << 2 // 4
|
||||||
)
|
)
|
||||||
|
|
||||||
func Scan(rows *sql.Rows, db *DB, mode ScanMode) {
|
func Scan(rows *sql.Rows, db *DB, mode ScanMode) {
|
||||||
|
|
Loading…
Reference in New Issue