From 95aa5c44dbdf1777efd691db4df8d68a72502641 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Sat, 15 Oct 2022 21:20:23 +0200 Subject: [PATCH] Remove IS NULL parentheses hack (#2534) (leaving the one on the EF side) Closes #2105 --- .../Query/Internal/NpgsqlQuerySqlGenerator.cs | 15 ------- .../NonSharedModelBulkUpdatesNpgsqlTest.cs | 2 +- .../NorthwindBulkUpdatesNpgsqlTest.cs | 12 +++--- ...FiltersInheritanceBulkUpdatesNpgsqlTest.cs | 4 +- .../TPTInheritanceBulkUpdatesNpgsqlTest.cs | 2 +- .../Query/ArrayArrayQueryTest.cs | 18 ++++----- .../Query/ArrayListQueryTest.cs | 18 ++++----- .../Query/CitextQueryTest.cs | 12 +++--- .../Query/Ef6GroupByNpgsqlTest.cs | 8 ++-- .../Query/EntitySplittingQueryNpgsqlTest.cs | 22 +++++----- .../Query/JsonDomQueryTest.cs | 2 +- .../Query/JsonPocoQueryTest.cs | 4 +- .../Query/NetworkQueryNpgsqlTest.cs | 6 +-- .../NorthwindFunctionsQueryNpgsqlTest.cs | 2 +- .../Query/NorthwindGroupByQueryNpgsqlTest.cs | 40 +++++++++---------- .../NorthwindMiscellaneousQueryNpgsqlTest.cs | 10 ++--- .../NorthwindSetOperationsQueryNpgsqlTest.cs | 4 +- .../Query/SpatialQueryNpgsqlGeographyTest.cs | 2 +- .../Query/SpatialQueryNpgsqlGeometryTest.cs | 10 ++--- 19 files changed, 89 insertions(+), 104 deletions(-) diff --git a/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs b/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs index 852599269..995c2717b 100644 --- a/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs +++ b/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs @@ -478,21 +478,6 @@ protected override Expression VisitSqlUnary(SqlUnaryExpression sqlUnaryExpressio Sql.Append("!!"); Visit(sqlUnaryExpression.Operand); return sqlUnaryExpression; - - // EF uses unary Equal and NotEqual to represent is-null checking. - // These need to be surrounded in parentheses in various cases (e.g. where TRUE = x IS NOT NULL), - // see - case ExpressionType.Equal: - Sql.Append("("); - Visit(sqlUnaryExpression.Operand); - Sql.Append(" IS NULL)"); - return sqlUnaryExpression; - - case ExpressionType.NotEqual: - Sql.Append("("); - Visit(sqlUnaryExpression.Operand); - Sql.Append(" IS NOT NULL)"); - return sqlUnaryExpression; } return base.VisitSqlUnary(sqlUnaryExpression); diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs index 886252bba..bc88b2407 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs @@ -52,7 +52,7 @@ WHERE EXISTS ( SELECT 1 FROM "Posts" AS p0 LEFT JOIN "Blogs" AS b ON p0."BlogId" = b."Id" - WHERE ((b."Title" IS NOT NULL)) AND (b."Title" LIKE 'Arthur%') AND p0."Id" = p."Id") + WHERE (b."Title" IS NOT NULL) AND (b."Title" LIKE 'Arthur%') AND p0."Id" = p."Id") """); } diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs index 6a5ff76a6..7318cf318 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs @@ -209,7 +209,7 @@ DELETE FROM "Order Details" AS o SELECT ( SELECT o1."OrderID" FROM "Orders" AS o1 - WHERE o0."CustomerID" = o1."CustomerID" OR (((o0."CustomerID" IS NULL)) AND ((o1."CustomerID" IS NULL))) + WHERE o0."CustomerID" = o1."CustomerID" OR ((o0."CustomerID" IS NULL) AND (o1."CustomerID" IS NULL)) LIMIT 1) FROM "Orders" AS o0 GROUP BY o0."CustomerID" @@ -233,7 +233,7 @@ GROUP BY o1."CustomerID" HAVING count(*)::int > 9 AND ( SELECT o2."OrderID" FROM "Orders" AS o2 - WHERE o1."CustomerID" = o2."CustomerID" OR (((o1."CustomerID" IS NULL)) AND ((o2."CustomerID" IS NULL))) + WHERE o1."CustomerID" = o2."CustomerID" OR ((o1."CustomerID" IS NULL) AND (o2."CustomerID" IS NULL)) LIMIT 1) = o0."OrderID") """); } @@ -345,7 +345,7 @@ SELECT 1 FROM "Order Details" AS o0 INNER JOIN "Orders" AS o1 ON o0."OrderID" = o1."OrderID" LEFT JOIN "Customers" AS c ON o1."CustomerID" = c."CustomerID" - WHERE ((c."CustomerID" IS NOT NULL)) AND (c."CustomerID" LIKE 'F%') AND o0."OrderID" = o."OrderID" AND o0."ProductID" = o."ProductID") + WHERE (c."CustomerID" IS NOT NULL) AND (c."CustomerID" LIKE 'F%') AND o0."OrderID" = o."OrderID" AND o0."ProductID" = o."ProductID") """); } @@ -488,7 +488,7 @@ SELECT 1 FROM "Order Details" AS o0 INNER JOIN "Orders" AS o1 ON o0."OrderID" = o1."OrderID" LEFT JOIN "Customers" AS c ON o1."CustomerID" = c."CustomerID" - WHERE ((c."City" IS NOT NULL)) AND (c."City" LIKE 'Se%') AND o0."OrderID" = o."OrderID" AND o0."ProductID" = o."ProductID") + WHERE (c."City" IS NOT NULL) AND (c."City" LIKE 'Se%') AND o0."OrderID" = o."OrderID" AND o0."ProductID" = o."ProductID") """); } @@ -863,7 +863,7 @@ public override async Task Update_Where_GroupBy_First_set_constant(bool async) SELECT ( SELECT o0."CustomerID" FROM "Orders" AS o0 - WHERE o."CustomerID" = o0."CustomerID" OR (((o."CustomerID" IS NULL)) AND ((o0."CustomerID" IS NULL))) + WHERE o."CustomerID" = o0."CustomerID" OR ((o."CustomerID" IS NULL) AND (o0."CustomerID" IS NULL)) LIMIT 1) FROM "Orders" AS o GROUP BY o."CustomerID" @@ -895,7 +895,7 @@ HAVING count(*)::int > 11 AND ( SELECT c0."CustomerID" FROM "Orders" AS o0 LEFT JOIN "Customers" AS c0 ON o0."CustomerID" = c0."CustomerID" - WHERE o."CustomerID" = o0."CustomerID" OR (((o."CustomerID" IS NULL)) AND ((o0."CustomerID" IS NULL))) + WHERE o."CustomerID" = o0."CustomerID" OR ((o."CustomerID" IS NULL) AND (o0."CustomerID" IS NULL)) LIMIT 1) = c."CustomerID") """); } diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs index 7125f7735..b73141b38 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs @@ -58,7 +58,7 @@ SELECT count(*)::int LEFT JOIN "Birds" AS b ON a."Id" = b."Id" LEFT JOIN "Eagle" AS e ON a."Id" = e."Id" LEFT JOIN "Kiwi" AS k ON a."Id" = k."Id" - WHERE a."CountryId" = 1 AND c."Id" = a."CountryId" AND ((k."Id" IS NOT NULL)) AND a."CountryId" > 0) > 0 + WHERE a."CountryId" = 1 AND c."Id" = a."CountryId" AND (k."Id" IS NOT NULL) AND a."CountryId" > 0) > 0 """); } @@ -150,7 +150,7 @@ SELECT count(*)::int LEFT JOIN "Birds" AS b ON a."Id" = b."Id" LEFT JOIN "Eagle" AS e ON a."Id" = e."Id" LEFT JOIN "Kiwi" AS k ON a."Id" = k."Id" - WHERE a."CountryId" = 1 AND c."Id" = a."CountryId" AND ((k."Id" IS NOT NULL)) AND a."CountryId" > 0) > 0 + WHERE a."CountryId" = 1 AND c."Id" = a."CountryId" AND (k."Id" IS NOT NULL) AND a."CountryId" > 0) > 0 """); } diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs index af57fa0e7..94e28f0ab 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs @@ -129,7 +129,7 @@ SELECT count(*)::int LEFT JOIN "Birds" AS b ON a."Id" = b."Id" LEFT JOIN "Eagle" AS e ON a."Id" = e."Id" LEFT JOIN "Kiwi" AS k ON a."Id" = k."Id" - WHERE c."Id" = a."CountryId" AND ((k."Id" IS NOT NULL)) AND a."CountryId" > 0) > 0 + WHERE c."Id" = a."CountryId" AND (k."Id" IS NOT NULL) AND a."CountryId" > 0) > 0 """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/ArrayArrayQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/ArrayArrayQueryTest.cs index 399427812..ae8a93541 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ArrayArrayQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ArrayArrayQueryTest.cs @@ -57,7 +57,7 @@ public override async Task Nullable_value_array_index_compare_to_null(bool async """ SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE (s."NullableIntArray"[3] IS NULL) +WHERE s."NullableIntArray"[3] IS NULL """); } @@ -81,7 +81,7 @@ public override async Task Nullable_reference_array_index_compare_to_null(bool a """ SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE (s."NullableStringArray"[3] IS NULL) +WHERE s."NullableStringArray"[3] IS NULL """); } @@ -232,7 +232,7 @@ public override async Task Array_column_Contains_null_constant(bool async) """ SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE (array_position(s."NullableStringArray", NULL) IS NOT NULL) +WHERE array_position(s."NullableStringArray", NULL) IS NOT NULL """); } @@ -298,7 +298,7 @@ await AssertQuery( SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE s."NullableText" = ANY (@__array_0) OR (((s."NullableText" IS NULL)) AND ((array_position(@__array_0, NULL) IS NOT NULL))) +WHERE s."NullableText" = ANY (@__array_0) OR ((s."NullableText" IS NULL) AND (array_position(@__array_0, NULL) IS NOT NULL)) """); } @@ -353,7 +353,7 @@ public override void Array_param_with_null_Contains_non_nullable_not_found_negat SELECT count(*)::int FROM "SomeEntities" AS s -WHERE NOT (s."NonNullableText" = ANY (@__array_0) AND ((s."NonNullableText" = ANY (@__array_0) IS NOT NULL))) +WHERE NOT (s."NonNullableText" = ANY (@__array_0) AND (s."NonNullableText" = ANY (@__array_0) IS NOT NULL)) """); } @@ -371,7 +371,7 @@ public override void Array_param_with_null_Contains_nullable_not_found() SELECT count(*)::int FROM "SomeEntities" AS s -WHERE s."NullableText" = ANY (@__array_0) OR (((s."NullableText" IS NULL)) AND ((array_position(@__array_0, NULL) IS NOT NULL))) +WHERE s."NullableText" = ANY (@__array_0) OR ((s."NullableText" IS NULL) AND (array_position(@__array_0, NULL) IS NOT NULL)) """); } @@ -389,7 +389,7 @@ public override void Array_param_with_null_Contains_nullable_not_found_negated() SELECT count(*)::int FROM "SomeEntities" AS s -WHERE NOT (s."NullableText" = ANY (@__array_0) AND ((s."NullableText" = ANY (@__array_0) IS NOT NULL))) AND (((s."NullableText" IS NOT NULL)) OR ((array_position(@__array_0, NULL) IS NULL))) +WHERE NOT (s."NullableText" = ANY (@__array_0) AND (s."NullableText" = ANY (@__array_0) IS NOT NULL)) AND ((s."NullableText" IS NOT NULL) OR (array_position(@__array_0, NULL) IS NULL)) """); } @@ -485,7 +485,7 @@ await AssertQuery( SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE s."NullableEnumConvertedToString" = ANY (@__array_0) OR (((s."NullableEnumConvertedToString" IS NULL)) AND ((array_position(@__array_0, NULL) IS NOT NULL))) +WHERE s."NullableEnumConvertedToString" = ANY (@__array_0) OR ((s."NullableEnumConvertedToString" IS NULL) AND (array_position(@__array_0, NULL) IS NOT NULL)) """); } @@ -504,7 +504,7 @@ await AssertQuery( SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE s."NullableEnumConvertedToStringWithNonNullableLambda" = ANY (@__array_0) OR (((s."NullableEnumConvertedToStringWithNonNullableLambda" IS NULL)) AND ((array_position(@__array_0, NULL) IS NOT NULL))) +WHERE s."NullableEnumConvertedToStringWithNonNullableLambda" = ANY (@__array_0) OR ((s."NullableEnumConvertedToStringWithNonNullableLambda" IS NULL) AND (array_position(@__array_0, NULL) IS NOT NULL)) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs index e3d373544..0a0ffb1ec 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs @@ -57,7 +57,7 @@ public override async Task Nullable_value_array_index_compare_to_null(bool async """ SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE (s."NullableIntList"[3] IS NULL) +WHERE s."NullableIntList"[3] IS NULL """); } @@ -81,7 +81,7 @@ public override async Task Nullable_reference_array_index_compare_to_null(bool a """ SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE (s."NullableStringList"[3] IS NULL) +WHERE s."NullableStringList"[3] IS NULL """); } @@ -215,7 +215,7 @@ public override async Task Array_column_Contains_null_constant(bool async) """ SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE (array_position(s."NullableStringList", NULL) IS NOT NULL) +WHERE array_position(s."NullableStringList", NULL) IS NOT NULL """); } @@ -281,7 +281,7 @@ await AssertQuery( SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE s."NullableText" = ANY (@__array_0) OR (((s."NullableText" IS NULL)) AND ((array_position(@__array_0, NULL) IS NOT NULL))) +WHERE s."NullableText" = ANY (@__array_0) OR ((s."NullableText" IS NULL) AND (array_position(@__array_0, NULL) IS NOT NULL)) """); } @@ -347,7 +347,7 @@ public override void Array_param_with_null_Contains_non_nullable_not_found_negat SELECT count(*)::int FROM "SomeEntities" AS s -WHERE NOT (s."NonNullableText" = ANY (@__array_0) AND ((s."NonNullableText" = ANY (@__array_0) IS NOT NULL))) +WHERE NOT (s."NonNullableText" = ANY (@__array_0) AND (s."NonNullableText" = ANY (@__array_0) IS NOT NULL)) """); } @@ -370,7 +370,7 @@ public override void Array_param_with_null_Contains_nullable_not_found() SELECT count(*)::int FROM "SomeEntities" AS s -WHERE s."NullableText" = ANY (@__array_0) OR (((s."NullableText" IS NULL)) AND ((array_position(@__array_0, NULL) IS NOT NULL))) +WHERE s."NullableText" = ANY (@__array_0) OR ((s."NullableText" IS NULL) AND (array_position(@__array_0, NULL) IS NOT NULL)) """); } @@ -393,7 +393,7 @@ public override void Array_param_with_null_Contains_nullable_not_found_negated() SELECT count(*)::int FROM "SomeEntities" AS s -WHERE NOT (s."NullableText" = ANY (@__array_0) AND ((s."NullableText" = ANY (@__array_0) IS NOT NULL))) AND (((s."NullableText" IS NOT NULL)) OR ((array_position(@__array_0, NULL) IS NULL))) +WHERE NOT (s."NullableText" = ANY (@__array_0) AND (s."NullableText" = ANY (@__array_0) IS NOT NULL)) AND ((s."NullableText" IS NOT NULL) OR (array_position(@__array_0, NULL) IS NULL)) """); } @@ -488,7 +488,7 @@ await AssertQuery( SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE s."NullableEnumConvertedToString" = ANY (@__array_0) OR (((s."NullableEnumConvertedToString" IS NULL)) AND ((array_position(@__array_0, NULL) IS NOT NULL))) +WHERE s."NullableEnumConvertedToString" = ANY (@__array_0) OR ((s."NullableEnumConvertedToString" IS NULL) AND (array_position(@__array_0, NULL) IS NOT NULL)) """); } @@ -507,7 +507,7 @@ await AssertQuery( SELECT s."Id", s."ArrayContainerEntityId", s."Byte", s."ByteArray", s."Bytea", s."EnumConvertedToInt", s."EnumConvertedToString", s."IntArray", s."IntList", s."NonNullableText", s."NullableEnumConvertedToString", s."NullableEnumConvertedToStringWithNonNullableLambda", s."NullableIntArray", s."NullableIntList", s."NullableStringArray", s."NullableStringList", s."NullableText", s."StringArray", s."StringList", s."ValueConvertedArray", s."ValueConvertedList", s."Varchar10", s."Varchar15" FROM "SomeEntities" AS s -WHERE s."NullableEnumConvertedToStringWithNonNullableLambda" = ANY (@__array_0) OR (((s."NullableEnumConvertedToStringWithNonNullableLambda" IS NULL)) AND ((array_position(@__array_0, NULL) IS NOT NULL))) +WHERE s."NullableEnumConvertedToStringWithNonNullableLambda" = ANY (@__array_0) OR ((s."NullableEnumConvertedToStringWithNonNullableLambda" IS NULL) AND (array_position(@__array_0, NULL) IS NOT NULL)) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs index d185b8e9a..f09b24aa8 100644 --- a/test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs @@ -29,7 +29,7 @@ public void StartsWith_literal() """ SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE ((s."CaseInsensitiveText" IS NOT NULL)) AND (s."CaseInsensitiveText" LIKE 'some%') +WHERE (s."CaseInsensitiveText" IS NOT NULL) AND (s."CaseInsensitiveText" LIKE 'some%') LIMIT 2 """); } @@ -49,7 +49,7 @@ public void StartsWith_param_pattern() SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE @__param_0 = '' OR (((s."CaseInsensitiveText" IS NOT NULL)) AND (s."CaseInsensitiveText" LIKE @__param_0_1 || '%' ESCAPE '') AND left(s."CaseInsensitiveText", length(@__param_0))::citext = @__param_0::citext) +WHERE @__param_0 = '' OR ((s."CaseInsensitiveText" IS NOT NULL) AND (s."CaseInsensitiveText" LIKE @__param_0_1 || '%' ESCAPE '') AND left(s."CaseInsensitiveText", length(@__param_0))::citext = @__param_0::citext) LIMIT 2 """); } @@ -68,7 +68,7 @@ public void StartsWith_param_instance() SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE s."CaseInsensitiveText" = '' OR (((s."CaseInsensitiveText" IS NOT NULL)) AND (@__param_0 LIKE s."CaseInsensitiveText" || '%' ESCAPE '') AND left(@__param_0, length(s."CaseInsensitiveText"))::citext = s."CaseInsensitiveText"::citext) +WHERE s."CaseInsensitiveText" = '' OR ((s."CaseInsensitiveText" IS NOT NULL) AND (@__param_0 LIKE s."CaseInsensitiveText" || '%' ESCAPE '') AND left(@__param_0, length(s."CaseInsensitiveText"))::citext = s."CaseInsensitiveText"::citext) LIMIT 2 """); } @@ -84,7 +84,7 @@ public void EndsWith_literal() """ SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE ((s."CaseInsensitiveText" IS NOT NULL)) AND (s."CaseInsensitiveText" LIKE '%sometext') +WHERE (s."CaseInsensitiveText" IS NOT NULL) AND (s."CaseInsensitiveText" LIKE '%sometext') LIMIT 2 """); } @@ -104,7 +104,7 @@ public void EndsWith_param_pattern() SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE @__param_0 = '' OR (((s."CaseInsensitiveText" IS NOT NULL)) AND right(s."CaseInsensitiveText", length(@__param_0_1))::citext = @__param_0::citext) +WHERE @__param_0 = '' OR ((s."CaseInsensitiveText" IS NOT NULL) AND right(s."CaseInsensitiveText", length(@__param_0_1))::citext = @__param_0::citext) LIMIT 2 """); } @@ -123,7 +123,7 @@ public void EndsWith_param_instance() SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE s."CaseInsensitiveText" = '' OR (((s."CaseInsensitiveText" IS NOT NULL)) AND right(@__param_0, length(s."CaseInsensitiveText"))::citext = s."CaseInsensitiveText"::citext) +WHERE s."CaseInsensitiveText" = '' OR ((s."CaseInsensitiveText" IS NOT NULL) AND right(@__param_0, length(s."CaseInsensitiveText"))::citext = s."CaseInsensitiveText"::citext) LIMIT 2 """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/Ef6GroupByNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Ef6GroupByNpgsqlTest.cs index bc4ee3f0d..21b4aa313 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Ef6GroupByNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Ef6GroupByNpgsqlTest.cs @@ -23,7 +23,7 @@ public override async Task Whats_new_2021_sample_3(bool async) SELECT ( SELECT p1."LastName" FROM "Person" AS p1 - WHERE p1."MiddleInitial" = 'Q' AND p1."Age" = 20 AND (p."LastName" = p1."LastName" OR (((p."LastName" IS NULL)) AND ((p1."LastName" IS NULL)))) + WHERE p1."MiddleInitial" = 'Q' AND p1."Age" = 20 AND (p."LastName" = p1."LastName" OR ((p."LastName" IS NULL) AND (p1."LastName" IS NULL))) LIMIT 1) FROM "Person" AS p WHERE p."MiddleInitial" = 'Q' AND p."Age" = 20 @@ -31,7 +31,7 @@ GROUP BY p."LastName" ORDER BY length(( SELECT p1."LastName" FROM "Person" AS p1 - WHERE p1."MiddleInitial" = 'Q' AND p1."Age" = 20 AND (p."LastName" = p1."LastName" OR (((p."LastName" IS NULL)) AND ((p1."LastName" IS NULL)))) + WHERE p1."MiddleInitial" = 'Q' AND p1."Age" = 20 AND (p."LastName" = p1."LastName" OR ((p."LastName" IS NULL) AND (p1."LastName" IS NULL))) LIMIT 1))::int NULLS FIRST """); } @@ -45,14 +45,14 @@ public override async Task Whats_new_2021_sample_5(bool async) SELECT ( SELECT p1."LastName" FROM "Person" AS p1 - WHERE p."FirstName" = p1."FirstName" OR (((p."FirstName" IS NULL)) AND ((p1."FirstName" IS NULL))) + WHERE p."FirstName" = p1."FirstName" OR ((p."FirstName" IS NULL) AND (p1."FirstName" IS NULL)) LIMIT 1) FROM "Person" AS p GROUP BY p."FirstName" ORDER BY ( SELECT p1."LastName" FROM "Person" AS p1 - WHERE p."FirstName" = p1."FirstName" OR (((p."FirstName" IS NULL)) AND ((p1."FirstName" IS NULL))) + WHERE p."FirstName" = p1."FirstName" OR ((p."FirstName" IS NULL) AND (p1."FirstName" IS NULL)) LIMIT 1) NULLS FIRST """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs index 9ae5d2b60..54da07145 100644 --- a/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs @@ -210,9 +210,9 @@ public override async Task Normal_entity_owning_a_split_reference_with_main_frag AssertSql( """ SELECT e."Id", CASE - WHEN ((e."OwnedReference_Id" IS NOT NULL)) AND ((e."OwnedReference_OwnedIntValue1" IS NOT NULL)) AND ((e."OwnedReference_OwnedIntValue2" IS NOT NULL)) AND ((o0."OwnedIntValue3" IS NOT NULL)) AND ((o."OwnedIntValue4" IS NOT NULL)) THEN o."OwnedIntValue4" + WHEN (e."OwnedReference_Id" IS NOT NULL) AND (e."OwnedReference_OwnedIntValue1" IS NOT NULL) AND (e."OwnedReference_OwnedIntValue2" IS NOT NULL) AND (o0."OwnedIntValue3" IS NOT NULL) AND (o."OwnedIntValue4" IS NOT NULL) THEN o."OwnedIntValue4" END AS "OwnedIntValue4", CASE - WHEN ((e."OwnedReference_Id" IS NOT NULL)) AND ((e."OwnedReference_OwnedIntValue1" IS NOT NULL)) AND ((e."OwnedReference_OwnedIntValue2" IS NOT NULL)) AND ((o0."OwnedIntValue3" IS NOT NULL)) AND ((o."OwnedIntValue4" IS NOT NULL)) THEN o."OwnedStringValue4" + WHEN (e."OwnedReference_Id" IS NOT NULL) AND (e."OwnedReference_OwnedIntValue1" IS NOT NULL) AND (e."OwnedReference_OwnedIntValue2" IS NOT NULL) AND (o0."OwnedIntValue3" IS NOT NULL) AND (o."OwnedIntValue4" IS NOT NULL) THEN o."OwnedStringValue4" END AS "OwnedStringValue4" FROM "EntityOnes" AS e LEFT JOIN "OwnedReferenceExtras2" AS o ON e."Id" = o."EntityOneId" @@ -366,9 +366,9 @@ public override async Task Tpt_entity_owning_a_split_reference_on_base_with_tabl AssertSql( """ SELECT b."Id", b."BaseValue", m."MiddleValue", s."SiblingValue", l."LeafValue", CASE - WHEN (l."Id" IS NOT NULL) THEN 'LeafEntity' - WHEN (s."Id" IS NOT NULL) THEN 'SiblingEntity' - WHEN (m."Id" IS NOT NULL) THEN 'MiddleEntity' + WHEN l."Id" IS NOT NULL THEN 'LeafEntity' + WHEN s."Id" IS NOT NULL THEN 'SiblingEntity' + WHEN m."Id" IS NOT NULL THEN 'MiddleEntity' END AS "Discriminator", b."OwnedReference_Id", b."OwnedReference_OwnedIntValue1", b."OwnedReference_OwnedIntValue2", o0."OwnedIntValue3", o."OwnedIntValue4", b."OwnedReference_OwnedStringValue1", b."OwnedReference_OwnedStringValue2", o0."OwnedStringValue3", o."OwnedStringValue4" FROM "BaseEntity" AS b LEFT JOIN "MiddleEntity" AS m ON b."Id" = m."Id" @@ -399,9 +399,9 @@ public override async Task Tpt_entity_owning_a_split_reference_on_middle_with_ta AssertSql( """ SELECT b."Id", b."BaseValue", m."MiddleValue", s."SiblingValue", l."LeafValue", CASE - WHEN (l."Id" IS NOT NULL) THEN 'LeafEntity' - WHEN (s."Id" IS NOT NULL) THEN 'SiblingEntity' - WHEN (m."Id" IS NOT NULL) THEN 'MiddleEntity' + WHEN l."Id" IS NOT NULL THEN 'LeafEntity' + WHEN s."Id" IS NOT NULL THEN 'SiblingEntity' + WHEN m."Id" IS NOT NULL THEN 'MiddleEntity' END AS "Discriminator", m."Id", m."OwnedReference_Id", m."OwnedReference_OwnedIntValue1", m."OwnedReference_OwnedIntValue2", o0."OwnedIntValue3", o."OwnedIntValue4", m."OwnedReference_OwnedStringValue1", m."OwnedReference_OwnedStringValue2", o0."OwnedStringValue3", o."OwnedStringValue4" FROM "BaseEntity" AS b LEFT JOIN "MiddleEntity" AS m ON b."Id" = m."Id" @@ -432,9 +432,9 @@ public override async Task Tpt_entity_owning_a_split_reference_on_leaf_with_tabl AssertSql( """ SELECT b."Id", b."BaseValue", m."MiddleValue", s."SiblingValue", l."LeafValue", CASE - WHEN (l."Id" IS NOT NULL) THEN 'LeafEntity' - WHEN (s."Id" IS NOT NULL) THEN 'SiblingEntity' - WHEN (m."Id" IS NOT NULL) THEN 'MiddleEntity' + WHEN l."Id" IS NOT NULL THEN 'LeafEntity' + WHEN s."Id" IS NOT NULL THEN 'SiblingEntity' + WHEN m."Id" IS NOT NULL THEN 'MiddleEntity' END AS "Discriminator", l."Id", l."OwnedReference_Id", l."OwnedReference_OwnedIntValue1", l."OwnedReference_OwnedIntValue2", o0."OwnedIntValue3", o."OwnedIntValue4", l."OwnedReference_OwnedStringValue1", l."OwnedReference_OwnedStringValue2", o0."OwnedStringValue3", o."OwnedStringValue4" FROM "BaseEntity" AS b LEFT JOIN "MiddleEntity" AS m ON b."Id" = m."Id" diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs index 0d286c663..762db44b6 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs @@ -374,7 +374,7 @@ public void Like() """ SELECT j."Id", j."CustomerDocument", j."CustomerElement" FROM "JsonbEntities" AS j -WHERE ((j."CustomerElement"->>'Name' IS NOT NULL)) AND (j."CustomerElement"->>'Name' LIKE 'J%') +WHERE (j."CustomerElement"->>'Name' IS NOT NULL) AND (j."CustomerElement"->>'Name' LIKE 'J%') LIMIT 2 """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs index db74a5165..f6b5fbec0 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs @@ -249,7 +249,7 @@ public void Compare_to_null() """ SELECT j."Id", j."Customer", j."ToplevelArray" FROM "JsonbEntities" AS j -WHERE (j."Customer"#>>'{Statistics,Nested,SomeNullableInt}' IS NULL) +WHERE j."Customer"#>>'{Statistics,Nested,SomeNullableInt}' IS NULL LIMIT 2 """); } @@ -468,7 +468,7 @@ public void Like() """ SELECT j."Id", j."Customer", j."ToplevelArray" FROM "JsonbEntities" AS j -WHERE ((j."Customer"->>'Name' IS NOT NULL)) AND (j."Customer"->>'Name' LIKE 'J%') +WHERE (j."Customer"->>'Name' IS NOT NULL) AND (j."Customer"->>'Name' LIKE 'J%') LIMIT 2 """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/NetworkQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NetworkQueryNpgsqlTest.cs index 3038ca1cb..6d37dcd04 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NetworkQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NetworkQueryNpgsqlTest.cs @@ -64,7 +64,7 @@ public void IPAddress_inet_parse_column() """ SELECT count(*)::int FROM "NetTestEntities" AS n -WHERE n."Inet" = n."TextInet"::inet OR (((n."Inet" IS NULL)) AND ((n."TextInet" IS NULL))) +WHERE n."Inet" = n."TextInet"::inet OR ((n."Inet" IS NULL) AND (n."TextInet" IS NULL)) """); } @@ -79,7 +79,7 @@ public void PhysicalAddress_macaddr_parse_column() """ SELECT count(*)::int FROM "NetTestEntities" AS n -WHERE n."Macaddr" = n."TextMacaddr"::macaddr OR (((n."Macaddr" IS NULL)) AND ((n."TextMacaddr" IS NULL))) +WHERE n."Macaddr" = n."TextMacaddr"::macaddr OR ((n."Macaddr" IS NULL) AND (n."TextMacaddr" IS NULL)) """); } @@ -784,7 +784,7 @@ public void IPAddress_inet_BitwiseAnd_inet() SELECT count(*)::int FROM "NetTestEntities" AS n -WHERE n."Inet" = (n."Inet" & @__inet_1) OR ((n."Inet" IS NULL)) +WHERE n."Inet" = (n."Inet" & @__inet_1) OR (n."Inet" IS NULL) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindFunctionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindFunctionsQueryNpgsqlTest.cs index b08992643..1b9392fb8 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindFunctionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindFunctionsQueryNpgsqlTest.cs @@ -24,7 +24,7 @@ public override async Task IsNullOrWhiteSpace_in_predicate(bool async) """ SELECT c."CustomerID", c."Address", c."City", c."CompanyName", c."ContactName", c."ContactTitle", c."Country", c."Fax", c."Phone", c."PostalCode", c."Region" FROM "Customers" AS c -WHERE ((c."Region" IS NULL)) OR btrim(c."Region", E' \t\n\r') = '' +WHERE (c."Region" IS NULL) OR btrim(c."Region", E' \t\n\r') = '' """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindGroupByQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindGroupByQueryNpgsqlTest.cs index 8c475de39..9ebbe332e 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindGroupByQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindGroupByQueryNpgsqlTest.cs @@ -285,7 +285,7 @@ public override async Task GroupBy_aggregate_projecting_conditional_expression_b AssertSql( """ SELECT CASE - WHEN (o."OrderDate" IS NULL) THEN 'is null' + WHEN o."OrderDate" IS NULL THEN 'is null' ELSE 'is not null' END AS "Key", COALESCE(sum(o."OrderID"), 0)::int AS "Sum" FROM "Orders" AS o @@ -1296,7 +1296,7 @@ public override async Task GroupJoin_GroupBy_Aggregate(bool async) SELECT o."CustomerID" AS "Key", avg(o."OrderID"::double precision) AS "Average" FROM "Customers" AS c LEFT JOIN "Orders" AS o ON c."CustomerID" = o."CustomerID" -WHERE (o."OrderID" IS NOT NULL) +WHERE o."OrderID" IS NOT NULL GROUP BY o."CustomerID" """); } @@ -1510,7 +1510,7 @@ public override async Task GroupBy_complex_key_aggregate_2(bool async) SELECT t."Key" AS "Month", COALESCE(sum(t."OrderID"), 0)::int AS "Total", ( SELECT COALESCE(sum(o0."OrderID"), 0)::int FROM "Orders" AS o0 - WHERE date_part('month', o0."OrderDate")::int = t."Key" OR (((o0."OrderDate" IS NULL)) AND ((t."Key" IS NULL)))) AS "Payment" + WHERE date_part('month', o0."OrderDate")::int = t."Key" OR ((o0."OrderDate" IS NULL) AND (t."Key" IS NULL))) AS "Payment" FROM ( SELECT o."OrderID", date_part('month', o."OrderDate")::int AS "Key" FROM "Orders" AS o @@ -1582,7 +1582,7 @@ WHERE EXISTS ( SELECT 1 FROM "Orders" AS o0 GROUP BY o0."CustomerID" - HAVING count(*)::int > 30 AND (o0."CustomerID" = o."CustomerID" OR (((o0."CustomerID" IS NULL)) AND ((o."CustomerID" IS NULL))))) + HAVING count(*)::int > 30 AND (o0."CustomerID" = o."CustomerID" OR ((o0."CustomerID" IS NULL) AND (o."CustomerID" IS NULL)))) """); } @@ -2027,7 +2027,7 @@ SELECT count(*)::int AS c, p0."ProductID" FROM "Products" AS p0 GROUP BY p0."ProductID" ) AS t0 ON TRUE -WHERE ((o."CustomerID" IS NOT NULL)) AND (o."CustomerID" LIKE 'A%') +WHERE (o."CustomerID" IS NOT NULL) AND (o."CustomerID" LIKE 'A%') ORDER BY o."OrderID" NULLS FIRST, t."ProductID" NULLS FIRST """); } @@ -2042,7 +2042,7 @@ SELECT NOT EXISTS ( SELECT 1 FROM "Orders" AS o GROUP BY o."CustomerID" - HAVING o."CustomerID" <> 'ALFKI' OR ((o."CustomerID" IS NULL))) + HAVING o."CustomerID" <> 'ALFKI' OR (o."CustomerID" IS NULL)) """); } @@ -2124,7 +2124,7 @@ public override async Task GroupBy_Where_Count_with_predicate(bool async) AssertSql( """ -SELECT count(*) FILTER (WHERE o."OrderID" < 10300 AND ((o."OrderDate" IS NOT NULL)) AND date_part('year', o."OrderDate")::int = 1997)::int +SELECT count(*) FILTER (WHERE o."OrderID" < 10300 AND (o."OrderDate" IS NOT NULL) AND date_part('year', o."OrderDate")::int = 1997)::int FROM "Orders" AS o GROUP BY o."CustomerID" """); @@ -2136,7 +2136,7 @@ public override async Task GroupBy_Where_Where_Count(bool async) AssertSql( """ -SELECT count(*) FILTER (WHERE o."OrderID" < 10300 AND ((o."OrderDate" IS NOT NULL)) AND date_part('year', o."OrderDate")::int = 1997)::int +SELECT count(*) FILTER (WHERE o."OrderID" < 10300 AND (o."OrderDate" IS NOT NULL) AND date_part('year', o."OrderDate")::int = 1997)::int FROM "Orders" AS o GROUP BY o."CustomerID" """); @@ -2148,7 +2148,7 @@ public override async Task GroupBy_Where_Select_Where_Count(bool async) AssertSql( """ -SELECT count(*) FILTER (WHERE o."OrderID" < 10300 AND ((o."OrderDate" IS NOT NULL)) AND date_part('year', o."OrderDate")::int = 1997)::int +SELECT count(*) FILTER (WHERE o."OrderID" < 10300 AND (o."OrderDate" IS NOT NULL) AND date_part('year', o."OrderDate")::int = 1997)::int FROM "Orders" AS o GROUP BY o."CustomerID" """); @@ -2160,7 +2160,7 @@ public override async Task GroupBy_Where_Select_Where_Select_Min(bool async) AssertSql( """ -SELECT min(o."OrderID") FILTER (WHERE o."OrderID" < 10300 AND ((o."OrderDate" IS NOT NULL)) AND date_part('year', o."OrderDate")::int = 1997) +SELECT min(o."OrderID") FILTER (WHERE o."OrderID" < 10300 AND (o."OrderDate" IS NOT NULL) AND date_part('year', o."OrderDate")::int = 1997) FROM "Orders" AS o GROUP BY o."CustomerID" """); @@ -2248,7 +2248,7 @@ public override async Task GroupBy_with_aggregate_through_navigation_property(bo SELECT max(c."Region") FROM "Orders" AS o0 LEFT JOIN "Customers" AS c ON o0."CustomerID" = c."CustomerID" - WHERE o."EmployeeID" = o0."EmployeeID" OR (((o."EmployeeID" IS NULL)) AND ((o0."EmployeeID" IS NULL)))) AS max + WHERE o."EmployeeID" = o0."EmployeeID" OR ((o."EmployeeID" IS NULL) AND (o0."EmployeeID" IS NULL))) AS max FROM "Orders" AS o GROUP BY o."EmployeeID" """); @@ -2263,7 +2263,7 @@ public override async Task GroupBy_with_aggregate_containing_complex_where(bool SELECT o."EmployeeID" AS "Key", ( SELECT max(o0."OrderID") FROM "Orders" AS o0 - WHERE o0."EmployeeID"::bigint = CAST((max(o."OrderID") * 6) AS bigint) OR (((o0."EmployeeID" IS NULL)) AND ((max(o."OrderID") IS NULL)))) AS "Max" + WHERE o0."EmployeeID"::bigint = CAST((max(o."OrderID") * 6) AS bigint) OR ((o0."EmployeeID" IS NULL) AND (max(o."OrderID") IS NULL))) AS "Max" FROM "Orders" AS o GROUP BY o."EmployeeID" """); @@ -2278,7 +2278,7 @@ public override async Task GroupBy_Shadow(bool async) SELECT ( SELECT e0."Title" FROM "Employees" AS e0 - WHERE e0."Title" = 'Sales Representative' AND e0."EmployeeID" = 1 AND (e."Title" = e0."Title" OR (((e."Title" IS NULL)) AND ((e0."Title" IS NULL)))) + WHERE e0."Title" = 'Sales Representative' AND e0."EmployeeID" = 1 AND (e."Title" = e0."Title" OR ((e."Title" IS NULL) AND (e0."Title" IS NULL))) LIMIT 1) FROM "Employees" AS e WHERE e."Title" = 'Sales Representative' AND e."EmployeeID" = 1 @@ -2467,7 +2467,7 @@ public override async Task GroupBy_group_Where_Select_Distinct_aggregate(bool as AssertSql( """ -SELECT o."CustomerID" AS "Key", max(DISTINCT o."OrderDate") FILTER (WHERE (o."OrderDate" IS NOT NULL)) AS "Max" +SELECT o."CustomerID" AS "Key", max(DISTINCT o."OrderDate") FILTER (WHERE o."OrderDate" IS NOT NULL) AS "Max" FROM "Orders" AS o GROUP BY o."CustomerID" """); @@ -2679,7 +2679,7 @@ SELECT p."ProductName" GROUP BY p."ProductName" ) AS t) > 1 AS "HasMultipleProducts" FROM "Orders" AS o -WHERE (o."OrderDate" IS NOT NULL) +WHERE o."OrderDate" IS NOT NULL """); } @@ -2962,7 +2962,7 @@ public override async Task GroupBy_aggregate_join_with_group_result(bool async) FROM "Orders" AS o GROUP BY o."CustomerID" ) AS t -INNER JOIN "Orders" AS o0 ON (t."Key" = o0."CustomerID" OR (((t."Key" IS NULL)) AND ((o0."CustomerID" IS NULL)))) AND (t."LastOrderDate" = o0."OrderDate" OR (((t."LastOrderDate" IS NULL)) AND ((o0."OrderDate" IS NULL)))) +INNER JOIN "Orders" AS o0 ON (t."Key" = o0."CustomerID" OR ((t."Key" IS NULL) AND (o0."CustomerID" IS NULL))) AND (t."LastOrderDate" = o0."OrderDate" OR ((t."LastOrderDate" IS NULL) AND (o0."OrderDate" IS NULL))) """); } @@ -3232,7 +3232,7 @@ ELSE 0 ELSE 0 END), 0)::int AS "Sum2" FROM "Orders" AS o -WHERE ((o."CustomerID" IS NOT NULL)) AND (o."CustomerID" LIKE 'A%') +WHERE (o."CustomerID" IS NOT NULL) AND (o."CustomerID" LIKE 'A%') GROUP BY o."CustomerID" """); } @@ -3418,7 +3418,7 @@ public override async Task Select_uncorrelated_collection_with_groupby_when_oute SELECT DISTINCT c."City" FROM "Orders" AS o LEFT JOIN "Customers" AS c ON o."CustomerID" = c."CustomerID" - WHERE ((o."CustomerID" IS NOT NULL)) AND (o."CustomerID" LIKE 'A%') + WHERE (o."CustomerID" IS NOT NULL) AND (o."CustomerID" LIKE 'A%') ) AS t LEFT JOIN LATERAL ( SELECT p."ProductID" @@ -3463,7 +3463,7 @@ public override async Task Select_correlated_collection_after_GroupBy_aggregate_ SELECT o."CustomerID" FROM "Orders" AS o GROUP BY o."CustomerID" - HAVING ((o."CustomerID" IS NOT NULL)) AND (o."CustomerID" LIKE 'F%') + HAVING (o."CustomerID" IS NOT NULL) AND (o."CustomerID" LIKE 'F%') ) AS t LEFT JOIN "Orders" AS o0 ON t."CustomerID" = o0."CustomerID" ORDER BY t."CustomerID" NULLS FIRST @@ -3516,7 +3516,7 @@ SELECT count(*)::int WHERE c."CustomerID" = o0."CustomerID" ) AS t0 LEFT JOIN "Customers" AS c0 ON t0."CustomerID" = c0."CustomerID" - WHERE (t."Key" = t0."Key" OR (((t."Key" IS NULL)) AND ((t0."Key" IS NULL)))) AND (COALESCE(c0."City", '') || COALESCE(t0."CustomerID", '') LIKE 'Lon%')) AS "Count", t."Key" + WHERE (t."Key" = t0."Key" OR ((t."Key" IS NULL) AND (t0."Key" IS NULL))) AND (COALESCE(c0."City", '') || COALESCE(t0."CustomerID", '') LIKE 'Lon%')) AS "Count", t."Key" FROM ( SELECT o."OrderID", COALESCE(c2."City", '') || COALESCE(o."CustomerID", '') AS "Key" FROM "Orders" AS o diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindMiscellaneousQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindMiscellaneousQueryNpgsqlTest.cs index cb91ca199..b48a9f346 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindMiscellaneousQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindMiscellaneousQueryNpgsqlTest.cs @@ -29,7 +29,7 @@ public override async Task Select_expression_date_add_year(bool async) """ SELECT o."OrderDate" + INTERVAL '1 years' AS "OrderDate" FROM "Orders" AS o -WHERE (o."OrderDate" IS NOT NULL) +WHERE o."OrderDate" IS NOT NULL """); } @@ -55,7 +55,7 @@ await AssertQuery( SELECT o."OrderDate" + CAST((@__years_0::text || ' years') AS interval) AS "OrderDate" FROM "Orders" AS o -WHERE (o."OrderDate" IS NOT NULL) +WHERE o."OrderDate" IS NOT NULL """); } @@ -89,7 +89,7 @@ await AssertFirst( """ SELECT floor(date_part('day', date_trunc('day', now()::timestamp) - date_trunc('day', o."OrderDate")))::int AS "Elapsed" FROM "Orders" AS o -WHERE (o."OrderDate" IS NOT NULL) +WHERE o."OrderDate" IS NOT NULL LIMIT 1 """); } @@ -242,7 +242,7 @@ await AssertQuery( SELECT c."CustomerID", c."Address", c."City", c."CompanyName", c."ContactName", c."ContactTitle", c."Country", c."Fax", c."Phone", c."PostalCode", c."Region" FROM "Customers" AS c -WHERE c."Region" = ANY (@__regions_0) OR (((c."Region" IS NULL)) AND ((array_position(@__regions_0, NULL) IS NOT NULL))) +WHERE c."Region" = ANY (@__regions_0) OR ((c."Region" IS NULL) AND (array_position(@__regions_0, NULL) IS NOT NULL)) """); } @@ -267,7 +267,7 @@ await AssertQuery( SELECT c."CustomerID", c."Address", c."City", c."CompanyName", c."ContactName", c."ContactTitle", c."Country", c."Fax", c."Phone", c."PostalCode", c."Region" FROM "Customers" AS c -WHERE c."Region" = ANY (@__regions_0) OR (((c."Region" IS NULL)) AND ((array_position(@__regions_0, NULL) IS NOT NULL))) +WHERE c."Region" = ANY (@__regions_0) OR ((c."Region" IS NULL) AND (array_position(@__regions_0, NULL) IS NOT NULL)) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindSetOperationsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindSetOperationsQueryNpgsqlTest.cs index bb5b849e8..e11f97f7b 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindSetOperationsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindSetOperationsQueryNpgsqlTest.cs @@ -157,7 +157,7 @@ SELECT t1."CustomerID" FROM "Orders" AS o4 ) AS t1 ORDER BY t1."CustomerID" NULLS FIRST - LIMIT 1) OR (((t0."CustomerID" IS NULL)) AND ((( + LIMIT 1) OR ((t0."CustomerID" IS NULL) AND (( SELECT t1."CustomerID" FROM ( SELECT NULL::int AS "OrderID", o2."CustomerID" @@ -170,7 +170,7 @@ SELECT t1."CustomerID" FROM "Orders" AS o4 ) AS t1 ORDER BY t1."CustomerID" NULLS FIRST - LIMIT 1) IS NULL))) + LIMIT 1) IS NULL)) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs index b5e9c31eb..72ba80f81 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs @@ -163,7 +163,7 @@ await AssertQuery( AssertSql( """ SELECT p."Id", CASE - WHEN (p."Point" IS NULL) THEN NULL + WHEN p."Point" IS NULL THEN NULL ELSE lower(GeometryType(p."Point")) END AS "GeometryType" FROM "PointEntity" AS p diff --git a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs index 073f0089f..ec773270d 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs @@ -102,7 +102,7 @@ public override async Task Combine_aggregate(bool async) """ SELECT p."Group" AS "Id", ST_Collect(p."Point") AS "Combined" FROM "PointEntity" AS p -WHERE (p."Point" IS NOT NULL) +WHERE p."Point" IS NOT NULL GROUP BY p."Group" """); } @@ -115,7 +115,7 @@ public override async Task EnvelopeCombine_aggregate(bool async) """ SELECT p."Group" AS "Id", ST_Extent(p."Point")::geometry AS "Combined" FROM "PointEntity" AS p -WHERE (p."Point" IS NOT NULL) +WHERE p."Point" IS NOT NULL GROUP BY p."Group" """); } @@ -152,7 +152,7 @@ public override async Task ConvexHull_aggregate(bool async) """ SELECT p."Group" AS "Id", ST_ConvexHull(ST_Collect(p."Point")) AS "ConvexHull" FROM "PointEntity" AS p -WHERE (p."Point" IS NOT NULL) +WHERE p."Point" IS NOT NULL GROUP BY p."Group" """); } @@ -277,7 +277,7 @@ await AssertQuery( AssertSql( """ SELECT p."Id", CASE - WHEN (p."Point" IS NULL) THEN NULL + WHEN p."Point" IS NULL THEN NULL ELSE lower(GeometryType(p."Point")) END AS "GeometryType" FROM "PointEntity" AS p @@ -673,7 +673,7 @@ public override async Task Union_aggregate(bool async) """ SELECT p."Group" AS "Id", ST_Union(p."Point") AS "Union" FROM "PointEntity" AS p -WHERE (p."Point" IS NOT NULL) +WHERE p."Point" IS NOT NULL GROUP BY p."Group" """); }