Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql-source:tinyint-unsigned should not be identified as boolean #18956

Merged
merged 8 commits into from
Nov 14, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ public void setJsonField(final ResultSet resultSet, final int colIndex, final Ob
}
}
case BOOLEAN -> putBoolean(json, columnName, resultSet, colIndex);
case TINYINT, TINYINT_UNSIGNED -> {
case TINYINT -> {
if (field.getLength() == 1L) {
// TINYINT(1) is boolean
putBoolean(json, columnName, resultSet, colIndex);
} else {
putShortInt(json, columnName, resultSet, colIndex);
}
}
case TINYINT_UNSIGNED -> 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 @@ -184,7 +185,7 @@ public MysqlType getFieldType(final JsonNode field) {

switch (literalType) {
// BIT(1) and TINYINT(1) are interpreted as boolean
case BIT, TINYINT, TINYINT_UNSIGNED -> {
case BIT, TINYINT -> {
if (columnSize == 1) {
return MysqlType.BOOLEAN;
}
Expand Down