HHH-18783 Removed @SkipForDialect from test case

Method getSqlType for java.lang.Character without length should return "char(1)", not "char"
This commit is contained in:
Čedomir Igaly 2024-11-03 16:06:02 +01:00 committed by Gavin King
parent c0a14334d1
commit 4fbade6076
2 changed files with 13 additions and 8 deletions

View File

@ -4,10 +4,6 @@
*/ */
package org.hibernate.dialect; package org.hibernate.dialect;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.hibernate.engine.jdbc.Size; import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.collections.Stack; import org.hibernate.internal.util.collections.Stack;
@ -41,6 +37,10 @@ import org.hibernate.sql.exec.internal.JdbcOperationQueryInsertImpl;
import org.hibernate.sql.exec.spi.JdbcOperation; import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.sql.exec.spi.JdbcOperationQueryInsert; import org.hibernate.sql.exec.spi.JdbcOperationQueryInsert;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/** /**
* A SQL AST translator for MySQL. * A SQL AST translator for MySQL.
* *
@ -81,9 +81,15 @@ public class MySQLSqlAstTranslator<T extends JdbcOperation> extends AbstractSqlA
case "varchar": case "varchar":
case "nchar": case "nchar":
case "nvarchar": case "nvarchar":
return castTarget.getLength() == null if ( castTarget.getLength() == null ) {
? "char" if ( castTarget.getJdbcMapping().getJdbcJavaType().getJavaType() == Character.class ) {
: ( "char(" + castTarget.getLength() + ")" ); return "char(1)";
}
else {
return "char";
}
}
return "char(" + castTarget.getLength() + ")";
case "binary": case "binary":
case "varbinary": case "varbinary":
return castTarget.getLength() == null return castTarget.getLength() == null

View File

@ -1131,7 +1131,6 @@ public class FunctionTests {
@Test @Test
@SkipForDialect( dialectClass = AltibaseDialect.class, reason = "Altibase cast to char does not do truncatation") @SkipForDialect( dialectClass = AltibaseDialect.class, reason = "Altibase cast to char does not do truncatation")
@SkipForDialect( dialectClass = MySQLDialect.class, matchSubTypes = true, reason = "MySQL cast does not do truncatation")
public void testCastFunctionWithLength(SessionFactoryScope scope) { public void testCastFunctionWithLength(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
session -> { session -> {