@@ -359,126 +359,133 @@ func TestRead_CanPickRdonlyForShardedKeyspaces(t *testing.T) {
359
359
func TestDiscover_CanPickRightAirbyteType (t * testing.T ) {
360
360
var tests = []struct {
361
361
MysqlType string
362
- JSONSchemaType string
362
+ JSONSchemaType [] string
363
363
AirbyteType string
364
364
TreatTinyIntAsBoolean bool
365
+ IsNullable string
365
366
}{
366
367
{
367
368
MysqlType : "int(11)" ,
368
- JSONSchemaType : "number" ,
369
+ JSONSchemaType : [] string { "number" } ,
369
370
AirbyteType : "integer" ,
370
371
},
371
372
{
372
373
MysqlType : "smallint(4)" ,
373
- JSONSchemaType : "number" ,
374
+ JSONSchemaType : [] string { "number" } ,
374
375
AirbyteType : "integer" ,
375
376
},
376
377
{
377
378
MysqlType : "mediumint(8)" ,
378
- JSONSchemaType : "number" ,
379
+ JSONSchemaType : [] string { "number" } ,
379
380
AirbyteType : "integer" ,
380
381
},
381
382
{
382
383
MysqlType : "tinyint" ,
383
- JSONSchemaType : "number" ,
384
+ JSONSchemaType : [] string { "number" } ,
384
385
AirbyteType : "integer" ,
385
386
TreatTinyIntAsBoolean : true ,
386
387
},
387
388
{
388
389
MysqlType : "tinyint(1)" ,
389
- JSONSchemaType : "boolean" ,
390
+ JSONSchemaType : [] string { "boolean" } ,
390
391
AirbyteType : "" ,
391
392
TreatTinyIntAsBoolean : true ,
392
393
},
393
394
{
394
395
MysqlType : "tinyint(1) unsigned" ,
395
- JSONSchemaType : "boolean" ,
396
+ JSONSchemaType : [] string { "boolean" } ,
396
397
AirbyteType : "" ,
397
398
TreatTinyIntAsBoolean : true ,
398
399
},
399
400
{
400
401
MysqlType : "tinyint(1)" ,
401
- JSONSchemaType : "number" ,
402
+ JSONSchemaType : [] string { "number" } ,
402
403
AirbyteType : "integer" ,
403
404
TreatTinyIntAsBoolean : false ,
404
405
},
405
406
{
406
407
MysqlType : "tinyint(1) unsigned" ,
407
- JSONSchemaType : "number" ,
408
+ JSONSchemaType : [] string { "number" } ,
408
409
AirbyteType : "integer" ,
409
410
TreatTinyIntAsBoolean : false ,
410
411
},
411
412
{
412
413
MysqlType : "bigint(16)" ,
413
- JSONSchemaType : "number" ,
414
+ JSONSchemaType : [] string { "number" } ,
414
415
AirbyteType : "integer" ,
415
416
},
416
417
{
417
418
MysqlType : "bigint unsigned" ,
418
- JSONSchemaType : "number" ,
419
+ JSONSchemaType : [] string { "number" } ,
419
420
AirbyteType : "integer" ,
420
421
},
421
422
{
422
423
MysqlType : "bigint zerofill" ,
423
- JSONSchemaType : "number" ,
424
+ JSONSchemaType : [] string { "number" } ,
424
425
AirbyteType : "integer" ,
425
426
},
426
427
{
427
428
MysqlType : "datetime" ,
428
- JSONSchemaType : "string" ,
429
+ JSONSchemaType : [] string { "string" } ,
429
430
AirbyteType : "timestamp_without_timezone" ,
430
431
},
431
432
{
432
433
MysqlType : "datetime(6)" ,
433
- JSONSchemaType : "string" ,
434
+ JSONSchemaType : [] string { "string" } ,
434
435
AirbyteType : "timestamp_without_timezone" ,
435
436
},
436
437
{
437
438
MysqlType : "time" ,
438
- JSONSchemaType : "string" ,
439
+ JSONSchemaType : [] string { "string" } ,
439
440
AirbyteType : "time_without_timezone" ,
440
441
},
441
442
{
442
443
MysqlType : "time(6)" ,
443
- JSONSchemaType : "string" ,
444
+ JSONSchemaType : [] string { "string" } ,
444
445
AirbyteType : "time_without_timezone" ,
445
446
},
446
447
{
447
448
MysqlType : "date" ,
448
- JSONSchemaType : "string" ,
449
+ JSONSchemaType : [] string { "string" } ,
449
450
AirbyteType : "date" ,
450
451
},
451
452
{
452
453
MysqlType : "text" ,
453
- JSONSchemaType : "string" ,
454
+ JSONSchemaType : [] string { "string" } ,
454
455
AirbyteType : "" ,
455
456
},
456
457
{
457
458
MysqlType : "varchar(256)" ,
458
- JSONSchemaType : "string" ,
459
+ JSONSchemaType : [] string { "string" } ,
459
460
AirbyteType : "" ,
460
461
},
462
+ {
463
+ MysqlType : "varchar(256)" ,
464
+ JSONSchemaType : []string {"string" , "null" },
465
+ AirbyteType : "" ,
466
+ IsNullable : "YES" ,
467
+ },
461
468
{
462
469
MysqlType : "decimal(12,5)" ,
463
- JSONSchemaType : "number" ,
470
+ JSONSchemaType : [] string { "number" } ,
464
471
AirbyteType : "" ,
465
472
},
466
473
{
467
474
MysqlType : "double" ,
468
- JSONSchemaType : "number" ,
475
+ JSONSchemaType : [] string { "number" } ,
469
476
AirbyteType : "" ,
470
477
},
471
478
{
472
479
MysqlType : "float(30)" ,
473
- JSONSchemaType : "number" ,
480
+ JSONSchemaType : [] string { "number" } ,
474
481
AirbyteType : "" ,
475
482
},
476
483
}
477
484
478
485
for _ , typeTest := range tests {
479
486
480
487
t .Run (fmt .Sprintf ("mysql_type_%v" , typeTest .MysqlType ), func (t * testing.T ) {
481
- p := getJsonSchemaType (typeTest .MysqlType , typeTest .TreatTinyIntAsBoolean )
488
+ p := getJsonSchemaType (typeTest .MysqlType , typeTest .TreatTinyIntAsBoolean , typeTest . IsNullable )
482
489
assert .Equal (t , typeTest .AirbyteType , p .AirbyteType )
483
490
assert .Equal (t , typeTest .JSONSchemaType , p .Type )
484
491
})
0 commit comments