CastFunctionTest. testFloatCasting and testLongCasting fail on mysql

Activity

Show:

Former user June 26, 2014 at 12:04 AM

Bulk close issues fixed in 4.2.14

Former user June 18, 2014 at 11:18 PM

Tests are skipped when MySQLDialect or subclasses are used.

Pushed to 4.2 only.

Former user June 18, 2014 at 10:53 PM
Edited

This was fixed as part of HHH-8454, which was not backported to 4.2.

This is not a regression. I'll skip these tests for MySQL in 4.2.

Former user June 18, 2014 at 9:43 PM

The failures do not reproduce in 4.3. Here the comparison of SQL generated for 4.2 vs 4.3:

HQL: select cast(e.theLostNumber as float) from org.hibernate.test.hql.CastFunctionTest$MyEntity e
4.2 SQL: select cast(castfuncti0_.theLostNumber as float) as col_0_0_ from MyEntity castfuncti0_
4.3 SQL: select cast(castfuncti0_.theLostNumber as decimal) as col_0_0_ from MyEntity castfuncti0_

HQL: select cast(e.theLostNumber as long) from org.hibernate.test.hql.CastFunctionTest$MyEntity e
4.2 SQL: select cast(castfuncti0_.theLostNumber as bigint) as col_0_0_ from MyEntity castfuncti0_
4.3 SQL: select cast(castfuncti0_.theLostNumber as signed) as col_0_0_ from MyEntity castfuncti0_

In 4.3, the targets are changed to valid types in the generated SQL.

Former user June 18, 2014 at 9:06 PM
Edited

MySQL 5.5 does not support casting to all targets. According to [1], these are the targets that are supported:

CAST(expr AS type)

The CAST() function takes an expression of any type and produces a result value of a specified type, similar to CONVERT(). See the description of CONVERT() for more information.

CONVERT(expr,type), CONVERT(expr USING transcoding_name)

The CONVERT() and CAST() functions take an expression of any type and produce a result value of a specified type.

The type for the result can be one of the following values:

BINARY[(N)]
CHAR[(N)]
DATE
DATETIME
DECIMAL[(M[,D])]
SIGNED [INTEGER]
TIME
UNSIGNED [INTEGER]

[1] https://dev.mysql.com/doc/refman/5.5/en/cast-functions.html#function_convert

Fixed

Assignee

Reporter

Components

Fix versions

Priority

Created June 16, 2014 at 8:25 PM
Updated June 26, 2014 at 12:04 AM
Resolved June 18, 2014 at 11:18 PM
Loading...