Fix postgres bug

This commit is contained in:
Lunny Xiao 2021-08-05 00:21:17 +08:00
parent 2ad8cfb1e8
commit aec6c89568
2 changed files with 5 additions and 0 deletions

View File

@ -176,6 +176,10 @@ func TestReplace(t *testing.T) {
"UPDATE table SET `a` = ~ `a`, `b`='abc`'",
"UPDATE table SET [a] = ~ [a], [b]='abc`'",
},
{
"INSERT INTO `insert_where` (`height`,`name`,`repo_id`,`width`,`index`) SELECT $1,$2,$3,$4,coalesce(MAX(`index`),0)+1 FROM `insert_where` WHERE (`repo_id`=$5)",
"INSERT INTO [insert_where] ([height],[name],[repo_id],[width],[index]) SELECT $1,$2,$3,$4,coalesce(MAX([index]),0)+1 FROM [insert_where] WHERE ([repo_id]=$5)",
},
}
for _, kase := range kases {

View File

@ -283,6 +283,7 @@ func (session *Session) insertStruct(bean interface{}) (int64, error) {
if err != nil {
return 0, err
}
sqlStr = session.engine.dialect.Quoter().Replace(sqlStr)
handleAfterInsertProcessorFunc := func(bean interface{}) {
if session.isAutoCommit {