20
20
import org .hibernate .type .descriptor .jdbc .JdbcType ;
21
21
22
22
import java .util .List ;
23
+ import java .util .Locale ;
23
24
24
25
import static org .hibernate .type .SqlTypes .isNumericOrDecimal ;
25
26
import static org .hibernate .type .SqlTypes .isStringType ;
@@ -28,7 +29,7 @@ class ColumnDefinitions {
28
29
29
30
static boolean hasMatchingType (Column column , ColumnInformation columnInformation , Metadata metadata , Dialect dialect ) {
30
31
boolean typesMatch = dialect .equivalentTypes ( column .getSqlTypeCode (metadata ), columnInformation .getTypeCode () )
31
- || stripArgs ( getSqlType ( column , metadata ) ). equalsIgnoreCase ( columnInformation .getTypeName () );
32
+ || normalize ( stripArgs ( getSqlType ( column , metadata ) ) ). equals ( normalize ( columnInformation .getTypeName () ) );
32
33
if ( typesMatch ) {
33
34
return true ;
34
35
}
@@ -239,8 +240,32 @@ private static boolean isPrimaryKeyIdentity(Table table, Metadata metadata, Dial
239
240
);
240
241
}
241
242
242
- private static String stripArgs (String string ) {
243
- int i = string .indexOf ( '(' );
244
- return i > 0 ? string .substring ( 0 , i ).trim () : string ;
243
+ private static String normalize (String typeName ) {
244
+ if ( typeName == null ) {
245
+ return null ;
246
+ }
247
+ else {
248
+ final String lowerCaseTypName = typeName .toLowerCase (Locale .ROOT );
249
+ switch (lowerCaseTypName ) {
250
+ case "character" :
251
+ return "char" ;
252
+ case "character varying" :
253
+ return "varchar" ;
254
+ case "binary varying" :
255
+ return "varbinary" ;
256
+ default :
257
+ return lowerCaseTypName ;
258
+ }
259
+ }
260
+ }
261
+
262
+ private static String stripArgs (String typeExpression ) {
263
+ if ( typeExpression == null ) {
264
+ return null ;
265
+ }
266
+ else {
267
+ int i = typeExpression .indexOf ( '(' );
268
+ return i > 0 ? typeExpression .substring ( 0 , i ).trim () : typeExpression ;
269
+ }
245
270
}
246
271
}
0 commit comments