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)