From 9a362fc329f35589475d3f99cd5195879c72ae60 Mon Sep 17 00:00:00 2001 From: xing Date: Fri, 16 Sep 2022 23:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/model.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/models/model.go b/models/model.go index fdd585d..9b3cf0b 100644 --- a/models/model.go +++ b/models/model.go @@ -87,7 +87,6 @@ func (w SqlBuilder) ParseWhere(in ...[]interface{}) (string, []interface{}) { w.parseType(ss, &args) } else if len(ss) >= 5 && len(ss)%5 == 0 { j := len(ss) / 5 - fl := false for i := 0; i < j; i++ { start := i * 5 end := start + 5 @@ -100,24 +99,21 @@ func (w SqlBuilder) ParseWhere(in ...[]interface{}) (string, []interface{}) { } if i == 0 { s.WriteString("( ") - fl = true } w.parseField(ss[start+1:end], &s) + s.WriteString(ss[start+2]) if w.parseIn(ss[start+1:end], &s, &c, &args, in) { s.WriteString(" and ") continue } - s.WriteString(ss[start+2]) s.WriteString(" ? and ") w.parseType(ss[start+1:end], &args) - if i == j-1 && fl { - st = s.String() - st = strings.TrimRight(st, "and ") - s.Reset() - s.WriteString(st) - s.WriteString(") and ") - } } + st := s.String() + st = strings.TrimRight(st, "and ") + s.Reset() + s.WriteString(st) + s.WriteString(") and ") } } ss := strings.TrimRight(s.String(), "and ")