@@ -352,7 +352,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
352
352
97 , 110 , 97 , 103 , 101 , 114 ,
353
353
},
354
354
numRows : 5 ,
355
- want : "JSON_INSERT(%s, _utf8mb4'$.role', _utf8mb4\" manager\" )" ,
355
+ want : "JSON_INSERT(%s, _utf8mb4'$.role', CAST(JSON_QUOTE( _utf8mb4' manager') as JSON) )" ,
356
356
},
357
357
{
358
358
// The mysqlbinlog -vvv --base64-output=decode-rows output for the following event:
@@ -373,7 +373,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
373
373
},
374
374
name : "REPLACE" ,
375
375
numRows : 1 ,
376
- want : "JSON_REPLACE(%s, _utf8mb4'$.role', _utf8mb4\" IC \" )" ,
376
+ want : "JSON_REPLACE(%s, _utf8mb4'$.role', CAST(JSON_QUOTE( _utf8mb4'IC') as JSON) )" ,
377
377
},
378
378
{
379
379
name : "REMOVE" ,
@@ -486,7 +486,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
486
486
100 , 97 , 121 , 2 , 16 , 36 , 46 , 102 , 97 , 118 , 111 , 114 , 105 , 116 , 101 , 95 , 99 , 111 , 108 , 111 , 114 ,
487
487
},
488
488
numRows : 5 ,
489
- want : "JSON_REMOVE(JSON_REPLACE(%s, _utf8mb4'$.day', _utf8mb4\" monday\" ), _utf8mb4'$.favorite_color')" ,
489
+ want : "JSON_REMOVE(JSON_REPLACE(%s, _utf8mb4'$.day', CAST(JSON_QUOTE( _utf8mb4' monday') as JSON) ), _utf8mb4'$.favorite_color')" ,
490
490
},
491
491
{
492
492
name : "INSERT and REMOVE and REPLACE" ,
@@ -514,7 +514,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
514
514
1 , 7 , 36 , 46 , 104 , 111 , 98 , 98 , 121 , 8 , 12 , 6 , 115 , 107 , 105 , 105 , 110 , 103 ,
515
515
},
516
516
numRows : 1 ,
517
- want : "JSON_INSERT(JSON_REMOVE(JSON_REPLACE(%s, _utf8mb4'$.day', _utf8mb4\" tuesday\" ) , _utf8mb4'$.favorite_color'), _utf8mb4'$.hobby', _utf8mb4\" skiing\" )" ,
517
+ want : "JSON_INSERT(JSON_REMOVE(JSON_REPLACE(%s, _utf8mb4'$.day', CAST(JSON_QUOTE( _utf8mb4' tuesday') as JSON)) , _utf8mb4'$.favorite_color'), _utf8mb4'$.hobby', CAST(JSON_QUOTE( _utf8mb4' skiing') as JSON) )" ,
518
518
},
519
519
{
520
520
name : "REPLACE with null" ,
@@ -535,7 +535,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
535
535
109 , 97 , 105 , 110 , 46 , 99 , 111 , 109 , 13 , 0 , 0 , 0 , 0 , 8 , 36 , 46 , 115 , 97 , 108 , 97 , 114 , 121 , 2 , 4 , 0 ,
536
536
},
537
537
numRows : 1 ,
538
- want : "JSON_REPLACE(%s, _utf8mb4'$.salary', null)" ,
538
+ want : "JSON_REPLACE(%s, _utf8mb4'$.salary', CAST(_utf8mb4' null' as JSON) )" ,
539
539
},
540
540
{
541
541
name : "REPLACE 2 paths" ,
@@ -557,7 +557,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
557
557
105 , 110 , 46 , 99 , 111 , 109 , 27 , 0 , 0 , 0 , 0 , 8 , 36 , 46 , 115 , 97 , 108 , 97 , 114 , 121 , 3 , 5 , 110 , 0 , 0 , 6 , 36 , 46 , 114 , 111 , 108 , 101 , 4 , 12 , 2 , 73 , 67 ,
558
558
},
559
559
numRows : 1 ,
560
- want : "JSON_REPLACE(JSON_REPLACE(%s, _utf8mb4'$.salary', 110) , _utf8mb4'$.role', _utf8mb4\" IC \" )" ,
560
+ want : "JSON_REPLACE(JSON_REPLACE(%s, _utf8mb4'$.salary', CAST( 110 as JSON)) , _utf8mb4'$.role', CAST(JSON_QUOTE( _utf8mb4'IC') as JSON) )" ,
561
561
},
562
562
{
563
563
name : "JSON null" ,
@@ -624,7 +624,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
624
624
105 , 110 , 103 , 115 , 34 , 44 , 32 , 34 , 115 , 116 , 97 , 116 , 101 , 34 , 58 , 34 , 77 , 73 , 34 , 125 ,
625
625
},
626
626
numRows : 1 ,
627
- want : "JSON_INSERT(%s, _utf8mb4'$.misc', _utf8mb4\" { \\ \ " address\\ \ " :\\ \ " 1012 S Park\\ \ " , \\ \ " town\\ \ " :\\ \ " Hastings\\ \ " , \\ \ " state\\ \ " :\\ \ " MI\\ \" } \" )" ,
627
+ want : "JSON_INSERT(%s, _utf8mb4'$.misc', CAST(JSON_QUOTE( _utf8mb4'{ \ " address\" :\" 1012 S Park\" , \" town\" :\" Hastings\" , \" state\" :\" MI\" }') as JSON) )" ,
628
628
},
629
629
{
630
630
name : "JSON field not updated" ,
0 commit comments