From 139c393f08b0c69b1aa6cf5ef932c5f05f2b56b3 Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Fri, 14 Aug 2020 09:59:11 +0800 Subject: [PATCH] add const ErrLastInsertIdUnavailable --- pkg/orm/db.go | 4 ++-- pkg/orm/db_mysql.go | 2 +- pkg/orm/db_oracle.go | 2 +- pkg/orm/orm.go | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/orm/db.go b/pkg/orm/db.go index dea8845f..2477b132 100644 --- a/pkg/orm/db.go +++ b/pkg/orm/db.go @@ -488,7 +488,7 @@ func (d *dbBase) InsertValue(q dbQuerier, mi *modelInfo, isMulti bool, names []s lastInsertId, err := res.LastInsertId() if err != nil { - DebugLog.Println("[WARN] return LastInsertId error:", err) + DebugLog.Println(ErrLastInsertIdUnavailable, ':', err) } return lastInsertId, nil } @@ -594,7 +594,7 @@ func (d *dbBase) InsertOrUpdate(q dbQuerier, mi *modelInfo, ind reflect.Value, a lastInsertId, err := res.LastInsertId() if err != nil { - DebugLog.Println("[WARN] return LastInsertId error:", err) + DebugLog.Println(ErrLastInsertIdUnavailable, ':', err) } return lastInsertId, nil } diff --git a/pkg/orm/db_mysql.go b/pkg/orm/db_mysql.go index 0db26e5b..11665fb2 100644 --- a/pkg/orm/db_mysql.go +++ b/pkg/orm/db_mysql.go @@ -167,7 +167,7 @@ func (d *dbBaseMysql) InsertOrUpdate(q dbQuerier, mi *modelInfo, ind reflect.Val lastInsertId, err := res.LastInsertId() if err != nil { - DebugLog.Println("[WARN] return LastInsertId error:", err) + DebugLog.Println(ErrLastInsertIdUnavailable, ':', err) } return lastInsertId, nil } diff --git a/pkg/orm/db_oracle.go b/pkg/orm/db_oracle.go index 91a30f81..5177fb89 100644 --- a/pkg/orm/db_oracle.go +++ b/pkg/orm/db_oracle.go @@ -153,7 +153,7 @@ func (d *dbBaseOracle) InsertValue(q dbQuerier, mi *modelInfo, isMulti bool, nam lastInsertId, err := res.LastInsertId() if err != nil { - DebugLog.Println("[WARN] return LastInsertId error:", err) + DebugLog.Println(ErrLastInsertIdUnavailable, ':', err) } return lastInsertId, nil } diff --git a/pkg/orm/orm.go b/pkg/orm/orm.go index 895636b6..5d81c764 100644 --- a/pkg/orm/orm.go +++ b/pkg/orm/orm.go @@ -85,6 +85,8 @@ var ( ErrStmtClosed = errors.New(" stmt already closed") ErrArgs = errors.New(" args error may be empty") ErrNotImplement = errors.New("have not implement") + + ErrLastInsertIdUnavailable = errors.New(" last insert id is unavailable") ) // Params stores the Params