From 451d1de288fb10c22cb44a9007355e0869f491ca Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Tue, 3 Sep 2024 00:33:19 +0800 Subject: [PATCH] Fix #33947. Need to match on whether the expressions are pointing to same table, even if not the same instance --- src/EFCore.Relational/Query/QuerySqlGenerator.cs | 2 +- .../BulkUpdates/NonSharedModelBulkUpdatesSqliteTest.cs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/EFCore.Relational/Query/QuerySqlGenerator.cs b/src/EFCore.Relational/Query/QuerySqlGenerator.cs index 1906d587a40..2a5a7a9a544 100644 --- a/src/EFCore.Relational/Query/QuerySqlGenerator.cs +++ b/src/EFCore.Relational/Query/QuerySqlGenerator.cs @@ -1496,7 +1496,7 @@ protected override Expression VisitUpdate(UpdateExpression updateExpression) var table = selectExpression.Tables[i]; var joinExpression = table as JoinExpressionBase; - if (ReferenceEquals(updateExpression.Table, joinExpression?.Table ?? table)) + if (updateExpression.Table.Alias == (joinExpression?.Table.Alias ?? table.Alias)) { LiftPredicate(table); continue; diff --git a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqliteTest.cs index 52763b754ae..d54efcb7a0f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSqliteTest.cs @@ -63,15 +63,14 @@ public override async Task Delete_aggregate_root_when_table_sharing_with_non_own public override async Task Replace_ColumnExpression_in_column_setter(bool async) { - // #33947 - await Assert.ThrowsAsync(() => base.Replace_ColumnExpression_in_column_setter(async)); + await base.Replace_ColumnExpression_in_column_setter(async); AssertSql( """ UPDATE "OwnedCollection" AS "o0" SET "Value" = 'SomeValue' FROM "Owner" AS "o" -INNER JOIN "OwnedCollection" AS "o0" ON "o"."Id" = "o0"."OwnerId" +WHERE "o"."Id" = "o0"."OwnerId" """); }