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(), table.getQualifiedTableName(),
columnInformation.getTypeName().toLowerCase(Locale.ROOT), columnInformation.getTypeName().toLowerCase(Locale.ROOT),
JdbcTypeNameMapper.getTypeName( columnInformation.getTypeCode() ), JdbcTypeNameMapper.getTypeName( columnInformation.getTypeCode() ),
column.getSqlType().toLowerCase(Locale.ROOT), column.getSqlType( metadata ).toLowerCase(Locale.ROOT),
JdbcTypeNameMapper.getTypeName( column.getSqlTypeCode( metadata ) ) JdbcTypeNameMapper.getTypeName( column.getSqlTypeCode( metadata ) )
) )
); );

View File

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