diff --git a/go/mysql/binlog/binlog_json.go b/go/mysql/binlog/binlog_json.go index e6b7d09819d..30c80531a96 100644 --- a/go/mysql/binlog/binlog_json.go +++ b/go/mysql/binlog/binlog_json.go @@ -106,7 +106,7 @@ func ParseBinaryJSONDiff(data []byte) (sqltypes.Value, error) { // Can be a JSON null. js, err := ParseBinaryJSON(data) if err == nil && js.Type() == json.TypeNull { - return sqltypes.MakeTrusted(sqltypes.Expression, js.MarshalTo(nil)), nil + return sqltypes.MakeTrusted(sqltypes.Expression, js.MarshalSQLTo(nil)), nil } return sqltypes.Value{}, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "invalid JSON diff operation: %d", opType) @@ -144,8 +144,7 @@ func ParseBinaryJSONDiff(data []byte) (sqltypes.Value, error) { "cannot read JSON diff value for path %q", path) } pos += valueLen - buf := value.MarshalSQLTo(nil) - diff.Write(buf) + diff.Write(value.MarshalSQLTo(nil)) diff.WriteByte(')') } diff --git a/go/vt/vttablet/tabletmanager/vreplication/vplayer_flaky_test.go b/go/vt/vttablet/tabletmanager/vreplication/vplayer_flaky_test.go index 872ba7a59b1..e697f6d2752 100644 --- a/go/vt/vttablet/tabletmanager/vreplication/vplayer_flaky_test.go +++ b/go/vt/vttablet/tabletmanager/vreplication/vplayer_flaky_test.go @@ -1667,13 +1667,13 @@ func TestPlayerPartialImages(t *testing.T) { }, }, { - input: `update src set jd=JSON_SET(jd, '$.idontknow', null) where id = 3`, + input: `update src set jd=JSON_SET(jd, '$.idontknow', null, '$.idontknoweither', 'null') where id = 3`, output: []string{ - "update dst set jd=JSON_INSERT(`jd`, _utf8mb4'$.idontknow', CAST(_utf8mb4'null' as JSON)) where id=3", + "update dst set jd=JSON_INSERT(JSON_INSERT(`jd`, _utf8mb4'$.idontknow', CAST(_utf8mb4'null' as JSON)), _utf8mb4'$.idontknoweither', CAST(JSON_QUOTE(_utf8mb4'null') as JSON)) where id=3", }, data: [][]string{ {"1", "{\"key1\": \"val1\", \"color\": \"red\", \"years\": 5, \"hobbies\": [\"skiing\", \"video games\", \"hiking\"]}", "blob data"}, - {"3", "{\"key3\": \"val3\", \"idontknow\": null}", "blob data3"}, + {"3", "{\"key3\": \"val3\", \"idontknow\": null, \"idontknoweither\": \"null\"}", "blob data3"}, {"12", "{\"key2\": \"val2\", \"misc\": \"{\\\"address\\\":\\\"1012 S Park\\\", \\\"town\\\":\\\"Hastings\\\", \\\"state\\\":\\\"MI\\\"}\", \"current\": true}", "newest blob data"}, }, },