HHH-17906 Use insert target paths for type inference of SqmValues

This commit is contained in:
Christian Beikov 2024-03-28 14:59:30 +01:00
parent d423b52be3
commit fe4a3fbaf3
1 changed files with 13 additions and 2 deletions

View File

@ -1586,11 +1586,22 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
@Override
public Values visitValues(SqmValues sqmValues) {
final List<SqmPath<?>> insertionTargetPaths;
if ( currentSqmStatement instanceof SqmInsertStatement<?> ) {
insertionTargetPaths = ( (SqmInsertStatement<?>) currentSqmStatement ).getInsertionTargetPaths();
}
else {
insertionTargetPaths = null;
}
final List<SqmExpression<?>> expressions = sqmValues.getExpressions();
final ArrayList<Expression> valuesExpressions = new ArrayList<>( expressions.size() );
for ( SqmExpression<?> expression : expressions ) {
for ( int i = 0; i < expressions.size(); i++ ) {
// todo: add WriteExpression handling
valuesExpressions.add( (Expression) expression.accept( this ) );
valuesExpressions.add(
insertionTargetPaths == null
? (Expression) expressions.get( i ).accept( this )
: visitWithInferredType( expressions.get( i ), insertionTargetPaths.get( i ) )
);
}
return new Values( valuesExpressions );
}