mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
expose attributes of struct Result for package gdb
This commit is contained in:
@ -454,8 +454,8 @@ func (c *Core) DoInsert(ctx context.Context, link Link, table string, list List,
|
||||
err = gerror.WrapCode(gcode.CodeDbOperationError, err, `sql.Result.RowsAffected failed`)
|
||||
return stdSqlResult, err
|
||||
} else {
|
||||
batchResult.result = stdSqlResult
|
||||
batchResult.affected += affectedRows
|
||||
batchResult.Result = stdSqlResult
|
||||
batchResult.Affected += affectedRows
|
||||
}
|
||||
params = params[:0]
|
||||
valueHolder = valueHolder[:0]
|
||||
|
||||
@ -301,8 +301,8 @@ func (d *DriverOracle) DoInsert(ctx context.Context, link Link, table string, li
|
||||
if n, err := r.RowsAffected(); err != nil {
|
||||
return r, err
|
||||
} else {
|
||||
batchResult.result = r
|
||||
batchResult.affected += n
|
||||
batchResult.Result = r
|
||||
batchResult.Affected += n
|
||||
}
|
||||
params = params[:0]
|
||||
intoStr = intoStr[:0]
|
||||
|
||||
@ -15,8 +15,8 @@ import (
|
||||
// SqlResult is execution result for sql operations.
|
||||
// It also supports batch operation result for rowsAffected.
|
||||
type SqlResult struct {
|
||||
result sql.Result
|
||||
affected int64
|
||||
Result sql.Result
|
||||
Affected int64
|
||||
}
|
||||
|
||||
// MustGetAffected returns the affected rows count, if any error occurs, it panics.
|
||||
@ -44,16 +44,16 @@ func (r *SqlResult) MustGetInsertId() int64 {
|
||||
// driver may support this.
|
||||
// Also, See sql.Result.
|
||||
func (r *SqlResult) RowsAffected() (int64, error) {
|
||||
if r.result == nil {
|
||||
if r.Result == nil {
|
||||
return 0, nil
|
||||
}
|
||||
if r.affected > 0 {
|
||||
return r.affected, nil
|
||||
if r.Affected > 0 {
|
||||
return r.Affected, nil
|
||||
}
|
||||
if r.result == nil {
|
||||
if r.Result == nil {
|
||||
return 0, nil
|
||||
}
|
||||
return r.result.RowsAffected()
|
||||
return r.Result.RowsAffected()
|
||||
}
|
||||
|
||||
// LastInsertId returns the integer generated by the database
|
||||
@ -63,8 +63,8 @@ func (r *SqlResult) RowsAffected() (int64, error) {
|
||||
// statements varies.
|
||||
// Also, See sql.Result.
|
||||
func (r *SqlResult) LastInsertId() (int64, error) {
|
||||
if r.result == nil {
|
||||
if r.Result == nil {
|
||||
return 0, nil
|
||||
}
|
||||
return r.result.LastInsertId()
|
||||
return r.Result.LastInsertId()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user