Skip to content

Commit e319941

Browse files
authored
Don't use same table in join when it is also primary target table (#3263)
1 parent 1206e51 commit e319941

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ protected override Expression VisitUpdate(UpdateExpression updateExpression)
341341
var table = selectExpression.Tables[i];
342342
var joinExpression = table as JoinExpressionBase;
343343

344-
if (ReferenceEquals(updateExpression.Table, joinExpression?.Table ?? table))
344+
if (updateExpression.Table.Alias == (joinExpression?.Table.Alias ?? table.Alias))
345345
{
346346
LiftPredicate(table);
347347
continue;

test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,17 @@ DELETE FROM "Owner" AS o
5050
""");
5151
}
5252

53-
// TODO: #3253
5453
public override async Task Replace_ColumnExpression_in_column_setter(bool async)
5554
{
56-
var exception = await Assert.ThrowsAsync<PostgresException>(() => base.Replace_ColumnExpression_in_column_setter(async));
55+
await base.Replace_ColumnExpression_in_column_setter(async);
5756

58-
Assert.Equal("42712", exception.SqlState);
57+
AssertSql(
58+
"""
59+
UPDATE "OwnedCollection" AS o0
60+
SET "Value" = 'SomeValue'
61+
FROM "Owner" AS o
62+
WHERE o."Id" = o0."OwnerId"
63+
""");
5964
}
6065

6166
public override async Task Delete_aggregate_root_when_table_sharing_with_non_owned_throws(bool async)

0 commit comments

Comments
 (0)