efcore.pg
efcore.pg copied to clipboard
ExecuteUpdate: handle queries failing due to invalid references to main table
Tests Update_with_cross_join_cross_apply_set_constant, Update_with_cross_join_left_join_set_constant, Update_with_cross_join_outer_apply_set_constant.
Make these work by introducing an additional subquery join, see https://github.com/dotnet/efcore/pull/28834#pullrequestreview-1082059936.
See conversation in https://github.com/npgsql/efcore.pg/pull/2476#discussion_r952034688
This will require changing IsValidSelectExpressionForExecuteUpdate method.
- By default relational converts APPLY to JOIN if there are no outer references (or they can be lifted in join predicate), so APPLY should cause it in all cases.
- For predicate joins, need to check join condition
- LEFT join would cause subquery join
- INNER join can lift predicate to outer level and convert it to cross join
Look at SelectExpressionCorrelationFindingExpressionVisitor and write similar visitor to verify the outer references from the table which is being updated.
Thanks @smitpatel, will follow these instructions.