refactor buildUpdates (#884)
This commit is contained in:
parent
fd4a80bcad
commit
6542364944
|
@ -176,10 +176,8 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
|
||||||
}
|
}
|
||||||
|
|
||||||
if session.statement.ColumnStr == "" {
|
if session.statement.ColumnStr == "" {
|
||||||
colNames, args = buildUpdates(session.engine, session.statement.RefTable, bean, false, false,
|
colNames, args = session.statement.buildUpdates(bean, false, false,
|
||||||
false, false, session.statement.allUseBool, session.statement.useAllCols,
|
false, false, true)
|
||||||
session.statement.mustColumnMap, session.statement.nullableMap,
|
|
||||||
session.statement.columnMap, session.statement.omitColumnMap, true, session.statement.unscoped)
|
|
||||||
} else {
|
} else {
|
||||||
colNames, args, err = session.genUpdateColumns(bean)
|
colNames, args, err = session.genUpdateColumns(bean)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
17
statement.go
17
statement.go
|
@ -223,11 +223,18 @@ func (statement *Statement) setRefBean(bean interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto generating update columnes and values according a struct
|
// Auto generating update columnes and values according a struct
|
||||||
func buildUpdates(engine *Engine, table *core.Table, bean interface{},
|
func (statement *Statement) buildUpdates(bean interface{},
|
||||||
includeVersion bool, includeUpdated bool, includeNil bool,
|
includeVersion, includeUpdated, includeNil,
|
||||||
includeAutoIncr bool, allUseBool bool, useAllCols bool,
|
includeAutoIncr, update bool) ([]string, []interface{}) {
|
||||||
mustColumnMap map[string]bool, nullableMap map[string]bool,
|
engine := statement.Engine
|
||||||
columnMap columnMap, omitColumnMap columnMap, update, unscoped bool) ([]string, []interface{}) {
|
table := statement.RefTable
|
||||||
|
allUseBool := statement.allUseBool
|
||||||
|
useAllCols := statement.useAllCols
|
||||||
|
mustColumnMap := statement.mustColumnMap
|
||||||
|
nullableMap := statement.nullableMap
|
||||||
|
columnMap := statement.columnMap
|
||||||
|
omitColumnMap := statement.omitColumnMap
|
||||||
|
unscoped := statement.unscoped
|
||||||
|
|
||||||
var colNames = make([]string, 0)
|
var colNames = make([]string, 0)
|
||||||
var args = make([]interface{}, 0)
|
var args = make([]interface{}, 0)
|
||||||
|
|
Loading…
Reference in New Issue