@@ -295,18 +295,28 @@ func (s ClickHouseSuite) Test_MySQL_JSON_SnapshotCDCConsistency() {
295295 js json NOT NULL
296296 )` , srcFullName )))
297297
298- variants := []string {
299- `{"z": 1, "aa": 2}` , // key order: shorter key sorts after longer one
300- `{"b": 2, "a": 1}` , // key order: reversed on storage
301- `{"n": [3, 1, 2], "obj": {"y": 1, "x": 2}}` , // nested object key order + array order preserved
302- `{"s": "a, b: c"}` , // whitespace inside strings is preserved
303- `{"pi": 3.14, "half": 0.5, "neg": -2.5}` , // non-whole doubles that render identically in both paths
298+ variants := []struct {
299+ val string
300+ expectExact string
301+ }{
302+ {val : `{"z": 1, "aa": 2}` }, // key order: shorter key sorts after longer one
303+ {val : `{"b": 2, "a": 1}` }, // key order: reversed on storage
304+ {val : `{"n": [3, 1, 2], "obj": {"y": 1, "x": 2}}` }, // nested object key order + array order preserved
305+ {val : `{"s": "a, b: c"}` }, // whitespace inside strings is preserved
306+ {val : `{"pi": 3.14, "half": 0.5, "neg": -2.5}` }, // non-whole doubles that render identically in both paths
307+ {val : `{"big": 1234567890123456789}` , expectExact : `{"big":1234567890123456789}` }, // 19-digit int64: float64 rounds to ...6800
308+ {val : `{"maxsafe": 9007199254740993}` , expectExact : `{"maxsafe":9007199254740993}` }, // 2^53+1: float64 drops the low bit (...992)
309+ {val : `{"negbig": -1234567890123456789}` , expectExact : `{"negbig":-1234567890123456789}` }, // sign preserved at full precision
310+ {
311+ val : `{"mix": [1234567890123456789, -9007199254740993, 9007199254740993]}` , // same hazards inside an array
312+ expectExact : `{"mix":[1234567890123456789,-9007199254740993,9007199254740993]}` ,
313+ },
304314 }
305315
306316 insertVariants := func () {
307317 for _ , v := range variants {
308318 require .NoError (s .t , s .source .Exec (s .t .Context (),
309- fmt .Sprintf (`INSERT INTO %s (js) VALUES ('%s')` , srcFullName , v )))
319+ fmt .Sprintf (`INSERT INTO %s (js) VALUES ('%s')` , srcFullName , v . val )))
310320 }
311321 }
312322
@@ -340,7 +350,11 @@ func (s ClickHouseSuite) Test_MySQL_JSON_SnapshotCDCConsistency() {
340350 for i := range variants {
341351 snapshotGot := fmt .Sprint (rows .Records [i ][1 ].Value ())
342352 cdcGot := fmt .Sprint (rows .Records [i + len (variants )][1 ].Value ())
343- require .Equal (s .t , snapshotGot , cdcGot , "snapshot/cdc JSON representation differs for %q" , variants [i ])
353+ require .Equal (s .t , snapshotGot , cdcGot , "snapshot/cdc JSON representation differs for %q" , variants [i ].val )
354+ if variants [i ].expectExact != "" {
355+ require .Equal (s .t , variants [i ].expectExact , snapshotGot , "snapshot JSON not preserved faithfully for %q" , variants [i ].val )
356+ require .Equal (s .t , variants [i ].expectExact , cdcGot , "cdc JSON not preserved faithfully for %q" , variants [i ].val )
357+ }
344358 }
345359
346360 env .Cancel (s .t .Context ())
0 commit comments