fix: fix same issue (#7002) in NOT conditions

This commit is contained in:
XuShuo 2024-05-01 07:23:53 +08:00
parent 9b20d98b32
commit 9caa8a4d4b
No known key found for this signature in database
GPG Key ID: 1FE25B87F2D51475

View File

@ -197,7 +197,8 @@ func (not NotConditions) Build(builder Builder) {
e, wrapInParentheses := c.(Expr) e, wrapInParentheses := c.(Expr)
if wrapInParentheses { if wrapInParentheses {
sql := strings.ToUpper(e.SQL) 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('(') builder.WriteByte('(')
} }
} }
@ -232,7 +233,8 @@ func (not NotConditions) Build(builder Builder) {
e, wrapInParentheses := c.(Expr) e, wrapInParentheses := c.(Expr)
if wrapInParentheses { if wrapInParentheses {
sql := strings.ToUpper(e.SQL) 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('(') builder.WriteByte('(')
} }
} }