diff --git a/Directory.Packages.props b/Directory.Packages.props index 12b0768fd2..9b86bfd74e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,7 +1,7 @@ - 10.0.4 - 10.0.4 + 10.0.13 + 10.0.13 10.0.3 @@ -10,11 +10,11 @@ Dependencies on EF preview versions should be locked to a specific version (as provider-facing breaking changes are frequent). For released versions, depend on anything in the current major version to allow users to update to higher patch versions. --> - - - - - + + + + + @@ -25,12 +25,12 @@ - - + + - - + + diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs index 60f43d3dfd..66387e3354 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs @@ -687,6 +687,18 @@ WHERE c."CustomerID" LIKE 'F%' """); } + public override async Task Update_Where_set_nullable_int_constant_via_discard_lambda(bool async) + { + await base.Update_Where_set_nullable_int_constant_via_discard_lambda(async); + + AssertExecuteUpdateSql( + """ +UPDATE "Products" AS p +SET "SupplierID" = 1 +WHERE p."ProductID" < 5 +"""); + } + public override async Task Update_Where_parameter_set_constant(bool async) { await base.Update_Where_parameter_set_constant(async); @@ -1512,6 +1524,32 @@ public override async Task Update_FromSql_set_constant(bool async) AssertExecuteUpdateSql(); } + public override async Task Update_with_select_mixed_entity_scalar_anonymous_projection(bool async) + { + await base.Update_with_select_mixed_entity_scalar_anonymous_projection(async); + + AssertSql( + """ +@p='Updated' + +UPDATE "Customers" AS c +SET "ContactName" = @p +"""); + } + + public override async Task Update_with_select_scalar_anonymous_projection(bool async) + { + await base.Update_with_select_scalar_anonymous_projection(async); + + AssertSql( + """ +@p='Updated' + +UPDATE "Customers" AS c +SET "ContactName" = @p +"""); + } + public override async Task Update_Where_SelectMany_subquery_set_null(bool async) { await base.Update_Where_SelectMany_subquery_set_null(async); diff --git a/test/EFCore.PG.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonProjectionNpgsqlTest.cs index 1004c7a988..e24d493162 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Associations/ComplexJson/ComplexJsonProjectionNpgsqlTest.cs @@ -317,6 +317,24 @@ LIMIT 1 """); } + public override async Task Select_subquery_FirstOrDefault_complex_collection(QueryTrackingBehavior queryTrackingBehavior) + { + await base.Select_subquery_FirstOrDefault_complex_collection(queryTrackingBehavior); + + AssertSql( + """ +SELECT r1.c, r1.c0 +FROM "RootEntity" AS r +LEFT JOIN LATERAL ( + SELECT r0."AssociateCollection" AS c, 1 AS c0 + FROM "RootEntity" AS r0 + ORDER BY r0."Id" NULLS FIRST + LIMIT 1 +) AS r1 ON TRUE +ORDER BY r."Id" NULLS FIRST +"""); + } + #endregion Subquery #region Value types diff --git a/test/EFCore.PG.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingProjectionNpgsqlTest.cs index 87a40359b1..0cc07b6f57 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingProjectionNpgsqlTest.cs @@ -286,6 +286,24 @@ LIMIT 1 """); } + public override async Task Select_subquery_FirstOrDefault_complex_collection(QueryTrackingBehavior queryTrackingBehavior) + { + await base.Select_subquery_FirstOrDefault_complex_collection(queryTrackingBehavior); + + AssertSql( + """ +SELECT r1."Id", r1."Name", r1."OptionalAssociate_Id", r1."OptionalAssociate_Int", r1."OptionalAssociate_Ints", r1."OptionalAssociate_Name", r1."OptionalAssociate_String", r1."OptionalAssociate_OptionalNestedAssociate_Id", r1."OptionalAssociate_OptionalNestedAssociate_Int", r1."OptionalAssociate_OptionalNestedAssociate_Ints", r1."OptionalAssociate_OptionalNestedAssociate_Name", r1."OptionalAssociate_OptionalNestedAssociate_String", r1."OptionalAssociate_RequiredNestedAssociate_Id", r1."OptionalAssociate_RequiredNestedAssociate_Int", r1."OptionalAssociate_RequiredNestedAssociate_Ints", r1."OptionalAssociate_RequiredNestedAssociate_Name", r1."OptionalAssociate_RequiredNestedAssociate_String", r1."RequiredAssociate_Id", r1."RequiredAssociate_Int", r1."RequiredAssociate_Ints", r1."RequiredAssociate_Name", r1."RequiredAssociate_String", r1."RequiredAssociate_OptionalNestedAssociate_Id", r1."RequiredAssociate_OptionalNestedAssociate_Int", r1."RequiredAssociate_OptionalNestedAssociate_Ints", r1."RequiredAssociate_OptionalNestedAssociate_Name", r1."RequiredAssociate_OptionalNestedAssociate_String", r1."RequiredAssociate_RequiredNestedAssociate_Id", r1."RequiredAssociate_RequiredNestedAssociate_Int", r1."RequiredAssociate_RequiredNestedAssociate_Ints", r1."RequiredAssociate_RequiredNestedAssociate_Name", r1."RequiredAssociate_RequiredNestedAssociate_String", r1.c +FROM "RootEntity" AS r +LEFT JOIN LATERAL ( + SELECT r0."Id", r0."Name", r0."OptionalAssociate_Id", r0."OptionalAssociate_Int", r0."OptionalAssociate_Ints", r0."OptionalAssociate_Name", r0."OptionalAssociate_String", r0."OptionalAssociate_OptionalNestedAssociate_Id", r0."OptionalAssociate_OptionalNestedAssociate_Int", r0."OptionalAssociate_OptionalNestedAssociate_Ints", r0."OptionalAssociate_OptionalNestedAssociate_Name", r0."OptionalAssociate_OptionalNestedAssociate_String", r0."OptionalAssociate_RequiredNestedAssociate_Id", r0."OptionalAssociate_RequiredNestedAssociate_Int", r0."OptionalAssociate_RequiredNestedAssociate_Ints", r0."OptionalAssociate_RequiredNestedAssociate_Name", r0."OptionalAssociate_RequiredNestedAssociate_String", r0."RequiredAssociate_Id", r0."RequiredAssociate_Int", r0."RequiredAssociate_Ints", r0."RequiredAssociate_Name", r0."RequiredAssociate_String", r0."RequiredAssociate_OptionalNestedAssociate_Id", r0."RequiredAssociate_OptionalNestedAssociate_Int", r0."RequiredAssociate_OptionalNestedAssociate_Ints", r0."RequiredAssociate_OptionalNestedAssociate_Name", r0."RequiredAssociate_OptionalNestedAssociate_String", r0."RequiredAssociate_RequiredNestedAssociate_Id", r0."RequiredAssociate_RequiredNestedAssociate_Int", r0."RequiredAssociate_RequiredNestedAssociate_Ints", r0."RequiredAssociate_RequiredNestedAssociate_Name", r0."RequiredAssociate_RequiredNestedAssociate_String", 1 AS c + FROM "RootEntity" AS r0 + ORDER BY r0."Id" NULLS FIRST + LIMIT 1 +) AS r1 ON TRUE +ORDER BY r."Id" NULLS FIRST +"""); + } + #endregion Subquery #region Value types diff --git a/test/EFCore.PG.FunctionalTests/Query/Associations/Navigations/NavigationsProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Associations/Navigations/NavigationsProjectionNpgsqlTest.cs index c3252acd00..f300d2e842 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Associations/Navigations/NavigationsProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Associations/Navigations/NavigationsProjectionNpgsqlTest.cs @@ -391,6 +391,31 @@ LIMIT 1 """); } + public override async Task Select_subquery_FirstOrDefault_complex_collection(QueryTrackingBehavior queryTrackingBehavior) + { + await base.Select_subquery_FirstOrDefault_complex_collection(queryTrackingBehavior); + + AssertSql( + """ +SELECT r."Id", r1."Id", s."Id", s."CollectionRootId", s."Int", s."Ints", s."Name", s."OptionalNestedAssociateId", s."RequiredNestedAssociateId", s."String", s."Id0", s."Id1", s."Id2", s."CollectionAssociateId", s."Int0", s."Ints0", s."Name0", s."String0", s."CollectionAssociateId0", s."Int1", s."Ints1", s."Name1", s."String1", s."CollectionAssociateId1", s."Int2", s."Ints2", s."Name2", s."String2", r1.c +FROM "RootEntity" AS r +LEFT JOIN LATERAL ( + SELECT 1 AS c, r0."Id" + FROM "RootEntity" AS r0 + ORDER BY r0."Id" NULLS FIRST + LIMIT 1 +) AS r1 ON TRUE +LEFT JOIN ( + SELECT a."Id", a."CollectionRootId", a."Int", a."Ints", a."Name", a."OptionalNestedAssociateId", a."RequiredNestedAssociateId", a."String", n."Id" AS "Id0", n0."Id" AS "Id1", n1."Id" AS "Id2", n1."CollectionAssociateId", n1."Int" AS "Int0", n1."Ints" AS "Ints0", n1."Name" AS "Name0", n1."String" AS "String0", n."CollectionAssociateId" AS "CollectionAssociateId0", n."Int" AS "Int1", n."Ints" AS "Ints1", n."Name" AS "Name1", n."String" AS "String1", n0."CollectionAssociateId" AS "CollectionAssociateId1", n0."Int" AS "Int2", n0."Ints" AS "Ints2", n0."Name" AS "Name2", n0."String" AS "String2" + FROM "AssociateType" AS a + LEFT JOIN "NestedAssociateType" AS n ON a."OptionalNestedAssociateId" = n."Id" + INNER JOIN "NestedAssociateType" AS n0 ON a."RequiredNestedAssociateId" = n0."Id" + LEFT JOIN "NestedAssociateType" AS n1 ON a."Id" = n1."CollectionAssociateId" +) AS s ON r1."Id" = s."CollectionRootId" +ORDER BY r."Id" NULLS FIRST, r1."Id" NULLS FIRST, s."Id" NULLS FIRST, s."Id0" NULLS FIRST, s."Id1" NULLS FIRST +"""); + } + #endregion Subquery [ConditionalFact] diff --git a/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedJson/OwnedJsonProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedJson/OwnedJsonProjectionNpgsqlTest.cs index 26200c5a46..0788e90091 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedJson/OwnedJsonProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedJson/OwnedJsonProjectionNpgsqlTest.cs @@ -365,6 +365,27 @@ LIMIT 1 } } + public override async Task Select_subquery_FirstOrDefault_complex_collection(QueryTrackingBehavior queryTrackingBehavior) + { + await base.Select_subquery_FirstOrDefault_complex_collection(queryTrackingBehavior); + + if (queryTrackingBehavior is not QueryTrackingBehavior.TrackAll) + { + AssertSql( + """ +SELECT r1.c, r1."Id", r1.c0 +FROM "RootEntity" AS r +LEFT JOIN LATERAL ( + SELECT r0."AssociateCollection" AS c, r0."Id", 1 AS c0 + FROM "RootEntity" AS r0 + ORDER BY r0."Id" NULLS FIRST + LIMIT 1 +) AS r1 ON TRUE +ORDER BY r."Id" NULLS FIRST +"""); + } + } + #endregion Subquery [ConditionalFact] diff --git a/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsProjectionNpgsqlTest.cs index 24c01fda7d..d2e2c13609 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsProjectionNpgsqlTest.cs @@ -439,6 +439,34 @@ LIMIT 1 } } + public override async Task Select_subquery_FirstOrDefault_complex_collection(QueryTrackingBehavior queryTrackingBehavior) + { + await base.Select_subquery_FirstOrDefault_complex_collection(queryTrackingBehavior); + + if (queryTrackingBehavior is not QueryTrackingBehavior.TrackAll) + { + AssertSql( + """ +SELECT r."Id", r5."Id", s."RootEntityId", s."Id", s."Int", s."Ints", s."Name", s."String", s."AssociateTypeRootEntityId", s."AssociateTypeId", s."AssociateTypeRootEntityId0", s."AssociateTypeId0", s."AssociateTypeRootEntityId1", s."AssociateTypeId1", s."Id0", s."Int0", s."Ints0", s."Name0", s."String0", s."Id1", s."Int1", s."Ints1", s."Name1", s."String1", s."Id2", s."Int2", s."Ints2", s."Name2", s."String2", r5.c +FROM "RootEntity" AS r +LEFT JOIN LATERAL ( + SELECT 1 AS c, r0."Id" + FROM "RootEntity" AS r0 + ORDER BY r0."Id" NULLS FIRST + LIMIT 1 +) AS r5 ON TRUE +LEFT JOIN ( + SELECT r1."RootEntityId", r1."Id", r1."Int", r1."Ints", r1."Name", r1."String", r2."AssociateTypeRootEntityId", r2."AssociateTypeId", r3."AssociateTypeRootEntityId" AS "AssociateTypeRootEntityId0", r3."AssociateTypeId" AS "AssociateTypeId0", r4."AssociateTypeRootEntityId" AS "AssociateTypeRootEntityId1", r4."AssociateTypeId" AS "AssociateTypeId1", r4."Id" AS "Id0", r4."Int" AS "Int0", r4."Ints" AS "Ints0", r4."Name" AS "Name0", r4."String" AS "String0", r2."Id" AS "Id1", r2."Int" AS "Int1", r2."Ints" AS "Ints1", r2."Name" AS "Name1", r2."String" AS "String1", r3."Id" AS "Id2", r3."Int" AS "Int2", r3."Ints" AS "Ints2", r3."Name" AS "Name2", r3."String" AS "String2" + FROM "RelatedCollection" AS r1 + LEFT JOIN "RelatedCollection_OptionalNested" AS r2 ON r1."RootEntityId" = r2."AssociateTypeRootEntityId" AND r1."Id" = r2."AssociateTypeId" + LEFT JOIN "RelatedCollection_RequiredNested" AS r3 ON r1."RootEntityId" = r3."AssociateTypeRootEntityId" AND r1."Id" = r3."AssociateTypeId" + LEFT JOIN "RelatedCollection_NestedCollection" AS r4 ON r1."RootEntityId" = r4."AssociateTypeRootEntityId" AND r1."Id" = r4."AssociateTypeId" +) AS s ON r5."Id" = s."RootEntityId" +ORDER BY r."Id" NULLS FIRST, r5."Id" NULLS FIRST, s."RootEntityId" NULLS FIRST, s."Id" NULLS FIRST, s."AssociateTypeRootEntityId" NULLS FIRST, s."AssociateTypeId" NULLS FIRST, s."AssociateTypeRootEntityId0" NULLS FIRST, s."AssociateTypeId0" NULLS FIRST, s."AssociateTypeRootEntityId1" NULLS FIRST, s."AssociateTypeId1" NULLS FIRST +"""); + } + } + #endregion Subquery [ConditionalFact] diff --git a/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingProjectionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingProjectionNpgsqlTest.cs index 4000b9bb61..e8d2ed39b0 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingProjectionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingProjectionNpgsqlTest.cs @@ -396,6 +396,32 @@ LIMIT 1 } } + public override async Task Select_subquery_FirstOrDefault_complex_collection(QueryTrackingBehavior queryTrackingBehavior) + { + await base.Select_subquery_FirstOrDefault_complex_collection(queryTrackingBehavior); + + if (queryTrackingBehavior is not QueryTrackingBehavior.TrackAll) + { + AssertSql( + """ +SELECT r."Id", r3."Id", s."RootEntityId", s."Id", s."Int", s."Ints", s."Name", s."String", s."AssociateTypeRootEntityId", s."AssociateTypeId", s."Id0", s."Int0", s."Ints0", s."Name0", s."String0", s."OptionalNestedAssociate_Id", s."OptionalNestedAssociate_Int", s."OptionalNestedAssociate_Ints", s."OptionalNestedAssociate_Name", s."OptionalNestedAssociate_String", s."RequiredNestedAssociate_Id", s."RequiredNestedAssociate_Int", s."RequiredNestedAssociate_Ints", s."RequiredNestedAssociate_Name", s."RequiredNestedAssociate_String", r3.c +FROM "RootEntity" AS r +LEFT JOIN LATERAL ( + SELECT 1 AS c, r0."Id" + FROM "RootEntity" AS r0 + ORDER BY r0."Id" NULLS FIRST + LIMIT 1 +) AS r3 ON TRUE +LEFT JOIN ( + SELECT r1."RootEntityId", r1."Id", r1."Int", r1."Ints", r1."Name", r1."String", r2."AssociateTypeRootEntityId", r2."AssociateTypeId", r2."Id" AS "Id0", r2."Int" AS "Int0", r2."Ints" AS "Ints0", r2."Name" AS "Name0", r2."String" AS "String0", r1."OptionalNestedAssociate_Id", r1."OptionalNestedAssociate_Int", r1."OptionalNestedAssociate_Ints", r1."OptionalNestedAssociate_Name", r1."OptionalNestedAssociate_String", r1."RequiredNestedAssociate_Id", r1."RequiredNestedAssociate_Int", r1."RequiredNestedAssociate_Ints", r1."RequiredNestedAssociate_Name", r1."RequiredNestedAssociate_String" + FROM "RelatedCollection" AS r1 + LEFT JOIN "RelatedCollection_NestedCollection" AS r2 ON r1."RootEntityId" = r2."AssociateTypeRootEntityId" AND r1."Id" = r2."AssociateTypeId" +) AS s ON r3."Id" = s."RootEntityId" +ORDER BY r."Id" NULLS FIRST, r3."Id" NULLS FIRST, s."RootEntityId" NULLS FIRST, s."Id" NULLS FIRST, s."AssociateTypeRootEntityId" NULLS FIRST, s."AssociateTypeId" NULLS FIRST +"""); + } + } + #endregion Subquery [ConditionalFact] diff --git a/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs index 381b0370e1..880d1671a0 100644 --- a/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs @@ -773,6 +773,18 @@ public override async Task Tpc_entity_owning_a_split_collection_on_leaf(bool asy AssertSql(); } + public override async Task Compare_split_entity_to_null(bool async) + { + await base.Compare_split_entity_to_null(async); + + AssertSql( + """ +SELECT e."Id", e."EntityThreeId", e."IntValue1", e."IntValue2", s."IntValue3", e."IntValue4", e."StringValue1", e."StringValue2", e."StringValue3", e."StringValue4" +FROM "EntityOne" AS e +INNER JOIN "SplitEntityOnePart" AS s ON e."Id" = s."Id" +"""); + } + protected override ITestStoreFactory TestStoreFactory => NpgsqlTestStoreFactory.Instance; } diff --git a/test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs index dd9fb2eae2..b21bcc3be3 100644 --- a/test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs @@ -670,6 +670,21 @@ WHERE NOT (p."NullableInt" = ANY (@nullableInts) AND p."NullableInt" = ANY (@nul """); } + public override async Task Parameter_collection_of_nullable_ints_Contains_nullable_int_with_EF_Parameter() + { + await base.Parameter_collection_of_nullable_ints_Contains_nullable_int_with_EF_Parameter(); + + AssertSql( + """ +@nullableInts={ NULL +'999' } (DbType = Object) + +SELECT p."Id", p."Bool", p."Bools", p."DateTime", p."DateTimes", p."Enum", p."Enums", p."Int", p."Ints", p."NullableInt", p."NullableInts", p."NullableString", p."NullableStrings", p."NullableWrappedId", p."NullableWrappedIdWithNullableComparer", p."String", p."Strings", p."WrappedId" +FROM "PrimitiveCollectionsEntity" AS p +WHERE p."NullableInt" = ANY (@nullableInts) OR (p."NullableInt" IS NULL AND array_position(@nullableInts, NULL) IS NOT NULL) +"""); + } + public override async Task Parameter_collection_of_structs_Contains_struct() { await base.Parameter_collection_of_structs_Contains_struct();