[fix] struct 中存在slice字段会报错误

This commit is contained in:
2023-06-21 11:07:25 +08:00
parent bf3032103e
commit 28d9dcbd4d
2 changed files with 9 additions and 8 deletions
+4 -2
View File
@@ -67,9 +67,10 @@ func TestScanJsonFieldStruct(t *testing.T) {
Id int `db:"id"`
Code string `db:"code"`
Map map[string]any `db:"map"`
Arr []int64 `db:"arr"`
}{}
myConn.Select(`select 0 as id, 'test' as code, '{"a":1}' as map`, []any{}, &dest)
myConn.Select(`select 0 as id, 'test' as code, '{"a":1}' as map, '[3, 4]' as arr`, []any{}, &dest)
t.Log(dest)
}
@@ -92,9 +93,10 @@ func TestScanJsonFieldStructSlice(t *testing.T) {
Id int `db:"id"`
Code string `db:"code"`
Map map[string]any `db:"map"`
Arr []any `db:"arr"`
}{}
myConn.Select(`select * from ((select 0 as id, 'test' as code, '{"a":1}' as map) union (select 1 as id, 'test1' as code, '{"a":2}' as map)) as t`, []any{}, &dest)
myConn.Select(`select * from ((select 0 as id, 'test' as code, '{"a":1}' as map, '[1, 2]' as arr) union (select 1 as id, 'test1' as code, '{"a":2}' as map, '[1, 2]' as arr)) as t`, []any{}, &dest)
t.Log(dest)
}