Skip to content

Commit

Permalink
Merge pull request #44 from hash-data/fix/mysql_tinyint
Browse files Browse the repository at this point in the history
fix: tinyint(1) and bit are now counted as integer
  • Loading branch information
piyushdatazip authored Mar 19, 2024
2 parents ff508bf + 9f43166 commit e6f2758
Show file tree
Hide file tree
Showing 6 changed files with 654 additions and 673 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ void testDiscover() throws Exception {
.collect(Collectors.toList()));
}

@Test
public void newTableSnapshotTest() throws Exception {
final AutoCloseableIterator<AirbyteMessage> firstBatchIterator = getSource()
.read(getConfig(), CONFIGURED_CATALOG, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,8 @@ public void copyToJsonField(final ResultSet resultSet, final int colIndex, final

// https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-type-conversions.html
switch (columnType) {
case BIT -> {
if (field.getLength() == 1L) {
// BIT(1) is boolean
putBoolean(json, columnName, resultSet, colIndex);
} else {
putBinary(json, columnName, resultSet, colIndex);
}
}
case BOOLEAN -> putBoolean(json, columnName, resultSet, colIndex);
case TINYINT -> {
if (field.getLength() == 1L) {
// TINYINT(1) is boolean
putBoolean(json, columnName, resultSet, colIndex);
} else {
putShortInt(json, columnName, resultSet, colIndex);
}
}
case TINYINT_UNSIGNED, YEAR -> putShortInt(json, columnName, resultSet, colIndex);
case BIT, TINYINT, TINYINT_UNSIGNED, YEAR -> putShortInt(json, columnName, resultSet, colIndex);
case SMALLINT, SMALLINT_UNSIGNED, MEDIUMINT, MEDIUMINT_UNSIGNED -> putInteger(json, columnName, resultSet, colIndex);
case INT, INT_UNSIGNED -> {
if (field.isUnsigned()) {
Expand Down Expand Up @@ -172,7 +156,7 @@ public MysqlType getDatabaseFieldType(final JsonNode field) {
// BIT(1) and TINYINT(1) are interpreted as boolean
case BIT, TINYINT -> {
if (columnSize == 1) {
return MysqlType.BOOLEAN;
return SMALLINT;
}
}
case YEAR -> {
Expand Down
Loading

0 comments on commit e6f2758

Please sign in to comment.