Skip to content

Commit

Permalink
在写代码的过程中发现这个BUG会导致在没有tansaction的情况下,前一个查询的where影响后一个查询的where绑定
Browse files Browse the repository at this point in the history
  • Loading branch information
tobycroft committed Sep 26, 2021
1 parent 4c77e97 commit 739e92e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,17 @@ func (dba *Orm) Reset() IOrm {
//return NewOrm(dba.GetIEngin())
}

// Reset orm api and bind values reset to init
func (dba *Orm) ResetWithOutNewApi() IOrm {
dba.ClearBindValues()
dba.ResetUnion()
dba.ResetTable()
dba.ResetWhere()
dba.ResetExtraCols()
return dba
//return NewOrm(dba.GetIEngin())
}

// ResetTable ...
func (dba *Orm) ResetTable() IOrm {
dba.GetISession().SetIBinder(NewBinder())
Expand Down Expand Up @@ -362,6 +373,8 @@ func (dba *Orm) BuildSql(operType ...string) (a string, b []interface{}, err err
// 所以, 在这里做一下数据绑定重置操作
if dba.GetISession().GetTransaction() {
dba.Reset()
} else {
dba.ResetWithOutNewApi()
}
// 这里统一清理一下绑定的数据吧, 万一要复用了, 造成绑定数据感染, 就尴尬了
dba.ClearBindValues()
Expand Down

0 comments on commit 739e92e

Please sign in to comment.