44using Microsoft . EntityFrameworkCore . TestUtilities ;
55using MySqlConnector ;
66using Pomelo . EntityFrameworkCore . MySql . FunctionalTests . TestUtilities ;
7+ using Pomelo . EntityFrameworkCore . MySql . Tests ;
78using Xunit ;
89
910namespace Pomelo . EntityFrameworkCore . MySql . FunctionalTests . BulkUpdates ;
@@ -53,9 +54,11 @@ public override async Task Delete_aggregate_root_when_table_sharing_with_non_own
5354
5455 public override async Task Delete_predicate_based_on_optional_navigation ( bool async )
5556 {
56- await base . Delete_predicate_based_on_optional_navigation ( async) ;
57+ if ( AppConfig . ServerVersion . Supports . DeleteWithSelfReferencingSubquery )
58+ {
59+ await base . Delete_predicate_based_on_optional_navigation ( async) ;
5760
58- AssertSql (
61+ AssertSql (
5962"""
6063DELETE `p`
6164FROM `Posts` AS `p`
@@ -66,6 +69,14 @@ public override async Task Delete_predicate_based_on_optional_navigation(bool as
6669 WHERE `b`.`Title` LIKE 'Arthur%'
6770)
6871""" ) ;
72+ }
73+ else
74+ {
75+ // Not supported by MySQL and older MariaDB versions:
76+ // Error Code: 1093. You can't specify target table 'p' for update in FROM clause
77+ await Assert . ThrowsAsync < MySqlException > (
78+ ( ) => base . Delete_predicate_based_on_optional_navigation ( async) ) ;
79+ }
6980 }
7081
7182 public override async Task Update_non_owned_property_on_entity_with_owned ( bool async )
@@ -130,9 +141,11 @@ public override async Task Update_non_main_table_in_entity_with_entity_splitting
130141
131142 public override async Task Delete_entity_with_auto_include ( bool async )
132143 {
133- await base . Delete_entity_with_auto_include ( async) ;
144+ if ( AppConfig . ServerVersion . Supports . DeleteWithSelfReferencingSubquery )
145+ {
146+ await base . Delete_entity_with_auto_include ( async) ;
134147
135- AssertSql (
148+ AssertSql (
136149"""
137150DELETE `c`
138151FROM `Context30572_Principal` AS `c`
@@ -142,6 +155,14 @@ public override async Task Delete_entity_with_auto_include(bool async)
142155 LEFT JOIN `Context30572_Dependent` AS `c1` ON `c0`.`DependentId` = `c1`.`Id`
143156)
144157""" ) ;
158+ }
159+ else
160+ {
161+ // Not supported by MySQL and older MariaDB versions:
162+ // Error Code: 1093. You can't specify target table 'c' for update in FROM clause
163+ await Assert . ThrowsAsync < MySqlException > (
164+ ( ) => base . Delete_entity_with_auto_include ( async) ) ;
165+ }
145166 }
146167
147168 public override async Task Update_with_alias_uniquification_in_setter_subquery ( bool async )
0 commit comments