HHH-14080 fix Dialect-Aware Rendering of Null Value Literals for InformixDialect

This commit is contained in:
Vladimír Kuruc 2024-03-22 22:49:57 +01:00 committed by Christian Beikov
parent 76ca5fb790
commit 9e8fe5ca07
3 changed files with 21 additions and 1 deletions

View File

@ -59,6 +59,7 @@ import org.hibernate.sql.exec.spi.JdbcOperation;
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
import org.hibernate.type.descriptor.sql.internal.CapacityDependentDdlType;
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
import org.hibernate.type.spi.TypeConfiguration;
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
import static org.hibernate.type.SqlTypes.BIGINT;
@ -594,4 +595,10 @@ public class InformixDialect extends Dialect {
.replace("S", "%F1");
}
@Override
public String getSelectClauseNullString(int sqlType, TypeConfiguration typeConfiguration) {
String typeName = typeConfiguration.getDdlTypeRegistry().getDescriptor( sqlType).getRawTypeName();
return "null::" + typeName;
}
}

View File

@ -10,6 +10,7 @@ import java.util.List;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.query.sqm.ComparisonOperator;
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.Statement;
@ -143,6 +144,18 @@ public class InformixSqlAstTranslator<T extends JdbcOperation> extends AbstractS
return " from " + getDual() + " dual";
}
@Override
protected void renderNull(Literal literal) {
if ( getParameterRenderingMode() == SqlAstNodeRenderingMode.NO_UNTYPED ) {
renderCasted( literal );
}
else {
int sqlType = literal.getExpressionType().getSingleJdbcMapping().getJdbcType().getJdbcTypeCode();
String nullString = getDialect().getSelectClauseNullString( sqlType, getSessionFactory().getTypeConfiguration() );
appendSql( nullString );
}
}
private boolean supportsParameterOffsetFetchExpression() {
return getDialect().getVersion().isSameOrAfter( 11 );
}

View File

@ -7413,7 +7413,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
}
}
private void renderNull(Literal literal) {
protected void renderNull(Literal literal) {
if ( getParameterRenderingMode() == SqlAstNodeRenderingMode.NO_UNTYPED ) {
renderCasted( literal );
}