From 794dc9bc1e7c4ebbbd99cd778489605c183ebc28 Mon Sep 17 00:00:00 2001 From: XuShuo Date: Wed, 1 May 2024 07:23:53 +0800 Subject: [PATCH] fix: fix same issue (#7002) in conditions --- clause/where.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clause/where.go b/clause/where.go index 8e740ce9b..400baf0ee 100644 --- a/clause/where.go +++ b/clause/where.go @@ -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('(') } } @@ -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('(') } }