Skip to content

Commit

Permalink
Merge pull request #250 from hanchuanchuan/fix-update-alias-error
Browse files Browse the repository at this point in the history
fix: 修复update指定表别名时审核错误的问题(fix #249)
  • Loading branch information
hanchuanchuan committed Jul 23, 2020
2 parents 67e1ed1 + c3d39d8 commit ff008f0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion session/session_inception.go
Original file line number Diff line number Diff line change
Expand Up @@ -6333,7 +6333,11 @@ func (s *session) checkUpdate(node *ast.UpdateStmt, sql string) {
for _, l := range node.List {
// 未指定表别名时加默认设置
if l.Column.Table.L == "" && len(tableInfoList) == 1 {
l.Column.Table = model.NewCIStr(s.myRecord.TableInfo.Name)
if s.myRecord.TableInfo.AsName != "" {
l.Column.Table = model.NewCIStr(s.myRecord.TableInfo.AsName)
} else {
l.Column.Table = model.NewCIStr(s.myRecord.TableInfo.Name)
}
}

if s.checkFieldItem(l.Column, tableInfoList) {
Expand Down

0 comments on commit ff008f0

Please sign in to comment.