Skip to content

Commit 0393520

Browse files
committed
HHH-18368 Fix for Informix function coalesce() error
1 parent 30b3c89 commit 0393520

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InformixDialect.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.hibernate.dialect.VarcharUUIDJdbcType;
3030
import org.hibernate.dialect.function.CaseLeastGreatestEmulation;
3131
import org.hibernate.dialect.function.CommonFunctionFactory;
32+
import org.hibernate.dialect.function.NvlCoalesceEmulation;
3233
import org.hibernate.dialect.identity.IdentityColumnSupport;
3334
import org.hibernate.dialect.pagination.LimitHandler;
3435
import org.hibernate.dialect.sequence.SequenceSupport;
@@ -336,12 +337,13 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
336337
functionFactory.variance();
337338
functionFactory.bitLength_pattern( "length(?1)*8" );
338339

339-
if ( getVersion().isSameOrAfter( 12 ) ) {
340+
if ( getVersion().isBefore( 12 ) ) {
341+
functionContributions.getFunctionRegistry().register( "coalesce", new NvlCoalesceEmulation() );
342+
}
343+
else {
344+
functionFactory.coalesce(SqlAstNodeRenderingMode.INLINE_ALL_PARAMETERS);
340345
functionFactory.locate_charindex();
341346
}
342-
343-
//coalesce() and nullif() both supported since Informix 12
344-
345347
functionContributions.getFunctionRegistry().register( "least", new CaseLeastGreatestEmulation( true ) );
346348
functionContributions.getFunctionRegistry().register( "greatest", new CaseLeastGreatestEmulation( false ) );
347349
if ( supportsWindowFunctions() ) {

hibernate-core/src/main/java/org/hibernate/dialect/function/CommonFunctionFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,9 +1566,14 @@ public void atan2_atn2() {
15661566
}
15671567

15681568
public void coalesce() {
1569+
coalesce( SqlAstNodeRenderingMode.DEFAULT );
1570+
}
1571+
1572+
public void coalesce( SqlAstNodeRenderingMode inferenceArgumentRenderingMode ) {
15691573
functionRegistry.namedDescriptorBuilder( "coalesce" )
15701574
.setMinArgumentCount( 1 )
15711575
.setArgumentTypeResolver( StandardFunctionArgumentTypeResolvers.ARGUMENT_OR_IMPLIED_RESULT_TYPE )
1576+
.setArgumentRenderingMode( inferenceArgumentRenderingMode )
15721577
.register();
15731578
}
15741579

0 commit comments

Comments
 (0)