TestTypesJSON tests JSON type handling
(t *testing.T)
| 184 | } |
| 185 | runQueryTests(t, tests) |
| 186 | } |
| 187 | |
| 188 | // TestTypesJSON tests JSON type handling |
| 189 | func TestTypesJSON(t *testing.T) { |
| 190 | tests := []QueryTest{ |
| 191 | // JSON literals |
| 192 | {Name: "json_object", Query: "SELECT '{\"a\": 1}'::JSON"}, |
| 193 | {Name: "json_array", Query: "SELECT '[1, 2, 3]'::JSON"}, |
| 194 | {Name: "json_nested", Query: "SELECT '{\"a\": {\"b\": 1}}'::JSON"}, |
| 195 | {Name: "json_string", Query: "SELECT '\"hello\"'::JSON"}, |
| 196 | {Name: "json_number", Query: "SELECT '42'::JSON"}, |
| 197 | {Name: "json_null", Query: "SELECT 'null'::JSON"}, |
| 198 | |
| 199 | // JSONB (may be stored as JSON) |
| 200 | {Name: "jsonb_object", Query: "SELECT '{\"a\": 1}'::JSONB"}, |
| 201 | {Name: "jsonb_array", Query: "SELECT '[1, 2, 3]'::JSONB"}, |
| 202 | |
| 203 | // JSON access operators |
| 204 | {Name: "json_arrow", Query: "SELECT '{\"a\": 1}'::JSON -> 'a'"}, |
| 205 | {Name: "json_double_arrow", Query: "SELECT '{\"a\": 1}'::JSON ->> 'a'"}, |
| 206 | {Name: "json_array_access", Query: "SELECT '[1, 2, 3]'::JSON -> 0"}, |
| 207 | {Name: "json_path", Query: "SELECT '{\"a\": {\"b\": 1}}'::JSON #> '{a,b}'", Skip: SkipUnsupportedByDuckDB}, |
| 208 | {Name: "json_path_text", Query: "SELECT '{\"a\": {\"b\": 1}}'::JSON #>> '{a,b}'", Skip: SkipUnsupportedByDuckDB}, |
| 209 | |
| 210 | // JSONB operators |
| 211 | {Name: "jsonb_contains", Query: "SELECT '{\"a\": 1, \"b\": 2}'::JSONB @> '{\"a\": 1}'::JSONB"}, |
| 212 | {Name: "jsonb_contained", Query: "SELECT '{\"a\": 1}'::JSONB <@ '{\"a\": 1, \"b\": 2}'::JSONB"}, |
| 213 | {Name: "jsonb_exists", Query: "SELECT '{\"a\": 1}'::JSONB ? 'a'"}, |
| 214 | |
| 215 | // From table |
| 216 | {Name: "select_json_data", Query: "SELECT data FROM json_data WHERE id = 1"}, |
| 217 | } |
| 218 | runQueryTests(t, tests) |
| 219 | } |
nothing calls this directly
no test coverage detected