Fix label count (#8267)
* fix label count * fix vendor * fix import order * update xorm to fix bug * fix tests * fix mssql bug
This commit is contained in:
parent
7cccada51e
commit
29dda47cbb
38 changed files with 959 additions and 580 deletions
51
vendor/github.com/go-xorm/xorm/session_update.go
generated
vendored
51
vendor/github.com/go-xorm/xorm/session_update.go
generated
vendored
|
@ -223,21 +223,31 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
|
|||
}
|
||||
|
||||
// for update action to like "column = column + ?"
|
||||
incColumns := session.statement.getInc()
|
||||
for _, v := range incColumns {
|
||||
colNames = append(colNames, session.engine.Quote(v.colName)+" = "+session.engine.Quote(v.colName)+" + ?")
|
||||
args = append(args, v.arg)
|
||||
incColumns := session.statement.incrColumns
|
||||
for i, colName := range incColumns.colNames {
|
||||
colNames = append(colNames, session.engine.Quote(colName)+" = "+session.engine.Quote(colName)+" + ?")
|
||||
args = append(args, incColumns.args[i])
|
||||
}
|
||||
// for update action to like "column = column - ?"
|
||||
decColumns := session.statement.getDec()
|
||||
for _, v := range decColumns {
|
||||
colNames = append(colNames, session.engine.Quote(v.colName)+" = "+session.engine.Quote(v.colName)+" - ?")
|
||||
args = append(args, v.arg)
|
||||
decColumns := session.statement.decrColumns
|
||||
for i, colName := range decColumns.colNames {
|
||||
colNames = append(colNames, session.engine.Quote(colName)+" = "+session.engine.Quote(colName)+" - ?")
|
||||
args = append(args, decColumns.args[i])
|
||||
}
|
||||
// for update action to like "column = expression"
|
||||
exprColumns := session.statement.getExpr()
|
||||
for _, v := range exprColumns {
|
||||
colNames = append(colNames, session.engine.Quote(v.colName)+" = "+v.expr)
|
||||
exprColumns := session.statement.exprColumns
|
||||
for i, colName := range exprColumns.colNames {
|
||||
switch tp := exprColumns.args[i].(type) {
|
||||
case string:
|
||||
colNames = append(colNames, session.engine.Quote(colName)+" = "+tp)
|
||||
case *builder.Builder:
|
||||
subQuery, subArgs, err := builder.ToSQL(tp)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
colNames = append(colNames, session.engine.Quote(colName)+" = ("+subQuery+")")
|
||||
args = append(args, subArgs...)
|
||||
}
|
||||
}
|
||||
|
||||
if err = session.statement.processIDParam(); err != nil {
|
||||
|
@ -468,14 +478,17 @@ func (session *Session) genUpdateColumns(bean interface{}) ([]string, []interfac
|
|||
continue
|
||||
}
|
||||
|
||||
if len(session.statement.columnMap) > 0 {
|
||||
if !session.statement.columnMap.contain(col.Name) {
|
||||
continue
|
||||
} else if _, ok := session.statement.incrColumns[col.Name]; ok {
|
||||
continue
|
||||
} else if _, ok := session.statement.decrColumns[col.Name]; ok {
|
||||
continue
|
||||
}
|
||||
// if only update specify columns
|
||||
if len(session.statement.columnMap) > 0 && !session.statement.columnMap.contain(col.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
if session.statement.incrColumns.isColExist(col.Name) {
|
||||
continue
|
||||
} else if session.statement.decrColumns.isColExist(col.Name) {
|
||||
continue
|
||||
} else if session.statement.exprColumns.isColExist(col.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
// !evalphobia! set fieldValue as nil when column is nullable and zero-value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue