Skip to content

Commit

Permalink
测试新WhereOr
Browse files Browse the repository at this point in the history
  • Loading branch information
tobycroft committed Oct 25, 2022
1 parent c9fce88 commit 5c05cd1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,16 @@ func (dba *Orm) Where(args ...interface{}) IOrm {
}

// Where : query or execute where condition, the relation is and
func (dba *Orm) WhereOr(args interface{}) IOrm {
func (dba *Orm) WhereOr(args interface{}, andor bool) IOrm {
// 如果只传入一个参数, 则可能是字符串、一维对象、二维数组
// 重新组合为长度为3的数组, 第一项为关系(and/or), 第二项为具体传入的参数 []interface{}
w := []interface{}{"andor", args}

dba.where = append(dba.where, w)
if andor {
w := []interface{}{"andor", args}
dba.where = append(dba.where, w)
} else {
w := []interface{}{"orand", args}
dba.where = append(dba.where, w)
}

return dba
}
Expand Down

0 comments on commit 5c05cd1

Please sign in to comment.