This commit is contained in:
xing 2022-09-16 23:54:32 +08:00
parent 7c9e85dc3e
commit 9a362fc329

View File

@ -87,7 +87,6 @@ func (w SqlBuilder) ParseWhere(in ...[]interface{}) (string, []interface{}) {
w.parseType(ss, &args) w.parseType(ss, &args)
} else if len(ss) >= 5 && len(ss)%5 == 0 { } else if len(ss) >= 5 && len(ss)%5 == 0 {
j := len(ss) / 5 j := len(ss) / 5
fl := false
for i := 0; i < j; i++ { for i := 0; i < j; i++ {
start := i * 5 start := i * 5
end := start + 5 end := start + 5
@ -100,24 +99,21 @@ func (w SqlBuilder) ParseWhere(in ...[]interface{}) (string, []interface{}) {
} }
if i == 0 { if i == 0 {
s.WriteString("( ") s.WriteString("( ")
fl = true
} }
w.parseField(ss[start+1:end], &s) w.parseField(ss[start+1:end], &s)
s.WriteString(ss[start+2])
if w.parseIn(ss[start+1:end], &s, &c, &args, in) { if w.parseIn(ss[start+1:end], &s, &c, &args, in) {
s.WriteString(" and ") s.WriteString(" and ")
continue continue
} }
s.WriteString(ss[start+2])
s.WriteString(" ? and ") s.WriteString(" ? and ")
w.parseType(ss[start+1:end], &args) 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 ") ss := strings.TrimRight(s.String(), "and ")