From 7721e700b252814dd623cca7c5de975bd7456a42 Mon Sep 17 00:00:00 2001 From: u Date: Thu, 16 Feb 2023 15:21:02 +0800 Subject: [PATCH] 'fix' --- builder2.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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", }