Skip to content

Commit ba9a360

Browse files
committed
HHH-18368 Fix for Informix function coalesce() error
1 parent 0ceef38 commit ba9a360

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
@@ -25,6 +25,7 @@
2525
import org.hibernate.dialect.SelectItemReferenceStrategy;
2626
import org.hibernate.dialect.function.CaseLeastGreatestEmulation;
2727
import org.hibernate.dialect.function.CommonFunctionFactory;
28+
import org.hibernate.dialect.function.NvlCoalesceEmulation;
2829
import org.hibernate.dialect.identity.IdentityColumnSupport;
2930
import org.hibernate.dialect.pagination.LimitHandler;
3031
import org.hibernate.dialect.sequence.SequenceSupport;
@@ -285,12 +286,13 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
285286
functionFactory.variance();
286287
functionFactory.bitLength_pattern( "length(?1)*8" );
287288

288-
if ( getVersion().isSameOrAfter( 12 ) ) {
289+
if ( getVersion().isBefore( 12 ) ) {
290+
functionContributions.getFunctionRegistry().register( "coalesce", new NvlCoalesceEmulation() );
291+
}
292+
else {
293+
functionFactory.coalesce(SqlAstNodeRenderingMode.INLINE_ALL_PARAMETERS);
289294
functionFactory.locate_charindex();
290295
}
291-
292-
//coalesce() and nullif() both supported since Informix 12
293-
294296
functionContributions.getFunctionRegistry().register( "least", new CaseLeastGreatestEmulation( true ) );
295297
functionContributions.getFunctionRegistry().register( "greatest", new CaseLeastGreatestEmulation( false ) );
296298
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)