From a2eb8010d303b25c4ea5dcf27d3c8c137a3fc430 Mon Sep 17 00:00:00 2001 From: wangning Date: Sat, 23 Aug 2025 10:52:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:AND=20GROUP=20=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lxDb/sql.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lxDb/sql.go b/lxDb/sql.go index 24a1883..e57e520 100644 --- a/lxDb/sql.go +++ b/lxDb/sql.go @@ -221,14 +221,7 @@ func SqlQuery(tx *gorm.DB, sql string, list interface{}, q *PaginationQuery, par // 安全地添加 WHERE 子句 if hasWhere(sql) { // 原SQL已有WHERE子句 - // 确保 where 子句以 AND 或 OR 开头,然后安全添加 - if strings.HasPrefix(where, " AND ") || strings.HasPrefix(where, " OR ") { - builder.WriteString(where) - } else { - // 如果 where 不是以 AND/OR 开头,添加 AND 前缀 - builder.WriteString(" AND ") - builder.WriteString(strings.TrimSpace(where)) - } + builder.WriteString(where) // 去掉where 前头的and or .. } else { // 原SQL没有WHERE子句 if strings.HasPrefix(where, " AND ") { where = strings.Replace(where, " AND ", " WHERE ", 1)