HHH-16823 support for nvarchar on MySQL
In H6 we stopped producing nvarchar columns on MySQL, but it's needed for MySQL 5.7. On the other hand, actually nvarchar is deprecated in MySQL 8. So use 'varchar character set utf8' instead.
This commit is contained in:
parent
c9baeb5c68
commit
fb4f5ba617
|
@ -251,10 +251,18 @@ public class MySQLDialect extends Dialect {
|
||||||
case NUMERIC:
|
case NUMERIC:
|
||||||
// it's just a synonym
|
// it's just a synonym
|
||||||
return columnType( DECIMAL );
|
return columnType( DECIMAL );
|
||||||
|
|
||||||
|
// on MySQL 8, the nchar/nvarchar types use a deprecated character set
|
||||||
|
case NCHAR:
|
||||||
|
return "char($l) character set utf8";
|
||||||
|
case NVARCHAR:
|
||||||
|
return "varchar($l) character set utf8";
|
||||||
|
|
||||||
// the maximum long LOB length is 4_294_967_295, bigger than any Java string
|
// the maximum long LOB length is 4_294_967_295, bigger than any Java string
|
||||||
case BLOB:
|
case BLOB:
|
||||||
return "longblob";
|
return "longblob";
|
||||||
case NCLOB:
|
case NCLOB:
|
||||||
|
return "longtext character set utf8";
|
||||||
case CLOB:
|
case CLOB:
|
||||||
return "longtext";
|
return "longtext";
|
||||||
|
|
||||||
|
@ -338,16 +346,18 @@ public class MySQLDialect extends Dialect {
|
||||||
}
|
}
|
||||||
ddlTypeRegistry.addDescriptor( varcharBuilder.build() );
|
ddlTypeRegistry.addDescriptor( varcharBuilder.build() );
|
||||||
|
|
||||||
|
// do not use nchar/nvarchar/ntext because these
|
||||||
|
// types use a deprecated character set on MySQL 8
|
||||||
final CapacityDependentDdlType.Builder nvarcharBuilder = CapacityDependentDdlType.builder(
|
final CapacityDependentDdlType.Builder nvarcharBuilder = CapacityDependentDdlType.builder(
|
||||||
NVARCHAR,
|
NVARCHAR,
|
||||||
columnType( NCLOB ),
|
columnType( NCLOB ),
|
||||||
"char",
|
"char character set utf8",
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
.withTypeCapacity( getMaxVarcharLength(), "varchar($l)" )
|
.withTypeCapacity( getMaxVarcharLength(), "varchar($l) character set utf8" )
|
||||||
.withTypeCapacity( maxMediumLobLen, "mediumtext" );
|
.withTypeCapacity( maxMediumLobLen, "mediumtext character set utf8" );
|
||||||
if ( getMaxVarcharLength() < maxLobLen ) {
|
if ( getMaxVarcharLength() < maxLobLen ) {
|
||||||
nvarcharBuilder.withTypeCapacity( maxLobLen, "text" );
|
nvarcharBuilder.withTypeCapacity( maxLobLen, "text character set utf8" );
|
||||||
}
|
}
|
||||||
ddlTypeRegistry.addDescriptor( nvarcharBuilder.build() );
|
ddlTypeRegistry.addDescriptor( nvarcharBuilder.build() );
|
||||||
|
|
||||||
|
@ -385,10 +395,10 @@ public class MySQLDialect extends Dialect {
|
||||||
);
|
);
|
||||||
|
|
||||||
ddlTypeRegistry.addDescriptor(
|
ddlTypeRegistry.addDescriptor(
|
||||||
CapacityDependentDdlType.builder( NCLOB, columnType( NCLOB ), "char", this )
|
CapacityDependentDdlType.builder( NCLOB, columnType( NCLOB ), "char character set utf8", this )
|
||||||
.withTypeCapacity( maxTinyLobLen, "tinytext" )
|
.withTypeCapacity( maxTinyLobLen, "tinytext character set utf8" )
|
||||||
.withTypeCapacity( maxMediumLobLen, "mediumtext" )
|
.withTypeCapacity( maxMediumLobLen, "mediumtext character set utf8" )
|
||||||
.withTypeCapacity( maxLobLen, "text" )
|
.withTypeCapacity( maxLobLen, "text character set utf8" )
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue