Skip to content

Commit

Permalink
fix: fix same issue (go-gorm#7002) in conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
VarusHsu committed Apr 30, 2024
1 parent 9b20d98 commit 794dc9b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions clause/where.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ func (not NotConditions) Build(builder Builder) {
e, wrapInParentheses := c.(Expr)
if wrapInParentheses {
sql := strings.ToUpper(e.SQL)
if wrapInParentheses = strings.Contains(sql, AndWithSpace) || strings.Contains(sql, OrWithSpace); wrapInParentheses {
if wrapInParentheses = strings.Contains(sql, AndWithSpace) || strings.Contains(sql, OrWithSpace) ||
strings.Contains(sql, AndSymbolWithSpace) || strings.Contains(sql, OrSymbolWithSpace); wrapInParentheses {
builder.WriteByte('(')
}
}
Expand Down Expand Up @@ -232,7 +233,8 @@ func (not NotConditions) Build(builder Builder) {
e, wrapInParentheses := c.(Expr)
if wrapInParentheses {
sql := strings.ToUpper(e.SQL)
if wrapInParentheses = strings.Contains(sql, AndWithSpace) || strings.Contains(sql, OrWithSpace); wrapInParentheses {
if wrapInParentheses = strings.Contains(sql, AndWithSpace) || strings.Contains(sql, OrWithSpace) ||
strings.Contains(sql, AndSymbolWithSpace) || strings.Contains(sql, OrSymbolWithSpace); wrapInParentheses {
builder.WriteByte('(')
}
}
Expand Down

0 comments on commit 794dc9b

Please sign in to comment.