@@ -7053,6 +7053,9 @@ public void visitParameter(JdbcParameter jdbcParameter) {
70537053renderExpressionAsLiteral ( jdbcParameter , jdbcParameterBindings );
70547054break ;
70557055}
7056+ case WRAP_ALL_PARAMETERS :
7057+ renderWrappedParameter ( jdbcParameter );
7058+ break ;
70567059case DEFAULT :
70577060default : {
70587061visitParameterAsParameter ( jdbcParameter );
@@ -7073,6 +7076,21 @@ protected final void renderParameterAsParameter(JdbcParameter jdbcParameter) {
70737076renderParameterAsParameter ( parameterBinders .size () + 1 , jdbcParameter );
70747077}
70757078
7079+ protected void renderWrappedParameter (JdbcParameter jdbcParameter ) {
7080+ clauseStack .push ( Clause .SELECT );
7081+
7082+ try {
7083+ appendSql ( "(select " );
7084+
7085+ render ( jdbcParameter , SqlAstNodeRenderingMode .DEFAULT );
7086+ appendSql ( getFromDualForSelectOnly () );
7087+ appendSql ( ')' );
7088+ }
7089+ finally {
7090+ clauseStack .pop ();
7091+ }
7092+ }
7093+
70767094/**
70777095 * Renders a parameter marker for the given position
70787096 * @param jdbcParameter
@@ -7088,7 +7106,7 @@ protected void renderParameterAsParameter(int position, JdbcParameter jdbcParame
70887106@ Override
70897107public void render (SqlAstNode sqlAstNode , SqlAstNodeRenderingMode renderingMode ) {
70907108SqlAstNodeRenderingMode original = this .parameterRenderingMode ;
7091- if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS ) {
7109+ if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS && original != SqlAstNodeRenderingMode . WRAP_ALL_PARAMETERS ) {
70927110this .parameterRenderingMode = renderingMode ;
70937111}
70947112try {
@@ -7101,7 +7119,7 @@ public void render(SqlAstNode sqlAstNode, SqlAstNodeRenderingMode renderingMode)
71017119
71027120protected void withParameterRenderingMode (SqlAstNodeRenderingMode renderingMode , Runnable runnable ) {
71037121SqlAstNodeRenderingMode original = this .parameterRenderingMode ;
7104- if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS ) {
7122+ if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS && original != SqlAstNodeRenderingMode . WRAP_ALL_PARAMETERS ) {
71057123this .parameterRenderingMode = renderingMode ;
71067124}
71077125try {
@@ -7285,7 +7303,7 @@ protected void visitAnsiCaseSearchedExpression(
72857303appendSql ( "case" );
72867304final SqlAstNodeRenderingMode original = this .parameterRenderingMode ;
72877305for ( CaseSearchedExpression .WhenFragment whenFragment : caseSearchedExpression .getWhenFragments () ) {
7288- if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS ) {
7306+ if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS && original != SqlAstNodeRenderingMode . WRAP_ALL_PARAMETERS ) {
72897307this .parameterRenderingMode = SqlAstNodeRenderingMode .DEFAULT ;
72907308}
72917309appendSql ( " when " );
@@ -7313,7 +7331,7 @@ protected void visitDecodeCaseSearchedExpression(CaseSearchedExpression caseSear
73137331for ( int i = 0 ; i < caseNumber ; i ++ ) {
73147332final CaseSearchedExpression .WhenFragment whenFragment = whenFragments .get ( i );
73157333Predicate predicate = whenFragment .getPredicate ();
7316- if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS ) {
7334+ if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS && original != SqlAstNodeRenderingMode . WRAP_ALL_PARAMETERS ) {
73177335this .parameterRenderingMode = SqlAstNodeRenderingMode .DEFAULT ;
73187336}
73197337if ( i != 0 ) {
@@ -7360,12 +7378,12 @@ protected void visitAnsiCaseSimpleExpression(
73607378Consumer <Expression > resultRenderer ) {
73617379appendSql ( "case " );
73627380final SqlAstNodeRenderingMode original = this .parameterRenderingMode ;
7363- if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS ) {
7381+ if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS && original != SqlAstNodeRenderingMode . WRAP_ALL_PARAMETERS ) {
73647382this .parameterRenderingMode = SqlAstNodeRenderingMode .DEFAULT ;
73657383}
73667384caseSimpleExpression .getFixture ().accept ( this );
73677385for ( CaseSimpleExpression .WhenFragment whenFragment : caseSimpleExpression .getWhenFragments () ) {
7368- if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS ) {
7386+ if ( original != SqlAstNodeRenderingMode .INLINE_ALL_PARAMETERS && original != SqlAstNodeRenderingMode . WRAP_ALL_PARAMETERS ) {
73697387this .parameterRenderingMode = SqlAstNodeRenderingMode .DEFAULT ;
73707388}
73717389appendSql ( " when " );
0 commit comments