Skip to content

Commit 4fbade6

Browse files
cigalygavinking
authored andcommitted
HHH-18783 Removed @SkipForDialect from test case
Method getSqlType for java.lang.Character without length should return "char(1)", not "char"
1 parent c0a1433 commit 4fbade6

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/MySQLSqlAstTranslator.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
*/
55
package org.hibernate.dialect;
66

7-
import java.util.ArrayList;
8-
import java.util.List;
9-
import java.util.Locale;
10-
117
import org.hibernate.engine.jdbc.Size;
128
import org.hibernate.engine.spi.SessionFactoryImplementor;
139
import org.hibernate.internal.util.collections.Stack;
@@ -41,6 +37,10 @@
4137
import org.hibernate.sql.exec.spi.JdbcOperation;
4238
import org.hibernate.sql.exec.spi.JdbcOperationQueryInsert;
4339

40+
import java.util.ArrayList;
41+
import java.util.List;
42+
import java.util.Locale;
43+
4444
/**
4545
* A SQL AST translator for MySQL.
4646
*
@@ -81,9 +81,15 @@ private static String getSqlType(CastTarget castTarget, String sqlType, Dialect
8181
case "varchar":
8282
case "nchar":
8383
case "nvarchar":
84-
return castTarget.getLength() == null
85-
? "char"
86-
: ( "char(" + castTarget.getLength() + ")" );
84+
if ( castTarget.getLength() == null ) {
85+
if ( castTarget.getJdbcMapping().getJdbcJavaType().getJavaType() == Character.class ) {
86+
return "char(1)";
87+
}
88+
else {
89+
return "char";
90+
}
91+
}
92+
return "char(" + castTarget.getLength() + ")";
8793
case "binary":
8894
case "varbinary":
8995
return castTarget.getLength() == null

hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,6 @@ public void testCastFunctionHexToBinary(SessionFactoryScope scope) {
11311131

11321132
@Test
11331133
@SkipForDialect( dialectClass = AltibaseDialect.class, reason = "Altibase cast to char does not do truncatation")
1134-
@SkipForDialect( dialectClass = MySQLDialect.class, matchSubTypes = true, reason = "MySQL cast does not do truncatation")
11351134
public void testCastFunctionWithLength(SessionFactoryScope scope) {
11361135
scope.inTransaction(
11371136
session -> {

0 commit comments

Comments
 (0)