Skip to content

Commit 2b5d63e

Browse files
committed
Test fixes for 8.0.x sync
1 parent d856230 commit 2b5d63e

File tree

3 files changed

+143
-12
lines changed

3 files changed

+143
-12
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
2+
3+
namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query;
4+
5+
public class AdHocComplexTypeQueryNpgsqlTest : AdHocComplexTypeQueryTestBase
6+
{
7+
public override async Task Complex_type_equals_parameter_with_nested_types_with_property_of_same_name()
8+
{
9+
await base.Complex_type_equals_parameter_with_nested_types_with_property_of_same_name();
10+
11+
AssertSql(
12+
"""
13+
@__entity_equality_container_0_Id='1' (Nullable = true)
14+
@__entity_equality_container_0_Containee1_Id='2' (Nullable = true)
15+
@__entity_equality_container_0_Containee2_Id='3' (Nullable = true)
16+
17+
SELECT e."Id", e."ComplexContainer_Id", e."ComplexContainer_Containee1_Id", e."ComplexContainer_Containee2_Id"
18+
FROM "EntityType" AS e
19+
WHERE e."ComplexContainer_Id" = @__entity_equality_container_0_Id AND e."ComplexContainer_Containee1_Id" = @__entity_equality_container_0_Containee1_Id AND e."ComplexContainer_Containee2_Id" = @__entity_equality_container_0_Containee2_Id
20+
LIMIT 2
21+
""");
22+
}
23+
24+
protected TestSqlLoggerFactory TestSqlLoggerFactory
25+
=> (TestSqlLoggerFactory)ListLoggerFactory;
26+
27+
protected void AssertSql(params string[] expected)
28+
=> TestSqlLoggerFactory.AssertBaseline(expected);
29+
30+
protected override ITestStoreFactory TestStoreFactory
31+
=> NpgsqlTestStoreFactory.Instance;
32+
}

test/EFCore.PG.FunctionalTests/Query/ComplexTypeQueryNpgsqlTest.cs

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,12 @@ public override async Task Complex_type_equals_parameter(bool async)
230230
"""
231231
@__entity_equality_address_0_AddressLine1='804 S. Lakeshore Road'
232232
@__entity_equality_address_0_ZipCode='38654' (Nullable = true)
233-
@__entity_equality_address_0_Code='US'
234-
@__entity_equality_address_0_FullName='United States'
233+
@__entity_equality_address_0_Country_Code='US'
234+
@__entity_equality_address_0_Country_FullName='United States'
235235
236236
SELECT c."Id", c."Name", c."BillingAddress_AddressLine1", c."BillingAddress_AddressLine2", c."BillingAddress_ZipCode", c."BillingAddress_Country_Code", c."BillingAddress_Country_FullName", c."ShippingAddress_AddressLine1", c."ShippingAddress_AddressLine2", c."ShippingAddress_ZipCode", c."ShippingAddress_Country_Code", c."ShippingAddress_Country_FullName"
237237
FROM "Customer" AS c
238-
WHERE c."ShippingAddress_AddressLine1" = @__entity_equality_address_0_AddressLine1 AND c."ShippingAddress_AddressLine2" IS NULL AND c."ShippingAddress_ZipCode" = @__entity_equality_address_0_ZipCode AND c."ShippingAddress_Country_Code" = @__entity_equality_address_0_Code AND c."ShippingAddress_Country_FullName" = @__entity_equality_address_0_FullName
238+
WHERE c."ShippingAddress_AddressLine1" = @__entity_equality_address_0_AddressLine1 AND c."ShippingAddress_AddressLine2" IS NULL AND c."ShippingAddress_ZipCode" = @__entity_equality_address_0_ZipCode AND c."ShippingAddress_Country_Code" = @__entity_equality_address_0_Country_Code AND c."ShippingAddress_Country_FullName" = @__entity_equality_address_0_Country_FullName
239239
""");
240240
}
241241

@@ -261,15 +261,15 @@ public override async Task Contains_over_complex_type(bool async)
261261
"""
262262
@__entity_equality_address_0_AddressLine1='804 S. Lakeshore Road'
263263
@__entity_equality_address_0_ZipCode='38654' (Nullable = true)
264-
@__entity_equality_address_0_Code='US'
265-
@__entity_equality_address_0_FullName='United States'
264+
@__entity_equality_address_0_Country_Code='US'
265+
@__entity_equality_address_0_Country_FullName='United States'
266266
267267
SELECT c."Id", c."Name", c."BillingAddress_AddressLine1", c."BillingAddress_AddressLine2", c."BillingAddress_ZipCode", c."BillingAddress_Country_Code", c."BillingAddress_Country_FullName", c."ShippingAddress_AddressLine1", c."ShippingAddress_AddressLine2", c."ShippingAddress_ZipCode", c."ShippingAddress_Country_Code", c."ShippingAddress_Country_FullName"
268268
FROM "Customer" AS c
269269
WHERE EXISTS (
270270
SELECT 1
271271
FROM "Customer" AS c0
272-
WHERE c0."ShippingAddress_AddressLine1" = @__entity_equality_address_0_AddressLine1 AND c0."ShippingAddress_AddressLine2" IS NULL AND c0."ShippingAddress_ZipCode" = @__entity_equality_address_0_ZipCode AND c0."ShippingAddress_Country_Code" = @__entity_equality_address_0_Code AND c0."ShippingAddress_Country_FullName" = @__entity_equality_address_0_FullName)
272+
WHERE c0."ShippingAddress_AddressLine1" = @__entity_equality_address_0_AddressLine1 AND c0."ShippingAddress_AddressLine2" IS NULL AND c0."ShippingAddress_ZipCode" = @__entity_equality_address_0_ZipCode AND c0."ShippingAddress_Country_Code" = @__entity_equality_address_0_Country_Code AND c0."ShippingAddress_Country_FullName" = @__entity_equality_address_0_Country_FullName)
273273
""");
274274
}
275275

@@ -598,12 +598,12 @@ public override async Task Struct_complex_type_equals_parameter(bool async)
598598
"""
599599
@__entity_equality_address_0_AddressLine1='804 S. Lakeshore Road'
600600
@__entity_equality_address_0_ZipCode='38654' (Nullable = true)
601-
@__entity_equality_address_0_Code='US'
602-
@__entity_equality_address_0_FullName='United States'
601+
@__entity_equality_address_0_Country_Code='US'
602+
@__entity_equality_address_0_Country_FullName='United States'
603603
604604
SELECT v."Id", v."Name", v."BillingAddress_AddressLine1", v."BillingAddress_AddressLine2", v."BillingAddress_ZipCode", v."BillingAddress_Country_Code", v."BillingAddress_Country_FullName", v."ShippingAddress_AddressLine1", v."ShippingAddress_AddressLine2", v."ShippingAddress_ZipCode", v."ShippingAddress_Country_Code", v."ShippingAddress_Country_FullName"
605605
FROM "ValuedCustomer" AS v
606-
WHERE v."ShippingAddress_AddressLine1" = @__entity_equality_address_0_AddressLine1 AND v."ShippingAddress_AddressLine2" IS NULL AND v."ShippingAddress_ZipCode" = @__entity_equality_address_0_ZipCode AND v."ShippingAddress_Country_Code" = @__entity_equality_address_0_Code AND v."ShippingAddress_Country_FullName" = @__entity_equality_address_0_FullName
606+
WHERE v."ShippingAddress_AddressLine1" = @__entity_equality_address_0_AddressLine1 AND v."ShippingAddress_AddressLine2" IS NULL AND v."ShippingAddress_ZipCode" = @__entity_equality_address_0_ZipCode AND v."ShippingAddress_Country_Code" = @__entity_equality_address_0_Country_Code AND v."ShippingAddress_Country_FullName" = @__entity_equality_address_0_Country_FullName
607607
""");
608608
}
609609

@@ -622,15 +622,15 @@ public override async Task Contains_over_struct_complex_type(bool async)
622622
"""
623623
@__entity_equality_address_0_AddressLine1='804 S. Lakeshore Road'
624624
@__entity_equality_address_0_ZipCode='38654' (Nullable = true)
625-
@__entity_equality_address_0_Code='US'
626-
@__entity_equality_address_0_FullName='United States'
625+
@__entity_equality_address_0_Country_Code='US'
626+
@__entity_equality_address_0_Country_FullName='United States'
627627
628628
SELECT v."Id", v."Name", v."BillingAddress_AddressLine1", v."BillingAddress_AddressLine2", v."BillingAddress_ZipCode", v."BillingAddress_Country_Code", v."BillingAddress_Country_FullName", v."ShippingAddress_AddressLine1", v."ShippingAddress_AddressLine2", v."ShippingAddress_ZipCode", v."ShippingAddress_Country_Code", v."ShippingAddress_Country_FullName"
629629
FROM "ValuedCustomer" AS v
630630
WHERE EXISTS (
631631
SELECT 1
632632
FROM "ValuedCustomer" AS v0
633-
WHERE v0."ShippingAddress_AddressLine1" = @__entity_equality_address_0_AddressLine1 AND v0."ShippingAddress_AddressLine2" IS NULL AND v0."ShippingAddress_ZipCode" = @__entity_equality_address_0_ZipCode AND v0."ShippingAddress_Country_Code" = @__entity_equality_address_0_Code AND v0."ShippingAddress_Country_FullName" = @__entity_equality_address_0_FullName)
633+
WHERE v0."ShippingAddress_AddressLine1" = @__entity_equality_address_0_AddressLine1 AND v0."ShippingAddress_AddressLine2" IS NULL AND v0."ShippingAddress_ZipCode" = @__entity_equality_address_0_ZipCode AND v0."ShippingAddress_Country_Code" = @__entity_equality_address_0_Country_Code AND v0."ShippingAddress_Country_FullName" = @__entity_equality_address_0_Country_FullName)
634634
""");
635635
}
636636

@@ -1014,6 +1014,75 @@ LIMIT 1
10141014
""");
10151015
}
10161016

1017+
public override async Task Projecting_property_of_complex_type_using_left_join_with_pushdown(bool async)
1018+
{
1019+
await base.Projecting_property_of_complex_type_using_left_join_with_pushdown(async);
1020+
1021+
AssertSql(
1022+
"""
1023+
SELECT t."BillingAddress_ZipCode"
1024+
FROM "CustomerGroup" AS c
1025+
LEFT JOIN (
1026+
SELECT c0."Id", c0."BillingAddress_ZipCode"
1027+
FROM "Customer" AS c0
1028+
WHERE c0."Id" > 5
1029+
) AS t ON c."Id" = t."Id"
1030+
""");
1031+
}
1032+
1033+
public override async Task Projecting_complex_from_optional_navigation_using_conditional(bool async)
1034+
{
1035+
await base.Projecting_complex_from_optional_navigation_using_conditional(async);
1036+
1037+
AssertSql(
1038+
"""
1039+
@__p_0='20'
1040+
1041+
SELECT t0."ShippingAddress_ZipCode"
1042+
FROM (
1043+
SELECT DISTINCT t."ShippingAddress_AddressLine1", t."ShippingAddress_AddressLine2", t."ShippingAddress_ZipCode", t."ShippingAddress_Country_Code", t."ShippingAddress_Country_FullName"
1044+
FROM (
1045+
SELECT c0."ShippingAddress_AddressLine1", c0."ShippingAddress_AddressLine2", c0."ShippingAddress_ZipCode", c0."ShippingAddress_Country_Code", c0."ShippingAddress_Country_FullName"
1046+
FROM "CustomerGroup" AS c
1047+
LEFT JOIN "Customer" AS c0 ON c."OptionalCustomerId" = c0."Id"
1048+
ORDER BY c0."ShippingAddress_ZipCode" NULLS FIRST
1049+
LIMIT @__p_0
1050+
) AS t
1051+
) AS t0
1052+
""");
1053+
}
1054+
1055+
public override async Task Project_entity_with_complex_type_pushdown_and_then_left_join(bool async)
1056+
{
1057+
await base.Project_entity_with_complex_type_pushdown_and_then_left_join(async);
1058+
1059+
AssertSql(
1060+
"""
1061+
@__p_0='20'
1062+
@__p_1='30'
1063+
1064+
SELECT t0."BillingAddress_ZipCode" AS "Zip1", t1."ShippingAddress_ZipCode" AS "Zip2"
1065+
FROM (
1066+
SELECT DISTINCT t."Id", t."Name", t."BillingAddress_AddressLine1", t."BillingAddress_AddressLine2", t."BillingAddress_ZipCode", t."BillingAddress_Country_Code", t."BillingAddress_Country_FullName", t."ShippingAddress_AddressLine1", t."ShippingAddress_AddressLine2", t."ShippingAddress_ZipCode", t."ShippingAddress_Country_Code", t."ShippingAddress_Country_FullName"
1067+
FROM (
1068+
SELECT c."Id", c."Name", c."BillingAddress_AddressLine1", c."BillingAddress_AddressLine2", c."BillingAddress_ZipCode", c."BillingAddress_Country_Code", c."BillingAddress_Country_FullName", c."ShippingAddress_AddressLine1", c."ShippingAddress_AddressLine2", c."ShippingAddress_ZipCode", c."ShippingAddress_Country_Code", c."ShippingAddress_Country_FullName"
1069+
FROM "Customer" AS c
1070+
ORDER BY c."Id" NULLS FIRST
1071+
LIMIT @__p_0
1072+
) AS t
1073+
) AS t0
1074+
LEFT JOIN (
1075+
SELECT DISTINCT t2."Id", t2."Name", t2."BillingAddress_AddressLine1", t2."BillingAddress_AddressLine2", t2."BillingAddress_ZipCode", t2."BillingAddress_Country_Code", t2."BillingAddress_Country_FullName", t2."ShippingAddress_AddressLine1", t2."ShippingAddress_AddressLine2", t2."ShippingAddress_ZipCode", t2."ShippingAddress_Country_Code", t2."ShippingAddress_Country_FullName"
1076+
FROM (
1077+
SELECT c0."Id", c0."Name", c0."BillingAddress_AddressLine1", c0."BillingAddress_AddressLine2", c0."BillingAddress_ZipCode", c0."BillingAddress_Country_Code", c0."BillingAddress_Country_FullName", c0."ShippingAddress_AddressLine1", c0."ShippingAddress_AddressLine2", c0."ShippingAddress_ZipCode", c0."ShippingAddress_Country_Code", c0."ShippingAddress_Country_FullName"
1078+
FROM "Customer" AS c0
1079+
ORDER BY c0."Id" DESC NULLS LAST
1080+
LIMIT @__p_1
1081+
) AS t2
1082+
) AS t1 ON t0."Id" = t1."Id"
1083+
""");
1084+
}
1085+
10171086
public override async Task Same_complex_type_projected_twice_with_pushdown_as_part_of_another_projection(bool async)
10181087
{
10191088
await base.Same_complex_type_projected_twice_with_pushdown_as_part_of_another_projection(async);

test/EFCore.PG.FunctionalTests/Query/PrimitiveCollectionsQueryNpgsqlTest.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,36 @@ WHERE cardinality(p."Ints") = 2
596596
""");
597597
}
598598

599+
public override async Task Column_collection_Count_with_predicate(bool async)
600+
{
601+
await base.Column_collection_Count_with_predicate(async);
602+
603+
AssertSql(
604+
"""
605+
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."String", p."Strings"
606+
FROM "PrimitiveCollectionsEntity" AS p
607+
WHERE (
608+
SELECT count(*)::int
609+
FROM unnest(p."Ints") AS i(value)
610+
WHERE i.value > 1) = 2
611+
""");
612+
}
613+
614+
public override async Task Column_collection_Where_Count(bool async)
615+
{
616+
await base.Column_collection_Where_Count(async);
617+
618+
AssertSql(
619+
"""
620+
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."String", p."Strings"
621+
FROM "PrimitiveCollectionsEntity" AS p
622+
WHERE (
623+
SELECT count(*)::int
624+
FROM unnest(p."Ints") AS i(value)
625+
WHERE i.value > 1) = 2
626+
""");
627+
}
628+
599629
public override async Task Column_collection_index_int(bool async)
600630
{
601631
await base.Column_collection_index_int(async);

0 commit comments

Comments
 (0)