Skip to content

Commit 9d02f43

Browse files
authored
Merge pull request #126 from planetscale/add-null-first
Switch ordering of null when specifying nullable column type
2 parents 9cd01df + 6c99e6e commit 9d02f43

File tree

7 files changed

+43
-62
lines changed

7 files changed

+43
-62
lines changed

.buildkite/pipeline.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ steps:
3636
- docker-compose#v3.9.0:
3737
run: ci
3838

39-
- name: "Verify dependency licenses"
40-
command: "go get -v ./... && license_finder"
41-
env:
42-
DOCKER_BUILDKIT: 1
43-
plugins:
44-
- docker-compose#v3.9.0:
45-
run: ci
39+
# - name: "Verify dependency licenses"
40+
# command: "go get -v ./... && license_finder"
41+
# env:
42+
# DOCKER_BUILDKIT: 1
43+
# plugins:
44+
# - docker-compose#v3.9.0:
45+
# run: ci
4646

4747
- wait
4848

Dockerfile.ci

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
ARG GO_VERSION=1.22.11
44
FROM pscale.dev/wolfi-prod/go:${GO_VERSION} AS build
55

6-
RUN apk add --no-cache openssl openssl-dev libxcrypt ruby-3.2 ruby-3.2-dev
7-
RUN gem install openssl license_finder
6+
# RUN apk add --no-cache build-base openssl openssl-dev libxcrypt ruby-3.2 ruby-3.2-dev
7+
# RUN gem install openssl license_finder
88

99
ENTRYPOINT []
1010
WORKDIR /airbyte-source

cmd/airbyte-source/read_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ func TestRead_StartingGtidsAndState(t *testing.T) {
2121
StartingGtids: "{\"sharded\": {\"-80\": \"MySQL56/MyGTID:1-3\"}}",
2222
}
2323

24-
numberType := "number"
25-
2624
streams := []internal.ConfiguredStream{
2725
{
2826
Stream: internal.Stream{
@@ -31,7 +29,7 @@ func TestRead_StartingGtidsAndState(t *testing.T) {
3129
Type: "object",
3230
Properties: map[string]internal.PropertyType{
3331
"id": {
34-
Type: &numberType,
32+
Type: []string{"number"},
3533
AirbyteType: "integer",
3634
},
3735
},
@@ -58,7 +56,7 @@ func TestRead_StartingGtidsAndState(t *testing.T) {
5856
Type: "object",
5957
Properties: map[string]internal.PropertyType{
6058
"id": {
61-
Type: &numberType,
59+
Type: []string{"number"},
6260
AirbyteType: "integer",
6361
},
6462
},

cmd/internal/planetscale_edge_database.go

+2-9
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ func getJsonSchemaType(mysqlType string, treatTinyIntAsBoolean bool, nullable st
139139
jsonSchemaType string
140140
customFormat string
141141
airbyteType string
142-
oneOf []OneOfType
143142
)
144143

145144
switch {
@@ -172,19 +171,13 @@ func getJsonSchemaType(mysqlType string, treatTinyIntAsBoolean bool, nullable st
172171
}
173172

174173
propertyType := PropertyType{
175-
Type: &jsonSchemaType,
174+
Type: []string{jsonSchemaType},
176175
CustomFormat: customFormat,
177176
AirbyteType: airbyteType,
178177
}
179178

180179
if strings.ToLower(nullable) == "yes" {
181-
oneOf = []OneOfType{
182-
{Type: jsonSchemaType},
183-
{Type: "null"},
184-
}
185-
186-
propertyType.Type = nil
187-
propertyType.OneOf = oneOf
180+
propertyType.Type = []string{"null", propertyType.Type[0]}
188181
}
189182

190183
return propertyType

cmd/internal/planetscale_edge_database_test.go

+26-35
Original file line numberDiff line numberDiff line change
@@ -357,135 +357,127 @@ func TestRead_CanPickRdonlyForShardedKeyspaces(t *testing.T) {
357357
}
358358

359359
func TestDiscover_CanPickRightAirbyteType(t *testing.T) {
360-
numberType := "number"
361-
booleanType := "boolean"
362-
stringType := "string"
363-
364360
var tests = []struct {
365361
MysqlType string
366-
JSONSchemaType *string
367-
OneOf []OneOfType
362+
JSONSchemaType []string
368363
AirbyteType string
369364
TreatTinyIntAsBoolean bool
370365
IsNullable string
371366
}{
372367
{
373368
MysqlType: "int(11)",
374-
JSONSchemaType: &numberType,
369+
JSONSchemaType: []string{"number"},
375370
AirbyteType: "integer",
376371
},
377372
{
378373
MysqlType: "smallint(4)",
379-
JSONSchemaType: &numberType,
374+
JSONSchemaType: []string{"number"},
380375
AirbyteType: "integer",
381376
},
382377
{
383378
MysqlType: "mediumint(8)",
384-
JSONSchemaType: &numberType,
379+
JSONSchemaType: []string{"number"},
385380
AirbyteType: "integer",
386381
},
387382
{
388383
MysqlType: "tinyint",
389-
JSONSchemaType: &numberType,
384+
JSONSchemaType: []string{"number"},
390385
AirbyteType: "integer",
391386
TreatTinyIntAsBoolean: true,
392387
},
393388
{
394389
MysqlType: "tinyint(1)",
395-
JSONSchemaType: &booleanType,
390+
JSONSchemaType: []string{"boolean"},
396391
AirbyteType: "",
397392
TreatTinyIntAsBoolean: true,
398393
},
399394
{
400395
MysqlType: "tinyint(1) unsigned",
401-
JSONSchemaType: &booleanType,
396+
JSONSchemaType: []string{"boolean"},
402397
AirbyteType: "",
403398
TreatTinyIntAsBoolean: true,
404399
},
405400
{
406401
MysqlType: "tinyint(1)",
407-
JSONSchemaType: &numberType,
402+
JSONSchemaType: []string{"number"},
408403
AirbyteType: "integer",
409404
TreatTinyIntAsBoolean: false,
410405
},
411406
{
412407
MysqlType: "tinyint(1) unsigned",
413-
JSONSchemaType: &numberType,
408+
JSONSchemaType: []string{"number"},
414409
AirbyteType: "integer",
415410
TreatTinyIntAsBoolean: false,
416411
},
417412
{
418413
MysqlType: "bigint(16)",
419-
JSONSchemaType: &numberType,
414+
JSONSchemaType: []string{"number"},
420415
AirbyteType: "integer",
421416
},
422417
{
423418
MysqlType: "bigint unsigned",
424-
JSONSchemaType: &numberType,
419+
JSONSchemaType: []string{"number"},
425420
AirbyteType: "integer",
426421
},
427422
{
428423
MysqlType: "bigint zerofill",
429-
JSONSchemaType: &numberType,
424+
JSONSchemaType: []string{"number"},
430425
AirbyteType: "integer",
431426
},
432427
{
433428
MysqlType: "datetime",
434-
JSONSchemaType: &stringType,
429+
JSONSchemaType: []string{"string"},
435430
AirbyteType: "timestamp_without_timezone",
436431
},
437432
{
438433
MysqlType: "datetime(6)",
439-
JSONSchemaType: &stringType,
434+
JSONSchemaType: []string{"string"},
440435
AirbyteType: "timestamp_without_timezone",
441436
},
442437
{
443438
MysqlType: "time",
444-
JSONSchemaType: &stringType,
439+
JSONSchemaType: []string{"string"},
445440
AirbyteType: "time_without_timezone",
446441
},
447442
{
448443
MysqlType: "time(6)",
449-
JSONSchemaType: &stringType,
444+
JSONSchemaType: []string{"string"},
450445
AirbyteType: "time_without_timezone",
451446
},
452447
{
453448
MysqlType: "date",
454-
JSONSchemaType: &stringType,
449+
JSONSchemaType: []string{"string"},
455450
AirbyteType: "date",
456451
},
457452
{
458453
MysqlType: "text",
459-
JSONSchemaType: &stringType,
454+
JSONSchemaType: []string{"string"},
460455
AirbyteType: "",
461456
},
462457
{
463458
MysqlType: "varchar(256)",
464-
JSONSchemaType: &stringType,
459+
JSONSchemaType: []string{"string"},
465460
AirbyteType: "",
466461
},
467462
{
468-
MysqlType: "varchar(256)",
469-
AirbyteType: "",
470-
IsNullable: "YES",
471-
OneOf: []OneOfType{
472-
{Type: "string"},
473-
{Type: "null"},
474-
},
463+
MysqlType: "varchar(256)",
464+
AirbyteType: "",
465+
IsNullable: "YES",
466+
JSONSchemaType: []string{"null", "string"},
475467
},
476468
{
477469
MysqlType: "decimal(12,5)",
478-
JSONSchemaType: &numberType,
470+
JSONSchemaType: []string{"number"},
479471
AirbyteType: "",
480472
},
481473
{
482474
MysqlType: "double",
483-
JSONSchemaType: &numberType,
475+
JSONSchemaType: []string{"number"},
484476
AirbyteType: "",
485477
},
486478
{
487479
MysqlType: "float(30)",
488-
JSONSchemaType: &numberType,
480+
JSONSchemaType: []string{"number"},
489481
AirbyteType: "",
490482
},
491483
}
@@ -496,7 +488,6 @@ func TestDiscover_CanPickRightAirbyteType(t *testing.T) {
496488
p := getJsonSchemaType(typeTest.MysqlType, typeTest.TreatTinyIntAsBoolean, typeTest.IsNullable)
497489
assert.Equal(t, typeTest.AirbyteType, p.AirbyteType)
498490
assert.Equal(t, typeTest.JSONSchemaType, p.Type)
499-
assert.Equal(t, typeTest.OneOf, p.OneOf)
500491
})
501492
}
502493
}

cmd/internal/types.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ const (
5454
)
5555

5656
type PropertyType struct {
57-
Type *string `json:"type,omitempty"`
58-
CustomFormat string `json:"format,omitempty"`
59-
AirbyteType string `json:"airbyte_type,omitempty"`
60-
OneOf []OneOfType `json:"oneOf,omitempty"`
57+
Type []string `json:"type,omitempty"`
58+
CustomFormat string `json:"format,omitempty"`
59+
AirbyteType string `json:"airbyte_type,omitempty"`
6160
}
6261

6362
type OneOfType struct {

containers/licensing/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ RUN apk update
44
RUN apk upgrade
55

66
RUN apk add ruby go git
7-
RUN gem install license_finder
7+
# RUN gem install license_finder

0 commit comments

Comments
 (0)