From fcb784e351cc041c65fd864c7d426d7c41ccc76c Mon Sep 17 00:00:00 2001 From: hoteas Date: Mon, 30 Jul 2018 19:21:14 +0000 Subject: [PATCH] --- db.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/db.go b/db.go index b44b883..6d7f5f6 100644 --- a/db.go +++ b/db.go @@ -694,9 +694,11 @@ func (this *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) { } else if k == "[#]" { k = strings.Replace(k, "[#]", "", -1) where += " " + ObjToStr(v) + " " - } else { + } else { //fmt.Println(reflect.ValueOf(v).Type().String()) - if reflect.ValueOf(v).Type().String() == "hotime.Slice" { + if v==nil{ + where += "`" + k + "` IS NULL" + }else if reflect.ValueOf(v).Type().String() == "hotime.Slice" { //fmt.Println(v) where += "`" + k + "` IN (" @@ -721,13 +723,9 @@ func (this *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) { //res=append(res,(v.(Slice))[i]) } } else { - if v!=nil{ + where += "`" + k + "`=? " res = append(res, v) - }else{ - where += "`" + k + "` IS NULL" - //res = append(res, v) - } } } @@ -739,7 +737,11 @@ func (this *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) { func (this *HoTimeDB) notIn(k string, v interface{}, where string, res []interface{}) (string, []interface{}) { //where:="" //fmt.Println(reflect.ValueOf(v).Type().String()) - if reflect.ValueOf(v).Type().String() == "hotime.Slice" { + if v==nil{ + + where += "`" + k + "` IS NOT NULL " + + }else if reflect.ValueOf(v).Type().String() == "hotime.Slice" { where += "`" + k + "` NOT IN (" res = append(res, (v.(Slice))...) for i := 0; i < len(v.(Slice)); i++ { @@ -762,12 +764,10 @@ func (this *HoTimeDB) notIn(k string, v interface{}, where string, res []interfa //res=append(res,(v.(Slice))[i]) } } else { - if v!=nil{ + where += "`" + k + "` !=? " res = append(res, v) - }else{ - where += "`" + k + "` IS NOT NULL " - } + }