Skip to content

Commit

Permalink
调整:Where条件,如果入参是nil,则忽略
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Jul 8, 2024
1 parent 563c25e commit 0d4ff90
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tableSet.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,19 @@ func (receiver *TableSet[Table]) UseIndex(idxName string) *TableSet[Table] {
// Where 条件
func (receiver *TableSet[Table]) Where(query any, args ...any) *TableSet[Table] {
session := receiver.getOrCreateSession()
session.whereList.Add(whereQuery{
query: query,
args: args,
})
if query != nil {
// 过滤条件为nil
var notNilArgs []any
for _, arg := range args {
if arg != nil {
notNilArgs = append(notNilArgs, arg)
}
}
session.whereList.Add(whereQuery{
query: query,
args: notNilArgs,
})
}
return session
}

Expand Down

0 comments on commit 0d4ff90

Please sign in to comment.