Skip to content

Commit

Permalink
MDEV-30412: JSON_OBJECTAGG doesn't escape double quote in key
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H authored and grooverdan committed Feb 14, 2023
1 parent c41c796 commit badf6de
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions mysql-test/main/func_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -1623,5 +1623,17 @@ id doc
{"$oid":"611c0a463b150154132f6636"} { "_id" : { "$oid" : "611c0a463b150154132f6636" }, "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : 1.0 } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] }
DROP TABLE arrNestTest;
#
# MDEV-30412 JSON_OBJECTAGG doesn't escape double quote in key
#
SELECT JSON_OBJECTAGG('"', 1);
JSON_OBJECTAGG('"', 1)
{"\"":1}
SELECT JSON_OBJECTAGG('\"', 1);
JSON_OBJECTAGG('\"', 1)
{"\"":1}
SELECT JSON_OBJECTAGG('\\', 1);
JSON_OBJECTAGG('\\', 1)
{"\\":1}
#
# End of 10.5 tests
#
8 changes: 8 additions & 0 deletions mysql-test/main/func_json.test
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,14 @@ INSERT INTO test.arrNestTest (doc) VALUES ('{ "_id" : { "$oid" : "611c0a463b1501
SELECT * FROM arrNestTest;
DROP TABLE arrNestTest;

--echo #
--echo # MDEV-30412 JSON_OBJECTAGG doesn't escape double quote in key
--echo #

SELECT JSON_OBJECTAGG('"', 1);
SELECT JSON_OBJECTAGG('\"', 1);
SELECT JSON_OBJECTAGG('\\', 1);

--echo #
--echo # End of 10.5 tests
--echo #
Expand Down
2 changes: 1 addition & 1 deletion sql/item_jsonfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4060,7 +4060,7 @@ bool Item_func_json_objectagg::add()
result.append(", ");

result.append("\"");
result.append(*key);
st_append_escaped(&result,key);
result.append("\":");

buf.length(0);
Expand Down

0 comments on commit badf6de

Please sign in to comment.