Skip to content

Commit 0bb3b48

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 4b73030 commit 0bb3b48

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
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 ) {

hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/MySQLColumnValidationTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ public void releaseResources() {
113113
fail(e.getMessage());
114114
}
115115

116-
if ( connectionProvider != null ) {
117-
connectionProvider.stop();
118-
}
116+
connectionProvider.stop();
119117
}
120118

121119
@Test

0 commit comments

Comments
 (0)