Try cast instead of inlining
This commit is contained in:
parent
abbbd2d3fb
commit
abfa2de1d4
|
@ -2760,13 +2760,13 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
||||||
@Override
|
@Override
|
||||||
public void render(SqlAstNode sqlAstNode, SqlAstNodeRenderingMode renderingMode) {
|
public void render(SqlAstNode sqlAstNode, SqlAstNodeRenderingMode renderingMode) {
|
||||||
switch ( renderingMode ) {
|
switch ( renderingMode ) {
|
||||||
case NO_PLAIN_PARAMETER:
|
case NO_PLAIN_PARAMETER: {
|
||||||
if ( sqlAstNode instanceof SqmParameterInterpretation ) {
|
if ( sqlAstNode instanceof SqmParameterInterpretation ) {
|
||||||
sqlAstNode = ( (SqmParameterInterpretation) sqlAstNode ).getResolvedExpression();
|
sqlAstNode = ( (SqmParameterInterpretation) sqlAstNode ).getResolvedExpression();
|
||||||
}
|
}
|
||||||
if ( sqlAstNode instanceof JdbcParameter ) {
|
if ( sqlAstNode instanceof JdbcParameter ) {
|
||||||
final JdbcMapping jdbcMapping = ( (JdbcParameter) sqlAstNode ).getExpressionType().getJdbcMappings()
|
final JdbcParameter jdbcParameter = (JdbcParameter) sqlAstNode;
|
||||||
.get( 0 );
|
final JdbcMapping jdbcMapping = jdbcParameter.getExpressionType().getJdbcMappings().get( 0 );
|
||||||
// We try to avoid inlining parameters if possible which can be done by wrapping the parameter
|
// We try to avoid inlining parameters if possible which can be done by wrapping the parameter
|
||||||
// in an expression that is semantically unnecessary e.g. numeric + 0 or concat with an empty string
|
// in an expression that is semantically unnecessary e.g. numeric + 0 or concat with an empty string
|
||||||
if ( jdbcMapping.getSqlTypeDescriptor().isNumber() ) {
|
if ( jdbcMapping.getSqlTypeDescriptor().isNumber() ) {
|
||||||
|
@ -2788,13 +2788,17 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
renderExpressionAsLiteral( (Expression) sqlAstNode, jdbcParameterBindings );
|
final List<SqlAstNode> arguments = new ArrayList<>( 2 );
|
||||||
|
arguments.add( jdbcParameter );
|
||||||
|
arguments.add( new CastTarget( (BasicValuedMapping) jdbcMapping ) );
|
||||||
|
castFunction().render( this, arguments, this );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sqlAstNode.accept( this );
|
sqlAstNode.accept( this );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INLINE_PARAMETERS:
|
}
|
||||||
|
case INLINE_PARAMETERS: {
|
||||||
boolean inlineParameters = this.inlineParameters;
|
boolean inlineParameters = this.inlineParameters;
|
||||||
this.inlineParameters = true;
|
this.inlineParameters = true;
|
||||||
try {
|
try {
|
||||||
|
@ -2804,16 +2808,16 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
|
||||||
this.inlineParameters = inlineParameters;
|
this.inlineParameters = inlineParameters;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
default:
|
default: {
|
||||||
sqlAstNode.accept( this );
|
sqlAstNode.accept( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitTuple(SqlTuple tuple) {
|
public void visitTuple(SqlTuple tuple) {
|
||||||
String separator = NO_SEPARATOR;
|
|
||||||
|
|
||||||
boolean isCurrentWhereClause = clauseStack.getCurrent() == Clause.WHERE;
|
boolean isCurrentWhereClause = clauseStack.getCurrent() == Clause.WHERE;
|
||||||
if ( isCurrentWhereClause ) {
|
if ( isCurrentWhereClause ) {
|
||||||
appendSql( OPEN_PARENTHESIS );
|
appendSql( OPEN_PARENTHESIS );
|
||||||
|
|
Loading…
Reference in New Issue