Skip to content

Commit

Permalink
Merge pull request #84 from planetscale/bigint-tinyint-changes
Browse files Browse the repository at this point in the history
Support `tinyint(1) unsigned` for `boolean` conversion
  • Loading branch information
Phani Raj authored Oct 17, 2023
2 parents 714ac3f + 004b34a commit d23b75a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/internal/planetscale_edge_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func getJsonSchemaType(mysqlType string, treatTinyIntAsBoolean bool) PropertyTyp
return PropertyType{Type: "string", CustomFormat: "date-time", AirbyteType: "timestamp_without_timezone"}
}

if mysqlType == "tinyint(1)" {
if strings.HasPrefix(mysqlType, "tinyint(1)") {
if treatTinyIntAsBoolean {
return PropertyType{Type: "boolean"}
}
Expand Down
12 changes: 12 additions & 0 deletions cmd/internal/planetscale_edge_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,24 @@ func TestDiscover_CanPickRightAirbyteType(t *testing.T) {
AirbyteType: "",
TreatTinyIntAsBoolean: true,
},
{
MysqlType: "tinyint(1) unsigned",
JSONSchemaType: "boolean",
AirbyteType: "",
TreatTinyIntAsBoolean: true,
},
{
MysqlType: "tinyint(1)",
JSONSchemaType: "integer",
AirbyteType: "",
TreatTinyIntAsBoolean: false,
},
{
MysqlType: "tinyint(1) unsigned",
JSONSchemaType: "integer",
AirbyteType: "",
TreatTinyIntAsBoolean: false,
},
{
MysqlType: "bigint(16)",
JSONSchemaType: "string",
Expand Down

0 comments on commit d23b75a

Please sign in to comment.