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 == "" {
|
||||
colNames, args = buildUpdates(session.engine, session.statement.RefTable, bean, false, false,
|
||||
false, false, session.statement.allUseBool, session.statement.useAllCols,
|
||||
session.statement.mustColumnMap, session.statement.nullableMap,
|
||||
session.statement.columnMap, session.statement.omitColumnMap, true, session.statement.unscoped)
|
||||
colNames, args = session.statement.buildUpdates(bean, false, false,
|
||||
false, false, true)
|
||||
} else {
|
||||
colNames, args, err = session.genUpdateColumns(bean)
|
||||
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
|
||||
func buildUpdates(engine *Engine, table *core.Table, bean interface{},
|
||||
includeVersion bool, includeUpdated bool, includeNil bool,
|
||||
includeAutoIncr bool, allUseBool bool, useAllCols bool,
|
||||
mustColumnMap map[string]bool, nullableMap map[string]bool,
|
||||
columnMap columnMap, omitColumnMap columnMap, update, unscoped bool) ([]string, []interface{}) {
|
||||
func (statement *Statement) buildUpdates(bean interface{},
|
||||
includeVersion, includeUpdated, includeNil,
|
||||
includeAutoIncr, update bool) ([]string, []interface{}) {
|
||||
engine := statement.Engine
|
||||
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 args = make([]interface{}, 0)
|
||||
|
|
Loading…
Reference in New Issue