完善
This commit is contained in:
parent
3272dd4aea
commit
239a8729a6
|
@ -91,19 +91,17 @@ func (w SqlBuilder) ParseWhere(in ...[]interface{}) (string, []interface{}) {
|
|||
for i := 0; i < j; i++ {
|
||||
start := i * 5
|
||||
end := start + 5
|
||||
if ss[start] == "or" {
|
||||
st := s.String()
|
||||
if strings.Contains(st, "and ") {
|
||||
if strings.Contains(st, "and ") && ss[start] == "or" {
|
||||
st = strings.TrimRight(st, "and ")
|
||||
s.Reset()
|
||||
s.WriteString(st)
|
||||
s.WriteString(" or ")
|
||||
s.WriteString(fmt.Sprintf(" %s ", ss[start]))
|
||||
}
|
||||
if i == 0 {
|
||||
s.WriteString("( ")
|
||||
fl = true
|
||||
}
|
||||
|
||||
w.parseField(ss[start+1:end], &s)
|
||||
if w.parseIn(ss[start+1:end], &s, &c, &args, in) {
|
||||
s.WriteString(" and ")
|
||||
|
@ -112,17 +110,6 @@ func (w SqlBuilder) ParseWhere(in ...[]interface{}) (string, []interface{}) {
|
|||
s.WriteString(ss[start+2])
|
||||
s.WriteString(" ? and ")
|
||||
w.parseType(ss[start+1:end], &s, &args)
|
||||
} else {
|
||||
w.parseField(ss[start+1:end], &s)
|
||||
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:start+4], &s, &args)
|
||||
|
||||
}
|
||||
if i == j-1 && fl {
|
||||
st := s.String()
|
||||
st = strings.TrimRight(st, "and ")
|
||||
|
|
Loading…
Reference in New Issue
Block a user