Skip to content

Commit

Permalink
Merge pull request #90 from planetscale/fix-tinyint-schema
Browse files Browse the repository at this point in the history
fix tinyint schema detection
  • Loading branch information
Phani Raj authored Nov 7, 2023
2 parents 8017ce1 + da2703a commit 5baac4f
Show file tree
Hide file tree
Showing 2 changed files with 7 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 @@ -134,7 +134,7 @@ func getJsonSchemaType(mysqlType string, treatTinyIntAsBoolean bool) PropertyTyp
return PropertyType{Type: "boolean"}
}
return PropertyType{Type: "number", AirbyteType: "integer"}
case strings.HasPrefix(mysqlType, "int"), strings.HasPrefix(mysqlType, "smallint"), strings.HasPrefix(mysqlType, "mediumint"), strings.HasPrefix(mysqlType, "bigint"):
case strings.HasPrefix(mysqlType, "int"), strings.HasPrefix(mysqlType, "smallint"), strings.HasPrefix(mysqlType, "mediumint"), strings.HasPrefix(mysqlType, "bigint"), strings.HasPrefix(mysqlType, "tinyint"):
return PropertyType{Type: "number", AirbyteType: "integer"}
case strings.HasPrefix(mysqlType, "decimal"), strings.HasPrefix(mysqlType, "double"), strings.HasPrefix(mysqlType, "float"):
return PropertyType{Type: "number"}
Expand Down
6 changes: 6 additions & 0 deletions cmd/internal/planetscale_edge_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ func TestDiscover_CanPickRightAirbyteType(t *testing.T) {
JSONSchemaType: "number",
AirbyteType: "integer",
},
{
MysqlType: "tinyint",
JSONSchemaType: "number",
AirbyteType: "integer",
TreatTinyIntAsBoolean: true,
},
{
MysqlType: "tinyint(1)",
JSONSchemaType: "boolean",
Expand Down

0 comments on commit 5baac4f

Please sign in to comment.