HHH-16198 - Fix splitting of SqlAstCreationState
This commit is contained in:
parent
6d9fd28c0f
commit
373e63f41b
|
@ -907,7 +907,6 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
@Override
|
@Override
|
||||||
public List<Assignment> visitSetClause(SqmSetClause setClause) {
|
public List<Assignment> visitSetClause(SqmSetClause setClause) {
|
||||||
final ArrayList<Assignment> assignments = new ArrayList<>( setClause.getAssignments().size() );
|
final ArrayList<Assignment> assignments = new ArrayList<>( setClause.getAssignments().size() );
|
||||||
final ArrayList<ColumnReference> targetColumnReferences = new ArrayList<>( 1 );
|
|
||||||
|
|
||||||
final SqmRoot<?> target = ( (SqmDmlStatement<?>) currentSqmStatement ).getTarget();
|
final SqmRoot<?> target = ( (SqmDmlStatement<?>) currentSqmStatement ).getTarget();
|
||||||
final String entityName = target.getEntityName();
|
final String entityName = target.getEntityName();
|
||||||
|
@ -924,12 +923,14 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
);
|
);
|
||||||
|
|
||||||
for ( SqmAssignment<?> sqmAssignment : setClause.getAssignments() ) {
|
for ( SqmAssignment<?> sqmAssignment : setClause.getAssignments() ) {
|
||||||
targetColumnReferences.clear();
|
|
||||||
|
|
||||||
final SqmPathInterpretation<?> assignedPathInterpretation;
|
final SqmPathInterpretation<?> assignedPathInterpretation;
|
||||||
try {
|
try {
|
||||||
pushProcessingState(
|
pushProcessingState(
|
||||||
createAssignmentProcessingState( targetColumnReferences ),
|
new SqlAstProcessingStateImpl(
|
||||||
|
getCurrentProcessingState(),
|
||||||
|
this,
|
||||||
|
getCurrentClauseStack()::getCurrent
|
||||||
|
),
|
||||||
getFromClauseIndex()
|
getFromClauseIndex()
|
||||||
);
|
);
|
||||||
currentClauseStack.push( Clause.SET );
|
currentClauseStack.push( Clause.SET );
|
||||||
|
@ -947,6 +948,15 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
|
|
||||||
final SqmExpression<?> assignmentValue = sqmAssignment.getValue();
|
final SqmExpression<?> assignmentValue = sqmAssignment.getValue();
|
||||||
final SqmParameter<?> assignmentValueParameter = getSqmParameter( assignmentValue );
|
final SqmParameter<?> assignmentValueParameter = getSqmParameter( assignmentValue );
|
||||||
|
final Expression pathSqlExpression = assignedPathInterpretation.getSqlExpression();
|
||||||
|
final List<ColumnReference> targetColumnReferences;
|
||||||
|
if ( pathSqlExpression instanceof SqlTuple ) {
|
||||||
|
//noinspection unchecked
|
||||||
|
targetColumnReferences = (List<ColumnReference>) ( (SqlTuple) pathSqlExpression ).getExpressions();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
targetColumnReferences = pathSqlExpression.getColumnReference().getColumnReferences();
|
||||||
|
}
|
||||||
if ( assignmentValueParameter != null ) {
|
if ( assignmentValueParameter != null ) {
|
||||||
consumeSqmParameter(
|
consumeSqmParameter(
|
||||||
assignmentValueParameter,
|
assignmentValueParameter,
|
||||||
|
@ -1013,22 +1023,6 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
return assignments;
|
return assignments;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SqlAstProcessingStateImpl createAssignmentProcessingState(ArrayList<ColumnReference> targetColumnReferences) {
|
|
||||||
return new SqlAstProcessingStateImpl( getCurrentProcessingState(), this, getCurrentClauseStack()::getCurrent ) {
|
|
||||||
@Override
|
|
||||||
public Expression resolveSqlExpression(
|
|
||||||
ColumnReferenceKey key,
|
|
||||||
Function<SqlAstProcessingState, Expression> creator) {
|
|
||||||
final Expression expression = getParentState()
|
|
||||||
.getSqlExpressionResolver()
|
|
||||||
.resolveSqlExpression( key, creator );
|
|
||||||
assert expression instanceof ColumnReference;
|
|
||||||
targetColumnReferences.add( (ColumnReference) expression );
|
|
||||||
return expression;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addAssignment(
|
private void addAssignment(
|
||||||
List<Assignment> assignments,
|
List<Assignment> assignments,
|
||||||
AggregateColumnAssignmentHandler aggregateColumnAssignmentHandler,
|
AggregateColumnAssignmentHandler aggregateColumnAssignmentHandler,
|
||||||
|
|
Loading…
Reference in New Issue