HHH-16498 Use specialized type declaration for schema validation if available

This commit is contained in:
Christian Beikov 2023-05-31 19:15:19 +02:00
parent 49c151f55d
commit 3e56e0c6af
2 changed files with 11 additions and 4 deletions

View File

@ -169,7 +169,7 @@ public abstract class AbstractSchemaValidator implements SchemaValidator {
table.getQualifiedTableName(),
columnInformation.getTypeName().toLowerCase(Locale.ROOT),
JdbcTypeNameMapper.getTypeName( columnInformation.getTypeCode() ),
column.getSqlType().toLowerCase(Locale.ROOT),
column.getSqlType( metadata ).toLowerCase(Locale.ROOT),
JdbcTypeNameMapper.getTypeName( column.getSqlTypeCode( metadata ) )
)
);

View File

@ -25,7 +25,7 @@ class ColumnDefinitions {
static boolean hasMatchingType(Column column, ColumnInformation columnInformation, Metadata metadata, Dialect dialect) {
boolean typesMatch = dialect.equivalentTypes( column.getSqlTypeCode(metadata), columnInformation.getTypeCode() )
|| stripArgs( column.getSqlType( metadata ) ).equalsIgnoreCase( columnInformation.getTypeName() );
|| stripArgs( getSqlType( column, metadata ) ).equalsIgnoreCase( columnInformation.getTypeName() );
if ( typesMatch ) {
return true;
}
@ -43,6 +43,13 @@ class ColumnDefinitions {
}
}
private static String getSqlType(Column column, Metadata metadata) {
if ( column.hasSpecializedTypeDeclaration() ) {
return column.getSpecializedTypeDeclaration();
}
return column.getSqlType( metadata );
}
static boolean hasMatchingLength(Column column, ColumnInformation columnInformation, Metadata metadata, Dialect dialect) {
final int actualSize = columnInformation.getColumnSize();
if ( actualSize == 0 ) {
@ -217,7 +224,7 @@ class ColumnDefinitions {
}
private static String stripArgs(String string) {
int i = string.indexOf('(');
return i>0 ? string.substring(0,i) : string;
int i = string.indexOf( '(' );
return i > 0 ? string.substring( 0, i ).trim() : string;
}
}