Upgrade xorm to v1.1.1 (#16339)

This commit is contained in:
Lunny Xiao 2021-07-04 21:10:46 +08:00 committed by GitHub
parent 32fd11395b
commit 760af187ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 989 additions and 1201 deletions

View file

@ -11,6 +11,7 @@ import (
"sort"
"strconv"
"strings"
"time"
"xorm.io/xorm/internal/utils"
"xorm.io/xorm/schemas"
@ -374,9 +375,7 @@ func (session *Session) innerInsert(bean interface{}) (int64, error) {
return 1, nil
}
aiValue.Set(int64ToIntValue(id, aiValue.Type()))
return 1, nil
return 1, convertAssignV(aiValue.Addr(), id)
} else if len(table.AutoIncrement) > 0 && (session.engine.dialect.URI().DBType == schemas.POSTGRES ||
session.engine.dialect.URI().DBType == schemas.MSSQL) {
res, err := session.queryBytes(sqlStr, args...)
@ -416,9 +415,7 @@ func (session *Session) innerInsert(bean interface{}) (int64, error) {
return 1, nil
}
aiValue.Set(int64ToIntValue(id, aiValue.Type()))
return 1, nil
return 1, convertAssignV(aiValue.Addr(), id)
}
res, err := session.exec(sqlStr, args...)
@ -458,7 +455,9 @@ func (session *Session) innerInsert(bean interface{}) (int64, error) {
return res.RowsAffected()
}
aiValue.Set(int64ToIntValue(id, aiValue.Type()))
if err := convertAssignV(aiValue.Addr(), id); err != nil {
return 0, err
}
return res.RowsAffected()
}
@ -499,6 +498,16 @@ func (session *Session) genInsertColumns(bean interface{}) ([]string, []interfac
}
if col.IsDeleted {
colNames = append(colNames, col.Name)
if !col.Nullable {
if col.SQLType.IsNumeric() {
args = append(args, 0)
} else {
args = append(args, time.Time{}.Format("2006-01-02 15:04:05"))
}
} else {
args = append(args, nil)
}
continue
}