summaryrefslogtreecommitdiffstats
path: root/vendor/xorm.io/xorm/session_update.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/xorm.io/xorm/session_update.go')
-rw-r--r--vendor/xorm.io/xorm/session_update.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/vendor/xorm.io/xorm/session_update.go b/vendor/xorm.io/xorm/session_update.go
index c5c65a452a..231163e063 100644
--- a/vendor/xorm.io/xorm/session_update.go
+++ b/vendor/xorm.io/xorm/session_update.go
@@ -377,10 +377,23 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
return 0, errors.New("No content found to be updated")
}
- sqlStr = fmt.Sprintf("UPDATE %v%v SET %v %v",
+ var tableAlias = session.engine.Quote(tableName)
+ var fromSQL string
+ if session.statement.TableAlias != "" {
+ switch session.engine.dialect.DBType() {
+ case core.MSSQL:
+ fromSQL = fmt.Sprintf("FROM %s %s ", tableAlias, session.statement.TableAlias)
+ tableAlias = session.statement.TableAlias
+ default:
+ tableAlias = fmt.Sprintf("%s AS %s", tableAlias, session.statement.TableAlias)
+ }
+ }
+
+ sqlStr = fmt.Sprintf("UPDATE %v%v SET %v %v%v",
top,
- session.engine.Quote(tableName),
+ tableAlias,
strings.Join(colNames, ", "),
+ fromSQL,
condSQL)
res, err := session.exec(sqlStr, append(args, condArgs...)...)