Skip to content

Commit a38d24e

Browse files
Copilotrenemadsen
andcommitted
Add conditional check for Delete_Where_using_navigation_2 test
MySQL and older MariaDB versions don't support DELETE with self-referencing subqueries (Error 1093). Added conditional logic to handle this limitation, following the pattern used in other similar tests. Co-authored-by: renemadsen <76994+renemadsen@users.noreply.github.com>
1 parent 65aa9e2 commit a38d24e

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

test/EFCore.MySql.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesMySqlTest.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,10 @@ WHERE EXTRACT(year FROM `o0`.`OrderDate`) = 2000
410410

411411
public override async Task Delete_Where_using_navigation_2(bool async)
412412
{
413-
await base.Delete_Where_using_navigation_2(async);
414-
AssertSql(
413+
if (AppConfig.ServerVersion.Supports.DeleteWithSelfReferencingSubquery)
414+
{
415+
await base.Delete_Where_using_navigation_2(async);
416+
AssertSql(
415417
"""
416418
DELETE `o`
417419
FROM `Order Details` AS `o`
@@ -422,6 +424,26 @@ SELECT 1
422424
LEFT JOIN `Customers` AS `c` ON `o1`.`CustomerID` = `c`.`CustomerID`
423425
WHERE (`c`.`CustomerID` LIKE 'F%') AND ((`o0`.`OrderID` = `o`.`OrderID`) AND (`o0`.`ProductID` = `o`.`ProductID`)))
424426
""");
427+
}
428+
else
429+
{
430+
// Not supported by MySQL and older MariaDB versions:
431+
// Error Code: 1093. You can't specify target table 'o' for update in FROM clause
432+
await Assert.ThrowsAsync<MySqlException>(
433+
() => base.Delete_Where_using_navigation_2(async));
434+
435+
AssertSql(
436+
"""
437+
DELETE `o`
438+
FROM `Order Details` AS `o`
439+
WHERE EXISTS (
440+
SELECT 1
441+
FROM `Order Details` AS `o0`
442+
INNER JOIN `Orders` AS `o1` ON `o0`.`OrderID` = `o1`.`OrderID`
443+
LEFT JOIN `Customers` AS `c` ON `o1`.`CustomerID` = `c`.`CustomerID`
444+
WHERE (`c`.`CustomerID` LIKE 'F%') AND ((`o0`.`OrderID` = `o`.`OrderID`) AND (`o0`.`ProductID` = `o`.`ProductID`)))
445+
""");
446+
}
425447
}
426448

427449
public override async Task Delete_Union(bool async)

0 commit comments

Comments
 (0)