This commit is contained in:
Lunny Xiao 2021-07-03 09:36:40 +08:00
parent bd3350dce6
commit 87f3dec0c0
1 changed files with 12 additions and 2 deletions

View File

@ -107,6 +107,16 @@ func toFloat64(i interface{}) float64 {
return 0
}
func toBool(i interface{}) bool {
switch t := i.(type) {
case int32:
return t > 0
case bool:
return t
}
return false
}
func TestQueryInterface(t *testing.T) {
assert.NoError(t, PrepareEngine())
@ -281,13 +291,13 @@ func TestQueryInterfaceNoParam(t *testing.T) {
assert.NoError(t, err)
assert.EqualValues(t, 1, len(records))
assert.EqualValues(t, 1, records[0]["id"])
assert.EqualValues(t, false, records[0]["msg"])
assert.False(t, toBool(records[0]["msg"]))
records, err = testEngine.Table("get_var5").Where(builder.Eq{"id": 1}).QueryInterface()
assert.NoError(t, err)
assert.EqualValues(t, 1, len(records))
assert.EqualValues(t, 1, records[0]["id"])
assert.EqualValues(t, false, records[0]["msg"])
assert.False(t, toBool(records[0]["msg"]))
}
func TestQueryWithBuilder(t *testing.T) {