[jOOQ/jOOQ#17135] <unsignedTypes/> flag doesn't work outside of

MySQLDatabase
This commit is contained in:
Lukas Eder 2024-08-27 08:53:08 +02:00
parent 23a0ae44e0
commit fdbeea9977
3 changed files with 12 additions and 11 deletions

View File

@ -48,6 +48,7 @@ import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import org.jooq.Name;
import org.jooq.SQLDialect;
@ -67,6 +68,8 @@ import org.jooq.types.UShort;
*/
public class DefaultDataTypeDefinition implements DataTypeDefinition {
private static final Pattern P_UNSIGNED = Pattern.compile("(?i:\\s*unsigned)");
private final Database database;
private final SchemaDefinition schema;
private final String type;
@ -127,6 +130,10 @@ public class DefaultDataTypeDefinition implements DataTypeDefinition {
this.database = database;
this.schema = schema;
// [#519] [#17135] Some types have unsigned versions
if (!database.supportsUnsignedTypes() && typeName.toLowerCase().endsWith("unsigned"))
typeName = P_UNSIGNED.matcher(typeName).replaceFirst("");
// [#3420] Some databases report NULL as a data type, e.g. Oracle for (some) AQ tables
this.type = typeName == null ? "OTHER" : typeName;
this.userType = userType;

View File

@ -113,12 +113,9 @@ public class MySQLRoutineDefinition extends AbstractRoutineDefinition {
String inOut = record.get(PARAMETERS.PARAMETER_MODE);
String dataType = record.get(PARAMETERS.DATA_TYPE);
// [#519] Some types have unsigned versions
if (getDatabase().supportsUnsignedTypes()) {
if (asList("tinyint", "smallint", "mediumint", "int", "bigint").contains(dataType.toLowerCase())) {
if (record.get(PARAMETERS.DTD_IDENTIFIER).toLowerCase().contains("unsigned")) {
dataType += "unsigned";
}
if (asList("tinyint", "smallint", "mediumint", "int", "bigint").contains(dataType.toLowerCase())) {
if (record.get(PARAMETERS.DTD_IDENTIFIER).toLowerCase().contains("unsigned")) {
dataType += "unsigned";
}
}

View File

@ -113,9 +113,6 @@ public class MySQLTableDefinition extends AbstractTableDefinition {
String dataType = record.get(COLUMNS.DATA_TYPE);
// [#519] Some types have unsigned versions
boolean unsigned = getDatabase().supportsUnsignedTypes();
// [#7719]
boolean displayWidths = getDatabase().integerDisplayWidths();
@ -131,7 +128,7 @@ public class MySQLTableDefinition extends AbstractTableDefinition {
boolean generated = generationOption != null;
columnTypeFix:
if (unsigned || displayWidths) {
if (displayWidths) {
if (asList("tinyint", "smallint", "mediumint", "int", "bigint").contains(dataType.toLowerCase())) {
String columnType = record.get(COLUMNS.COLUMN_TYPE).toLowerCase();
@ -148,7 +145,7 @@ public class MySQLTableDefinition extends AbstractTableDefinition {
String mUnsigned = matcher.group(3);
dataType = mType
+ (unsigned && mUnsigned != null ? mUnsigned : "")
+ (mUnsigned != null ? mUnsigned : "")
+ (displayWidths && mPrecision != null ? mPrecision : "");
}
}