Skip to content

Commit 53f66ae

Browse files
committed
add table query test
1 parent b487701 commit 53f66ae

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

enginetest/queries/json_scripts.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,29 @@ var JsonScripts = []ScriptTest{
202202
Name: "json conversion works with escaped characters",
203203
Assertions: []ScriptTestAssertion{
204204
{
205-
Query: `select cast(cast(JSON_OBJECT('key"with"quotes', 1) as char) as json);`,
205+
Query: `SELECT CAST(CAST(JSON_OBJECT('key"with"quotes', 1) as CHAR) as JSON);`,
206206
Expected: []sql.Row{
207207
{`{"key\"with\"quotes": 1}`},
208208
},
209209
},
210210
},
211211
},
212+
{
213+
Name: "json_object with escaped k:v pairs from table",
214+
SetUpScript: []string{
215+
`CREATE TABLE textt (t text);`,
216+
`INSERT INTO textt VALUES ('first row\n\\'), ('second row"');`,
217+
},
218+
Assertions: []ScriptTestAssertion{
219+
{
220+
Query: `SELECT JSON_OBJECT(t, t) FROM textt;`,
221+
Expected: []sql.Row{
222+
{types.MustJSON(`{"first row\n\\": "first row\n\\"}`)},
223+
{types.MustJSON(`{"second row\"": "second row\""}`)},
224+
},
225+
},
226+
},
227+
},
212228
{
213229
Name: "json_value preserves types",
214230
Assertions: []ScriptTestAssertion{

0 commit comments

Comments
 (0)