@@ -735,8 +735,11 @@ SELECT 1
735735
736736 public override async Task Delete_Where_optional_navigation_predicate ( bool async )
737737 {
738- await base . Delete_Where_optional_navigation_predicate ( async) ;
739- AssertSql (
738+ if ( AppConfig . ServerVersion . Supports . DeleteWithSelfReferencingSubquery )
739+ {
740+ await base . Delete_Where_optional_navigation_predicate ( async) ;
741+
742+ AssertSql (
740743"""
741744DELETE `o`
742745FROM `Order Details` AS `o`
@@ -747,6 +750,14 @@ SELECT 1
747750 LEFT JOIN `Customers` AS `c` ON `o1`.`CustomerID` = `c`.`CustomerID`
748751 WHERE (`c`.`City` LIKE 'Se%') AND ((`o0`.`OrderID` = `o`.`OrderID`) AND (`o0`.`ProductID` = `o`.`ProductID`)))
749752""" ) ;
753+ }
754+ else
755+ {
756+ // Not supported by MySQL and older MariaDB versions:
757+ // Error Code: 1093. You can't specify target table 'o' for update in FROM clause
758+ await Assert . ThrowsAsync < MySqlException > (
759+ ( ) => base . Delete_Where_optional_navigation_predicate ( async) ) ;
760+ }
750761 }
751762
752763 public override async Task Delete_with_join ( bool async )
@@ -877,9 +888,11 @@ LIMIT 100 OFFSET 0
877888
878889 public override async Task Delete_with_cross_apply ( bool async )
879890 {
880- await base . Delete_with_cross_apply ( async) ;
891+ if ( AppConfig . ServerVersion . Supports . DeleteWithSelfReferencingSubquery )
892+ {
893+ await base . Delete_with_cross_apply ( async) ;
881894
882- AssertSql (
895+ AssertSql (
883896"""
884897DELETE `o`
885898FROM `Order Details` AS `o`
@@ -892,13 +905,23 @@ LIMIT 100 OFFSET 0
892905) AS `o1` ON TRUE
893906WHERE `o`.`OrderID` < 10276
894907""" ) ;
908+ }
909+ else
910+ {
911+ // Not supported by MySQL and older MariaDB versions:
912+ // Error Code: 1093. You can't specify target table 'o' for update in FROM clause
913+ await Assert . ThrowsAsync < MySqlException > (
914+ ( ) => base . Delete_with_cross_apply ( async) ) ;
915+ }
895916 }
896917
897918 public override async Task Delete_with_outer_apply ( bool async )
898919 {
899- await base . Delete_with_outer_apply ( async) ;
920+ if ( AppConfig . ServerVersion . Supports . DeleteWithSelfReferencingSubquery )
921+ {
922+ await base . Delete_with_outer_apply ( async) ;
900923
901- AssertSql (
924+ AssertSql (
902925"""
903926DELETE `o`
904927FROM `Order Details` AS `o`
@@ -911,6 +934,14 @@ LIMIT 100 OFFSET 0
911934) AS `o1` ON TRUE
912935WHERE `o`.`OrderID` < 10276
913936""" ) ;
937+ }
938+ else
939+ {
940+ // Not supported by MySQL and older MariaDB versions:
941+ // Error Code: 1093. You can't specify target table 'o' for update in FROM clause
942+ await Assert . ThrowsAsync < MySqlException > (
943+ ( ) => base . Delete_with_outer_apply ( async) ) ;
944+ }
914945 }
915946
916947 public override async Task Update_Where_set_constant_TagWith ( bool async )
@@ -1849,7 +1880,18 @@ await Assert.ThrowsAsync<MySqlException>(
18491880
18501881 public override async Task Delete_with_RightJoin ( bool async )
18511882 {
1852- await base . Delete_with_RightJoin ( async) ;
1883+ if ( ! AppConfig . ServerVersion . Supports . DeleteWithSelfReferencingSubquery )
1884+ {
1885+ // Not supported by MySQL and older MariaDB versions:
1886+ // Error Code: 1093. You can't specify target table 'o' for update in FROM clause
1887+ await Assert . ThrowsAsync < MySqlException > (
1888+ ( ) => base . Delete_with_RightJoin ( async) ) ;
1889+ }
1890+ else
1891+ {
1892+ // Works as expected in MariaDB 11+.
1893+ await base . Delete_with_RightJoin ( async) ;
1894+ }
18531895
18541896 // Note: SQL validation skipped - actual SQL needs to be captured from test run
18551897 }
0 commit comments