Skip to content

Commit cbf1739

Browse files
committed
HHH-18368 Fix for Informix function coalesce() error
1 parent 81108ce commit cbf1739

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
@@ -23,6 +23,7 @@
2323
import org.hibernate.dialect.SelectItemReferenceStrategy;
2424
import org.hibernate.dialect.function.CaseLeastGreatestEmulation;
2525
import org.hibernate.dialect.function.CommonFunctionFactory;
26+
import org.hibernate.dialect.function.NvlCoalesceEmulation;
2627
import org.hibernate.dialect.identity.IdentityColumnSupport;
2728
import org.hibernate.dialect.pagination.LimitHandler;
2829
import org.hibernate.dialect.sequence.SequenceSupport;
@@ -281,12 +282,13 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
281282
functionFactory.variance();
282283
functionFactory.bitLength_pattern( "length(?1)*8" );
283284

284-
if ( getVersion().isSameOrAfter( 12 ) ) {
285+
if ( getVersion().isBefore( 12 ) ) {
286+
functionContributions.getFunctionRegistry().register( "coalesce", new NvlCoalesceEmulation() );
287+
}
288+
else {
289+
functionFactory.coalesce(SqlAstNodeRenderingMode.INLINE_ALL_PARAMETERS);
285290
functionFactory.locate_charindex();
286291
}
287-
288-
//coalesce() and nullif() both supported since Informix 12
289-
290292
functionContributions.getFunctionRegistry().register( "least", new CaseLeastGreatestEmulation( true ) );
291293
functionContributions.getFunctionRegistry().register( "greatest", new CaseLeastGreatestEmulation( false ) );
292294
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
@@ -1562,9 +1562,14 @@ public void atan2_atn2() {
15621562
}
15631563

15641564
public void coalesce() {
1565+
coalesce( SqlAstNodeRenderingMode.DEFAULT );
1566+
}
1567+
1568+
public void coalesce( SqlAstNodeRenderingMode inferenceArgumentRenderingMode ) {
15651569
functionRegistry.namedDescriptorBuilder( "coalesce" )
15661570
.setMinArgumentCount( 1 )
15671571
.setArgumentTypeResolver( StandardFunctionArgumentTypeResolvers.ARGUMENT_OR_IMPLIED_RESULT_TYPE )
1572+
.setArgumentRenderingMode( inferenceArgumentRenderingMode )
15681573
.register();
15691574
}
15701575

0 commit comments

Comments
 (0)