diff --git a/builder2.go b/builder2.go index b51a596..1757a22 100644 --- a/builder2.go +++ b/builder2.go @@ -67,6 +67,9 @@ func (b *Builder2) Sql() (string, error) { } filterSql, err := toWhereSql(b.Filter) + if err != nil { + return "", err + } sql := fmt.Sprintf("select %s from %s ", selectSql, fromSql) if joinSql != "" { @@ -226,6 +229,9 @@ func toWhereSql(where interface{}) (string, error) { //[ "a=","1","and",[["c=","3"],"and",["d=","4"]],"or",["b=","2"]] if whereGjson.IsArray() { + if len(whereGjson.Array()) == 0 { + return "", nil + } ws := []string{} expression := whereGjson.Array() @@ -277,6 +283,10 @@ func toWhereSql(where interface{}) (string, error) { // } } } else if whereGjson.IsObject() { + if len(whereGjson.Map()) == 0 { + return "", nil + } + newValue := []interface{}{ "and", }