|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | +using Xunit.Sdk; |
| 5 | + |
| 6 | +namespace Microsoft.EntityFrameworkCore.Query.Associations.Navigations; |
| 7 | + |
| 8 | +public class NavigationsBulkUpdateNpgsqlTest(NavigationsNpgsqlFixture fixture, ITestOutputHelper testOutputHelper) |
| 9 | + : NavigationsBulkUpdateRelationalTestBase<NavigationsNpgsqlFixture>(fixture, testOutputHelper) |
| 10 | +{ |
| 11 | + [ConditionalFact] |
| 12 | + public virtual void Check_all_tests_overridden() |
| 13 | + => TestHelpers.AssertAllMethodsOverridden(GetType()); |
| 14 | + |
| 15 | + // FK constraint failures |
| 16 | + public override Task Delete_entity_with_associations() |
| 17 | + => Assert.ThrowsAsync<PostgresException>(base.Delete_entity_with_associations); |
| 18 | + |
| 19 | + public override Task Delete_required_associate() |
| 20 | + => Assert.ThrowsAsync<PostgresException>(base.Delete_required_associate); |
| 21 | + |
| 22 | + public override Task Delete_optional_associate() |
| 23 | + => Assert.ThrowsAsync<PostgresException>(base.Delete_optional_associate); |
| 24 | + |
| 25 | + // PostgreSQL generates valid SQL for these but produces wrong row counts due to self-joins in UPDATE ... FROM |
| 26 | + public override Task Update_property_inside_associate() |
| 27 | + => Assert.ThrowsAsync<EqualException>(base.Update_property_inside_associate); |
| 28 | + |
| 29 | + public override Task Update_property_inside_associate_with_special_chars() |
| 30 | + => Assert.ThrowsAsync<EqualException>(base.Update_property_inside_associate_with_special_chars); |
| 31 | + |
| 32 | + public override Task Update_property_on_projected_associate() |
| 33 | + => Assert.ThrowsAsync<EqualException>(base.Update_property_on_projected_associate); |
| 34 | + |
| 35 | + public override Task Update_property_on_projected_associate_with_OrderBy_Skip() |
| 36 | + => Assert.ThrowsAsync<EqualException>(base.Update_property_on_projected_associate_with_OrderBy_Skip); |
| 37 | + |
| 38 | + public override Task Update_multiple_properties_inside_same_associate() |
| 39 | + => Assert.ThrowsAsync<EqualException>(base.Update_multiple_properties_inside_same_associate); |
| 40 | + |
| 41 | + public override Task Update_primitive_collection_to_constant() |
| 42 | + => Assert.ThrowsAsync<EqualException>(base.Update_primitive_collection_to_constant); |
| 43 | + |
| 44 | + public override Task Update_primitive_collection_to_parameter() |
| 45 | + => Assert.ThrowsAsync<EqualException>(base.Update_primitive_collection_to_parameter); |
| 46 | + |
| 47 | + // Translation not yet supported for navigation-mapped associations |
| 48 | + public override Task Update_associate_to_parameter() |
| 49 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_associate_to_parameter); |
| 50 | + |
| 51 | + public override Task Update_associate_to_inline() |
| 52 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_associate_to_inline); |
| 53 | + |
| 54 | + public override Task Update_associate_to_inline_with_lambda() |
| 55 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_associate_to_inline_with_lambda); |
| 56 | + |
| 57 | + public override Task Update_associate_to_another_associate() |
| 58 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_associate_to_another_associate); |
| 59 | + |
| 60 | + public override Task Update_associate_to_null() |
| 61 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_associate_to_null); |
| 62 | + |
| 63 | + public override Task Update_associate_to_null_with_lambda() |
| 64 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_associate_to_null_with_lambda); |
| 65 | + |
| 66 | + public override Task Update_associate_to_null_parameter() |
| 67 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_associate_to_null_parameter); |
| 68 | + |
| 69 | + public override Task Update_nested_associate_to_parameter() |
| 70 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_nested_associate_to_parameter); |
| 71 | + |
| 72 | + public override Task Update_nested_associate_to_inline_with_lambda() |
| 73 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_nested_associate_to_inline_with_lambda); |
| 74 | + |
| 75 | + public override Task Update_nested_associate_to_another_nested_associate() |
| 76 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_nested_associate_to_another_nested_associate); |
| 77 | + |
| 78 | + public override Task Update_nested_collection_to_parameter() |
| 79 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_nested_collection_to_parameter); |
| 80 | + |
| 81 | + public override Task Update_nested_collection_to_inline_with_lambda() |
| 82 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_nested_collection_to_inline_with_lambda); |
| 83 | + |
| 84 | + public override Task Update_nested_collection_to_another_nested_collection() |
| 85 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_nested_collection_to_another_nested_collection); |
| 86 | + |
| 87 | + public override Task Update_collection_to_parameter() |
| 88 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_collection_to_parameter); |
| 89 | + |
| 90 | + public override Task Update_collection_referencing_the_original_collection() |
| 91 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_collection_referencing_the_original_collection); |
| 92 | + |
| 93 | + public override Task Update_primitive_collection_to_another_collection() |
| 94 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_primitive_collection_to_another_collection); |
| 95 | + |
| 96 | + public override Task Update_inside_structural_collection() |
| 97 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_inside_structural_collection); |
| 98 | + |
| 99 | + public override Task Update_multiple_properties_inside_associates_and_on_entity_type() |
| 100 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_multiple_properties_inside_associates_and_on_entity_type); |
| 101 | + |
| 102 | + public override Task Update_multiple_projected_associates_via_anonymous_type() |
| 103 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_multiple_projected_associates_via_anonymous_type); |
| 104 | + |
| 105 | + public override async Task Update_property_inside_nested_associate() |
| 106 | + { |
| 107 | + await base.Update_property_inside_nested_associate(); |
| 108 | + |
| 109 | + AssertExecuteUpdateSql( |
| 110 | + """ |
| 111 | +@p='foo_updated' |
| 112 | +
|
| 113 | +UPDATE "NestedAssociateType" AS n |
| 114 | +SET "String" = @p |
| 115 | +FROM "RootEntity" AS r |
| 116 | +INNER JOIN "AssociateType" AS a ON r."RequiredAssociateId" = a."Id" |
| 117 | +WHERE a."RequiredNestedAssociateId" = n."Id" |
| 118 | +"""); |
| 119 | + } |
| 120 | + |
| 121 | + public override async Task Update_associate_with_null_required_property() |
| 122 | + { |
| 123 | + await base.Update_associate_with_null_required_property(); |
| 124 | + |
| 125 | + AssertExecuteUpdateSql(); |
| 126 | + } |
| 127 | + |
| 128 | + public override async Task Update_required_nested_associate_to_null() |
| 129 | + { |
| 130 | + await base.Update_required_nested_associate_to_null(); |
| 131 | + |
| 132 | + AssertExecuteUpdateSql(); |
| 133 | + } |
| 134 | + |
| 135 | + public override Task Update_inside_primitive_collection() |
| 136 | + => Assert.ThrowsAsync<InvalidOperationException>(base.Update_inside_primitive_collection); |
| 137 | +} |
0 commit comments