Fix more test failures with write path model

This commit is contained in:
Christian Beikov 2022-11-29 08:39:59 +01:00
parent a81f9d3e2d
commit 26aaf1bf88
3 changed files with 52 additions and 44 deletions

View File

@ -7642,33 +7642,41 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
appendSql( tableInsert.getMutatingTable().getTableName() );
registerAffectedTable( tableInsert.getMutatingTable().getTableName() );
sqlBuffer.append( " (" );
tableInsert.forEachValueBinding( (columnPosition, columnValueBinding) -> {
sqlBuffer.append( columnValueBinding.getColumnReference().getColumnExpression() );
if ( columnPosition < tableInsert.getNumberOfValueBindings() - 1 ) {
sqlBuffer.append( ", " );
}
} );
getCurrentClauseStack().push( Clause.VALUES );
try {
sqlBuffer.append( ") values (" );
sqlBuffer.append( ' ' );
if ( tableInsert.getNumberOfValueBindings() == 0 ) {
sqlBuffer.append( dialect.getNoColumnsInsertString() );
}
else {
tableInsert.forEachValueBinding( (columnPosition, columnValueBinding) -> {
columnValueBinding.getValueExpression().accept( this );
if ( columnPosition < tableInsert.getNumberOfValueBindings() - 1 ) {
sqlBuffer.append( ", " );
if ( columnPosition == 0 ) {
sqlBuffer.append( '(' );
}
else {
sqlBuffer.append( ',' );
}
sqlBuffer.append( columnValueBinding.getColumnReference().getColumnExpression() );
} );
}
finally {
getCurrentClauseStack().pop();
}
sqlBuffer.append( ")" );
getCurrentClauseStack().push( Clause.VALUES );
try {
sqlBuffer.append( ") values " );
tableInsert.forEachValueBinding( (columnPosition, columnValueBinding) -> {
if ( columnPosition == 0 ) {
sqlBuffer.append( '(' );
}
else {
sqlBuffer.append( ',' );
}
columnValueBinding.getValueExpression().accept( this );
} );
}
finally {
getCurrentClauseStack().pop();
}
sqlBuffer.append( ")" );
}
}
@Override
@ -7692,15 +7700,17 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
getCurrentClauseStack().push( Clause.SET );
try {
sqlBuffer.append( " set " );
tableUpdate.forEachValueBinding( (position, columnValueBinding) -> {
sqlBuffer.append( columnValueBinding.getColumnReference().getColumnExpression() );
sqlBuffer.append( "=" );
columnValueBinding.getValueExpression().accept( this );
if ( position < tableUpdate.getNumberOfValueBindings() - 1 ) {
sqlBuffer.append( ", " );
sqlBuffer.append( " set" );
tableUpdate.forEachValueBinding( (columnPosition, columnValueBinding) -> {
if ( columnPosition == 0 ) {
sqlBuffer.append( ' ' );
}
else {
sqlBuffer.append( ',' );
}
sqlBuffer.append( columnValueBinding.getColumnReference().getColumnExpression() );
sqlBuffer.append( '=' );
columnValueBinding.getValueExpression().accept( this );
} );
}
finally {
@ -7709,20 +7719,22 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
getCurrentClauseStack().push( Clause.WHERE );
try {
sqlBuffer.append( " where " );
sqlBuffer.append( " where" );
tableUpdate.forEachKeyBinding( (position, columnValueBinding) -> {
sqlBuffer.append( columnValueBinding.getColumnReference().getColumnExpression() );
sqlBuffer.append( "=" );
columnValueBinding.getValueExpression().accept( this );
if ( position < tableUpdate.getNumberOfKeyBindings() - 1 ) {
if ( position == 0 ) {
sqlBuffer.append( ' ' );
}
else {
sqlBuffer.append( " and " );
}
sqlBuffer.append( columnValueBinding.getColumnReference().getColumnExpression() );
sqlBuffer.append( '=' );
columnValueBinding.getValueExpression().accept( this );
} );
if ( tableUpdate.getNumberOfOptimisticLockBindings() > 0 ) {
sqlBuffer.append( " and " );
tableUpdate.forEachOptimisticLockBinding( (position, columnValueBinding) -> {
sqlBuffer.append( " and " );
sqlBuffer.append( columnValueBinding.getColumnReference().getColumnExpression() );
if ( columnValueBinding.getValueExpression() == null ) {
sqlBuffer.append( " is null" );
@ -7731,10 +7743,6 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
sqlBuffer.append( "=" );
columnValueBinding.getValueExpression().accept( this );
}
if ( position < tableUpdate.getNumberOfOptimisticLockBindings() - 1 ) {
sqlBuffer.append( " and " );
}
} );
}

View File

@ -66,8 +66,8 @@ public abstract class AbstractTableInsertBuilder
if ( jdbcMapping.getJdbcType().isLob() && getJdbcServices().getDialect().forceLobAsLastValue() ) {
if ( lobValueBindingList == null ) {
lobValueBindingList = new ArrayList<>();
lobValueBindingList.add( valueBinding );
}
lobValueBindingList.add( valueBinding );
}
else {
valueBindingList.add( valueBinding );

View File

@ -65,8 +65,8 @@ public abstract class AbstractTableUpdateBuilder<O extends MutationOperation>
if ( jdbcMapping.getJdbcType().isLob() && getJdbcServices().getDialect().forceLobAsLastValue() ) {
if ( lobValueBindings == null ) {
lobValueBindings = new ArrayList<>();
lobValueBindings.add( valueBinding );
}
lobValueBindings.add( valueBinding );
}
else {
valueBindings.add( valueBinding );