Skip to content

Commit 1e742d3

Browse files
committed
HHH-16578 - Make the column type comparison in ColumnDefinitions somewhat more flexible
Signed-off-by: Jan Schatteman <jschatte@redhat.com>
1 parent eaf7533 commit 1e742d3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/ColumnDefinitions.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ColumnDefinitions {
2525

2626
static boolean hasMatchingType(Column column, ColumnInformation columnInformation, Metadata metadata, Dialect dialect) {
2727
boolean typesMatch = dialect.equivalentTypes( column.getSqlTypeCode(metadata), columnInformation.getTypeCode() )
28-
|| stripArgs( column.getSqlType( metadata ) ).equalsIgnoreCase( columnInformation.getTypeName() );
28+
|| hasSameColumnType( stripArgs( column.getSqlType( metadata ) ), columnInformation.getTypeName() );
2929
if ( typesMatch ) {
3030
return true;
3131
}
@@ -43,6 +43,21 @@ static boolean hasMatchingType(Column column, ColumnInformation columnInformatio
4343
}
4444
}
4545

46+
private static boolean hasSameColumnType(String metadataColumnTypeString, String columnInformationColumnTypeString) {
47+
/*
48+
tokenize the metadata column type string, since that could include more than just the type information, such as e.g. 'unsigned',
49+
and we can't just check if it contains the other one, since that would fail with e.g. tinyint and int
50+
the column information type string, as per InformationExtractorJdbcDatabaseMetaDataImpl.addColumns (L160) should already
51+
only contain a single string
52+
*/
53+
for (String s : metadataColumnTypeString.split( " " ) ) {
54+
if ( s.equalsIgnoreCase( columnInformationColumnTypeString ) ) {
55+
return true;
56+
}
57+
}
58+
return false;
59+
}
60+
4661
static boolean hasMatchingLength(Column column, ColumnInformation columnInformation, Metadata metadata, Dialect dialect) {
4762
final int actualSize = columnInformation.getColumnSize();
4863
if ( actualSize == 0 ) {

0 commit comments

Comments
 (0)