-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathjsonb_test.go
29 lines (27 loc) · 866 Bytes
/
jsonb_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package sqlz
import "testing"
func TestJSONBBuilder(t *testing.T) {
runTests(t, func(dbz *DB) []test {
return []test{
{
"create a complex JSONB object",
dbz.
InsertInto("table").
Columns("data").
Values(
BuildJSONBObject(map[string]interface{}{
"string": "This is a string",
"number": 3,
"object": map[string]interface{}{
"subfield": "subval",
"subarray": []interface{}{1, 2, "3"},
},
"array": []interface{}{"one", "two", "three"},
}),
),
"INSERT INTO table (data) VALUES (jsonb_build_object(?, jsonb_build_array(?, ?, ?), ?, ?, ?, jsonb_build_object(?, jsonb_build_array(?, ?, ?), ?, ?), ?, ?))",
[]interface{}{"array", "one", "two", "three", "number", 3, "object", "subarray", 1, 2, "3", "subfield", "subval", "string", "This is a string"},
},
}
})
}