mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 04:08:19 +00:00
HHH-6655 trim function on DB2 is broken
This commit is contained in:
parent
58fa4c2eac
commit
11dcd9ab46
@ -159,7 +159,7 @@ public DB2Dialect() {
|
||||
|
||||
registerFunction( "substring", new StandardSQLFunction( "substr", StandardBasicTypes.STRING ) );
|
||||
registerFunction( "bit_length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "length(?1)*8" ) );
|
||||
registerFunction( "trim", new AnsiTrimEmulationFunction() );
|
||||
registerFunction( "trim", new SQLFunctionTemplate( StandardBasicTypes.STRING, "trim(?1 ?2 ?3 ?4)" ) );
|
||||
|
||||
registerFunction( "concat", new VarArgsSQLFunction( StandardBasicTypes.STRING, "", "||", "" ) );
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
* Models the ANSI SQL <tt>TRIM</tt> function.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
* @author Brett Meyer
|
||||
*/
|
||||
public class TrimFunction
|
||||
extends BasicFunctionExpression<String>
|
||||
@ -118,11 +119,22 @@ public void registerParameters(ParameterRegistry registry) {
|
||||
|
||||
@Override
|
||||
public String render(RenderingContext renderingContext) {
|
||||
String renderedTrimChar;
|
||||
if ( trimCharacter.getClass().isAssignableFrom(
|
||||
LiteralExpression.class ) ) {
|
||||
// If the character is a literal, treat it as one. A few dialects
|
||||
// do not support parameters as trim() arguments.
|
||||
renderedTrimChar = ( ( LiteralExpression<Character> )
|
||||
trimCharacter ).getLiteral().toString();
|
||||
} else {
|
||||
renderedTrimChar = ( (Renderable) trimCharacter ).render(
|
||||
renderingContext );
|
||||
}
|
||||
return new StringBuilder()
|
||||
.append( "trim(" )
|
||||
.append( trimspec.name() )
|
||||
.append( ' ' )
|
||||
.append( ( (Renderable) trimCharacter ).render( renderingContext ) )
|
||||
.append( renderedTrimChar )
|
||||
.append( " from " )
|
||||
.append( ( (Renderable) trimSource ).render( renderingContext ) )
|
||||
.append( ')' )
|
||||
|
@ -92,8 +92,6 @@ public Class[] getAnnotatedClasses() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@RequiresDialect( DB2Dialect.class )
|
||||
@FailureExpected( jiraKey = "HHH-6655" )
|
||||
public void testTrim() {
|
||||
final String expectedResult = "David R. Vincent";
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
|
Loading…
x
Reference in New Issue
Block a user