Include 'LastInsertId' for exec queries.
This commit is contained in:
parent
5ec2f6ceb6
commit
104ddfd15b
1
main.go
1
main.go
@ -14,6 +14,7 @@ type DB struct {
|
|||||||
Value interface{}
|
Value interface{}
|
||||||
Error error
|
Error error
|
||||||
RowsAffected int64
|
RowsAffected int64
|
||||||
|
LastInsertId int64
|
||||||
callbacks *Callback
|
callbacks *Callback
|
||||||
db sqlCommon
|
db sqlCommon
|
||||||
parent *DB
|
parent *DB
|
||||||
|
3
scope.go
3
scope.go
@ -348,6 +348,9 @@ func (scope *Scope) Exec() *Scope {
|
|||||||
if count, err := result.RowsAffected(); scope.Err(err) == nil {
|
if count, err := result.RowsAffected(); scope.Err(err) == nil {
|
||||||
scope.db.RowsAffected = count
|
scope.db.RowsAffected = count
|
||||||
}
|
}
|
||||||
|
if lastInsertId, err := result.LastInsertId(); scope.Err(err) == nil {
|
||||||
|
scope.db.LastInsertId = lastInsertId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return scope
|
return scope
|
||||||
|
Loading…
x
Reference in New Issue
Block a user