This commit is contained in:
hoteas 2018-07-30 19:21:14 +00:00
parent d7d7227ad8
commit fcb784e351

22
db.go
View File

@ -696,7 +696,9 @@ func (this *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
where += " " + ObjToStr(v) + " " where += " " + ObjToStr(v) + " "
} else { } else {
//fmt.Println(reflect.ValueOf(v).Type().String()) //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) //fmt.Println(v)
where += "`" + k + "` IN (" where += "`" + k + "` IN ("
@ -721,13 +723,9 @@ func (this *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
//res=append(res,(v.(Slice))[i]) //res=append(res,(v.(Slice))[i])
} }
} else { } else {
if v!=nil{
where += "`" + k + "`=? " where += "`" + k + "`=? "
res = append(res, v) 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{}) { func (this *HoTimeDB) notIn(k string, v interface{}, where string, res []interface{}) (string, []interface{}) {
//where:="" //where:=""
//fmt.Println(reflect.ValueOf(v).Type().String()) //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 (" where += "`" + k + "` NOT IN ("
res = append(res, (v.(Slice))...) res = append(res, (v.(Slice))...)
for i := 0; i < len(v.(Slice)); i++ { 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]) //res=append(res,(v.(Slice))[i])
} }
} else { } else {
if v!=nil{
where += "`" + k + "` !=? " where += "`" + k + "` !=? "
res = append(res, v) res = append(res, v)
}else{
where += "`" + k + "` IS NOT NULL "
}
} }