diff --git a/builder2.go b/builder2.go index 1757a22..25c43a5 100644 --- a/builder2.go +++ b/builder2.go @@ -248,6 +248,9 @@ func toWhereSql(where interface{}) (string, error) { if whereSql == "" && (w.String() == "and" || w.String() == "or") { operator = w.String() } else { + if w.String() == "" { + continue + } ws = append(ws, w.String()) } } else { @@ -255,6 +258,9 @@ func toWhereSql(where interface{}) (string, error) { if err != nil { return "", err } + if newExp == "" { + continue + } ws = append(ws, newExp) } @@ -316,6 +322,9 @@ func toWhereSql(where interface{}) (string, error) { } else { whereSql = whereGjson.String() } + if strings.TrimSpace(whereSql) == "" { + return "", nil + } return fmt.Sprintf("( %s )", whereSql), nil }