Skip to content

Commit 79d3f08

Browse files
committed
Update unit test for SQL conversion
Signed-off-by: Matt Lord <mattalord@gmail.com>
1 parent 7dc29b3 commit 79d3f08

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

go/mysql/binlog_event_mysql56_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
352352
97, 110, 97, 103, 101, 114,
353353
},
354354
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))",
356356
},
357357
{
358358
// The mysqlbinlog -vvv --base64-output=decode-rows output for the following event:
@@ -373,7 +373,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
373373
},
374374
name: "REPLACE",
375375
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))",
377377
},
378378
{
379379
name: "REMOVE",
@@ -486,7 +486,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
486486
100, 97, 121, 2, 16, 36, 46, 102, 97, 118, 111, 114, 105, 116, 101, 95, 99, 111, 108, 111, 114,
487487
},
488488
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')",
490490
},
491491
{
492492
name: "INSERT and REMOVE and REPLACE",
@@ -514,7 +514,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
514514
1, 7, 36, 46, 104, 111, 98, 98, 121, 8, 12, 6, 115, 107, 105, 105, 110, 103,
515515
},
516516
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))",
518518
},
519519
{
520520
name: "REPLACE with null",
@@ -535,7 +535,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
535535
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,
536536
},
537537
numRows: 1,
538-
want: "JSON_REPLACE(%s, _utf8mb4'$.salary', null)",
538+
want: "JSON_REPLACE(%s, _utf8mb4'$.salary', CAST(_utf8mb4'null' as JSON))",
539539
},
540540
{
541541
name: "REPLACE 2 paths",
@@ -557,7 +557,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
557557
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,
558558
},
559559
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))",
561561
},
562562
{
563563
name: "JSON null",
@@ -624,7 +624,7 @@ func TestMySQL56PartialUpdateRowsEvent(t *testing.T) {
624624
105, 110, 103, 115, 34, 44, 32, 34, 115, 116, 97, 116, 101, 34, 58, 34, 77, 73, 34, 125,
625625
},
626626
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))",
628628
},
629629
{
630630
name: "JSON field not updated",

0 commit comments

Comments
 (0)