Skip to content

Commit ed3f17f

Browse files
author
James Cor
committed
fix double unquoting in tests
1 parent 4670975 commit ed3f17f

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

enginetest/queries/json_scripts.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ var JsonScripts = []ScriptTest{
627627
SetUpScript: []string{
628628
"create table t (pk int primary key, col1 JSON, col2 JSON);",
629629
`insert into t values (1, JSON_OBJECT('key1', 1, 'key2', '"abc"'), JSON_ARRAY(3,10,5,17,"z"));`,
630-
`insert into t values (2, JSON_OBJECT('key1', 100, 'key2', '"ghi"'), JSON_ARRAY(3,10,5,17,JSON_ARRAY(22,"y",66)));`,
630+
`insert into t values (2, JSON_OBJECT('key1', 100, 'key2', 'ghi'), JSON_ARRAY(3,10,5,17,JSON_ARRAY(22,"y",66)));`,
631631
`CREATE TABLE t2 (i INT PRIMARY KEY, j JSON);`,
632632
`INSERT INTO t2 VALUES (0, '{"a": "123", "outer": {"inner": 456}}');`,
633633
},
@@ -636,16 +636,23 @@ var JsonScripts = []ScriptTest{
636636
Query: `select col1->'$.key1' from t;`,
637637
Expected: []sql.Row{{types.MustJSON("1")}, {types.MustJSON("100")}},
638638
},
639+
{
640+
Query: `select col1->'$.key2' from t;`,
641+
Expected: []sql.Row{
642+
{types.JSONDocument{Val: "\"abc\""}},
643+
{types.JSONDocument{Val: "ghi"}},
644+
},
645+
},
639646
{
640647
Query: `select col1->>'$.key2' from t;`,
641-
Expected: []sql.Row{{"abc"}, {"ghi"}},
648+
Expected: []sql.Row{{"\"abc\""}, {"ghi"}},
642649
},
643650
{
644651
Query: `select pk, col1 from t where col1->'$.key1' = 1;`,
645652
Expected: []sql.Row{{1, types.MustJSON(`{"key1":1, "key2":"\"abc\""}`)}},
646653
},
647654
{
648-
Query: `select pk, col1 from t where col1->>'$.key2' = 'abc';`,
655+
Query: `select pk, col1 from t where col1->>'$.key2' = '"abc"';`,
649656
Expected: []sql.Row{{1, types.MustJSON(`{"key1":1, "key2":"\"abc\""}`)}},
650657
},
651658
{

enginetest/queries/queries.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5412,6 +5412,12 @@ SELECT * FROM cte WHERE d = 2;`,
54125412
},
54135413
},
54145414
},
5415+
{
5416+
Query: `SELECT COALESCE(CAST('{"a": "one \\n two"}' as json), '');`,
5417+
Expected: []sql.Row{
5418+
{"{\"a\": \"one \\n two\"}"},
5419+
},
5420+
},
54155421
{
54165422
Query: "SELECT concat(s, i) FROM mytable",
54175423
Expected: []sql.Row{

sql/types/strings.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,6 @@ func ConvertToBytes(ctx context.Context, v interface{}, t sql.StringType, dest [
415415
if err != nil {
416416
return nil, err
417417
}
418-
// TODO: why do we do this?
419-
//val, err = strings.UnquoteBytes(val)
420-
if err != nil {
421-
return nil, err
422-
}
423418
start = 0
424419
case sql.Wrapper[string]:
425420
unwrapped, err := s.Unwrap(ctx)

0 commit comments

Comments
 (0)