From 2703bf42fdbe77977614868e7e5760deee4de338 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Sun, 19 Mar 2023 15:57:38 +0100 Subject: [PATCH] Implement full parentheses management Closes #2217 --- .../Query/Internal/NpgsqlQuerySqlGenerator.cs | 152 ++++++++++++++++-- ...FiltersInheritanceBulkUpdatesNpgsqlTest.cs | 26 +-- .../InheritanceBulkUpdatesNpgsqlTest.cs | 16 +- .../NonSharedModelBulkUpdatesNpgsqlTest.cs | 2 +- .../NorthwindBulkUpdatesNpgsqlTest.cs | 84 +++++----- ...FiltersInheritanceBulkUpdatesNpgsqlTest.cs | 12 +- .../TPCInheritanceBulkUpdatesNpgsqlTest.cs | 8 +- ...FiltersInheritanceBulkUpdatesNpgsqlTest.cs | 8 +- .../TPTInheritanceBulkUpdatesNpgsqlTest.cs | 4 +- .../Query/ArrayArrayQueryTest.cs | 4 +- .../Query/ArrayListQueryTest.cs | 4 +- .../Query/BigIntegerQueryTest.cs | 2 +- .../Query/CitextQueryTest.cs | 22 +-- .../Query/Ef6GroupByNpgsqlTest.cs | 18 +-- .../Query/EntitySplittingQueryNpgsqlTest.cs | 12 +- .../Query/GearsOfWarQueryNpgsqlTest.cs | 28 ++-- .../Query/JsonDomQueryTest.cs | 2 +- .../Query/JsonPocoQueryTest.cs | 2 +- .../Query/JsonStringQueryTest.cs | 2 +- .../Query/LTreeQueryTest.cs | 4 +- .../Query/LegacyTimestampQueryTest.cs | 2 +- .../Query/NetworkQueryNpgsqlTest.cs | 10 +- .../NorthwindDbFunctionsQueryNpgsqlTest.cs | 4 +- .../NorthwindFunctionsQueryNpgsqlTest.cs | 2 +- .../Query/NorthwindGroupByQueryNpgsqlTest.cs | 56 +++---- .../NorthwindMiscellaneousQueryNpgsqlTest.cs | 2 +- .../NorthwindSetOperationsQueryNpgsqlTest.cs | 4 +- .../Query/NorthwindWhereQueryNpgsqlTest.cs | 4 +- .../Query/NullSemanticsQueryNpgsqlTest.cs | 14 +- .../Query/OperatorsQueryNpgsqlTest.cs | 110 +------------ .../Query/TPCGearsOfWarQueryNpgsqlTest.cs | 2 +- .../Query/TPTGearsOfWarQueryNpgsqlTest.cs | 2 +- .../Query/TimestampQueryTest.cs | 12 +- .../Query/TrigramsQueryNpgsqlTest.cs | 2 +- .../NodaTimeQueryNpgsqlTest.cs | 32 ++-- 35 files changed, 348 insertions(+), 322 deletions(-) diff --git a/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs b/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs index ef2563253..5d9afc43c 100644 --- a/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs +++ b/src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs @@ -438,16 +438,16 @@ protected virtual Expression VisitPostgresBinary(PostgresBinaryExpression binary { Check.NotNull(binaryExpression, nameof(binaryExpression)); - var requiresBrackets = RequiresBrackets(binaryExpression.Left); + var requiresParentheses = RequiresParentheses(binaryExpression, binaryExpression.Left); - if (requiresBrackets) + if (requiresParentheses) { Sql.Append("("); } Visit(binaryExpression.Left); - if (requiresBrackets) + if (requiresParentheses) { Sql.Append(")"); } @@ -516,16 +516,16 @@ binaryExpression.Right.TypeMapping is NpgsqlArrayTypeMapping arrayMapping && }) .Append(" "); - requiresBrackets = RequiresBrackets(binaryExpression.Right); + requiresParentheses = RequiresParentheses(binaryExpression, binaryExpression.Right); - if (requiresBrackets) + if (requiresParentheses) { Sql.Append("("); } Visit(binaryExpression.Right); - if (requiresBrackets) + if (requiresParentheses) { Sql.Append(")"); } @@ -902,16 +902,16 @@ public virtual Expression VisitUnknownBinary(PostgresUnknownBinaryExpression unk { Check.NotNull(unknownBinaryExpression, nameof(unknownBinaryExpression)); - var requiresBrackets = RequiresBrackets(unknownBinaryExpression.Left); + var requiresParentheses = RequiresParentheses(unknownBinaryExpression, unknownBinaryExpression.Left); - if (requiresBrackets) + if (requiresParentheses) { Sql.Append("("); } Visit(unknownBinaryExpression.Left); - if (requiresBrackets) + if (requiresParentheses) { Sql.Append(")"); } @@ -921,16 +921,16 @@ public virtual Expression VisitUnknownBinary(PostgresUnknownBinaryExpression unk .Append(unknownBinaryExpression.Operator) .Append(" "); - requiresBrackets = RequiresBrackets(unknownBinaryExpression.Right); + requiresParentheses = RequiresParentheses(unknownBinaryExpression, unknownBinaryExpression.Right); - if (requiresBrackets) + if (requiresParentheses) { Sql.Append("("); } Visit(unknownBinaryExpression.Right); - if (requiresBrackets) + if (requiresParentheses) { Sql.Append(")"); } @@ -1023,8 +1023,132 @@ public virtual Expression VisitPostgresFunction(PostgresFunctionExpression e) return e; } - private static bool RequiresBrackets(SqlExpression expression) - => expression is SqlBinaryExpression || expression is LikeExpression || expression is PostgresBinaryExpression; + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + protected override bool RequiresParentheses(SqlExpression outerExpression, SqlExpression innerExpression) + { + switch (innerExpression) + { + // PG doesn't support ~-, -~, ~~, -- so we add parentheses + case SqlUnaryExpression innerUnary when outerExpression is SqlUnaryExpression outerUnary + && (innerUnary.OperatorType is ExpressionType.Negate || innerUnary.OperatorType is ExpressionType.Not && innerUnary.Type != typeof(bool)) + && (outerUnary.OperatorType is ExpressionType.Negate || outerUnary.OperatorType is ExpressionType.Not && outerUnary.Type != typeof(bool)): + return true; + + // Copy paste of QuerySqlGenerator.RequiresParentheses for SqlBinaryExpression + case PostgresBinaryExpression innerBinary: + { + // If the provider defined precedence for the two expression, use that + if (TryGetOperatorInfo(outerExpression, out var outerPrecedence, out var isOuterAssociative) + && TryGetOperatorInfo(innerExpression, out var innerPrecedence, out _)) + { + return outerPrecedence.CompareTo(innerPrecedence) switch + { + > 0 => true, + < 0 => false, + + // If both operators have the same precedence, add parentheses unless they're the same operator, and + // that operator is associative (e.g. a + b + c) + 0 => outerExpression is not PostgresBinaryExpression outerBinary + || outerBinary.OperatorType != innerBinary.OperatorType + || !isOuterAssociative + // Arithmetic operators on floating points aren't associative, because of rounding errors. + || outerExpression.Type == typeof(float) + || outerExpression.Type == typeof(double) + || innerExpression.Type == typeof(float) + || innerExpression.Type == typeof(double) + }; + } + + // Otherwise always parenthesize for safety + return true; + } + + default: + return base.RequiresParentheses(outerExpression, innerExpression); + } + } + + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + protected override bool TryGetOperatorInfo(SqlExpression expression, out int precedence, out bool isAssociative) + { + // See https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-PRECEDENCE + (precedence, isAssociative) = expression switch + { + // TODO: Exponent => 1300 + + SqlBinaryExpression sqlBinaryExpression => sqlBinaryExpression.OperatorType switch + { + // Multiplication, division, modulo + ExpressionType.Multiply => (1200, true), + ExpressionType.Divide => (1200, false), + ExpressionType.Modulo => (1200, false), + + // Addition, subtraction (binary) + ExpressionType.Add => (1100, true), + ExpressionType.Subtract => (1100, false), + + // All other native and user-defined operators => 1000 + ExpressionType.LeftShift => (1000, true), + ExpressionType.RightShift => (1000, true), + ExpressionType.And when sqlBinaryExpression.Type != typeof(bool) => (1000, true), + ExpressionType.Or when sqlBinaryExpression.Type != typeof(bool) => (1000, true), + + // Comparison operators + ExpressionType.Equal => (800, false), + ExpressionType.NotEqual => (800, false), + ExpressionType.LessThan => (800, false), + ExpressionType.LessThanOrEqual => (800, false), + ExpressionType.GreaterThan => (800, false), + ExpressionType.GreaterThanOrEqual => (800, false), + + // Logical operators + ExpressionType.AndAlso => (500, true), + ExpressionType.OrElse => (500, true), + ExpressionType.And when sqlBinaryExpression.Type == typeof(bool) => (500, true), + ExpressionType.Or when sqlBinaryExpression.Type == typeof(bool) => (500, true), + + _ => default, + }, + + SqlUnaryExpression sqlUnaryExpression => sqlUnaryExpression.OperatorType switch + { + ExpressionType.Convert => (1600, false), + ExpressionType.Negate => (1400, false), + ExpressionType.Not when sqlUnaryExpression.Type != typeof(bool) => (1000, false), + ExpressionType.Equal => (700, false), // IS NULL + ExpressionType.NotEqual => (700, false), // IS NOT NULL + ExpressionType.Not when sqlUnaryExpression.Type == typeof(bool) => (600, false), + + _ => default, + }, + + // There's an "any other operator" category in the PG operator precedence table, we assign that a numeric value of 1000. + // TODO: Some operators here may be associative + PostgresBinaryExpression => (1000, false), + + CollateExpression => (1000, false), + AtTimeZoneExpression => (1000, false), + InExpression => (900, false), + PostgresJsonTraversalExpression => (1000, false), + PostgresArrayIndexExpression => (1500, false), + PostgresAllExpression or PostgresAnyExpression => (800, false), + LikeExpression or PostgresILikeExpression or PostgresRegexMatchExpression => (900, false), + + _ => default, + }; + + return precedence != default; + } private void GenerateList( IReadOnlyList items, diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/FiltersInheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/FiltersInheritanceBulkUpdatesNpgsqlTest.cs index c8921f024..b09e1740b 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/FiltersInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/FiltersInheritanceBulkUpdatesNpgsqlTest.cs @@ -20,7 +20,7 @@ public override async Task Delete_where_hierarchy(bool async) AssertSql( """ DELETE FROM "Animals" AS a -WHERE (a."CountryId" = 1) AND (a."Name" = 'Great spotted kiwi') +WHERE a."CountryId" = 1 AND a."Name" = 'Great spotted kiwi' """); } @@ -31,7 +31,7 @@ public override async Task Delete_where_hierarchy_derived(bool async) AssertSql( """ DELETE FROM "Animals" AS a -WHERE ((a."Discriminator" = 'Kiwi') AND (a."CountryId" = 1)) AND (a."Name" = 'Great spotted kiwi') +WHERE a."Discriminator" = 'Kiwi' AND a."CountryId" = 1 AND a."Name" = 'Great spotted kiwi' """); } @@ -45,7 +45,7 @@ DELETE FROM "Countries" AS c WHERE ( SELECT count(*)::int FROM "Animals" AS a - WHERE ((a."CountryId" = 1) AND (c."Id" = a."CountryId")) AND (a."CountryId" > 0)) > 0 + WHERE a."CountryId" = 1 AND c."Id" = a."CountryId" AND a."CountryId" > 0) > 0 """); } @@ -59,7 +59,7 @@ DELETE FROM "Countries" AS c WHERE ( SELECT count(*)::int FROM "Animals" AS a - WHERE (((a."CountryId" = 1) AND (c."Id" = a."CountryId")) AND (a."Discriminator" = 'Kiwi')) AND (a."CountryId" > 0)) > 0 + WHERE a."CountryId" = 1 AND c."Id" = a."CountryId" AND a."Discriminator" = 'Kiwi' AND a."CountryId" > 0) > 0 """); } @@ -84,16 +84,16 @@ public override async Task Delete_GroupBy_Where_Select_First_3(bool async) AssertSql( """ DELETE FROM "Animals" AS a -WHERE (a."CountryId" = 1) AND EXISTS ( +WHERE a."CountryId" = 1 AND EXISTS ( SELECT 1 FROM "Animals" AS a0 WHERE a0."CountryId" = 1 GROUP BY a0."CountryId" - HAVING (count(*)::int < 3) AND (( + HAVING count(*)::int < 3 AND ( SELECT a1."Id" FROM "Animals" AS a1 - WHERE (a1."CountryId" = 1) AND (a0."CountryId" = a1."CountryId") - LIMIT 1) = a."Id")) + WHERE a1."CountryId" = 1 AND a0."CountryId" = a1."CountryId" + LIMIT 1) = a."Id") """); } @@ -119,7 +119,7 @@ SELECT 1 FROM ( SELECT a0."Id", a0."CountryId", a0."Discriminator", a0."Name", a0."Species", a0."EagleId", a0."IsFlightless", a0."Group", a0."FoundOn" FROM "Animals" AS a0 - WHERE (a0."CountryId" = 1) AND (a0."Name" = 'Great spotted kiwi') + WHERE a0."CountryId" = 1 AND a0."Name" = 'Great spotted kiwi' ORDER BY a0."Name" NULLS FIRST LIMIT @__p_1 OFFSET @__p_0 ) AS t @@ -135,7 +135,7 @@ public override async Task Update_where_hierarchy(bool async) """ UPDATE "Animals" AS a SET "Name" = 'Animal' -WHERE (a."CountryId" = 1) AND (a."Name" = 'Great spotted kiwi') +WHERE a."CountryId" = 1 AND a."Name" = 'Great spotted kiwi' """); } @@ -154,7 +154,7 @@ public override async Task Update_where_hierarchy_derived(bool async) """ UPDATE "Animals" AS a SET "Name" = 'Kiwi' -WHERE ((a."Discriminator" = 'Kiwi') AND (a."CountryId" = 1)) AND (a."Name" = 'Great spotted kiwi') +WHERE a."Discriminator" = 'Kiwi' AND a."CountryId" = 1 AND a."Name" = 'Great spotted kiwi' """); } @@ -169,7 +169,7 @@ public override async Task Update_where_using_hierarchy(bool async) WHERE ( SELECT count(*)::int FROM "Animals" AS a - WHERE ((a."CountryId" = 1) AND (c."Id" = a."CountryId")) AND (a."CountryId" > 0)) > 0 + WHERE a."CountryId" = 1 AND c."Id" = a."CountryId" AND a."CountryId" > 0) > 0 """); } @@ -184,7 +184,7 @@ public override async Task Update_where_using_hierarchy_derived(bool async) WHERE ( SELECT count(*)::int FROM "Animals" AS a - WHERE (((a."CountryId" = 1) AND (c."Id" = a."CountryId")) AND (a."Discriminator" = 'Kiwi')) AND (a."CountryId" > 0)) > 0 + WHERE a."CountryId" = 1 AND c."Id" = a."CountryId" AND a."Discriminator" = 'Kiwi' AND a."CountryId" > 0) > 0 """); } diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/InheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/InheritanceBulkUpdatesNpgsqlTest.cs index 31f4ff850..0a5c60f8a 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/InheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/InheritanceBulkUpdatesNpgsqlTest.cs @@ -31,7 +31,7 @@ public override async Task Delete_where_hierarchy_derived(bool async) AssertSql( """ DELETE FROM "Animals" AS a -WHERE (a."Discriminator" = 'Kiwi') AND (a."Name" = 'Great spotted kiwi') +WHERE a."Discriminator" = 'Kiwi' AND a."Name" = 'Great spotted kiwi' """); } @@ -45,7 +45,7 @@ DELETE FROM "Countries" AS c WHERE ( SELECT count(*)::int FROM "Animals" AS a - WHERE (c."Id" = a."CountryId") AND (a."CountryId" > 0)) > 0 + WHERE c."Id" = a."CountryId" AND a."CountryId" > 0) > 0 """); } @@ -59,7 +59,7 @@ DELETE FROM "Countries" AS c WHERE ( SELECT count(*)::int FROM "Animals" AS a - WHERE ((c."Id" = a."CountryId") AND (a."Discriminator" = 'Kiwi')) AND (a."CountryId" > 0)) > 0 + WHERE c."Id" = a."CountryId" AND a."Discriminator" = 'Kiwi' AND a."CountryId" > 0) > 0 """); } @@ -130,11 +130,11 @@ WHERE EXISTS ( SELECT 1 FROM "Animals" AS a0 GROUP BY a0."CountryId" - HAVING (count(*)::int < 3) AND (( + HAVING count(*)::int < 3 AND ( SELECT a1."Id" FROM "Animals" AS a1 WHERE a0."CountryId" = a1."CountryId" - LIMIT 1) = a."Id")) + LIMIT 1) = a."Id") """); } @@ -165,7 +165,7 @@ public override async Task Update_where_hierarchy_derived(bool async) """ UPDATE "Animals" AS a SET "Name" = 'Kiwi' -WHERE (a."Discriminator" = 'Kiwi') AND (a."Name" = 'Great spotted kiwi') +WHERE a."Discriminator" = 'Kiwi' AND a."Name" = 'Great spotted kiwi' """); } @@ -180,7 +180,7 @@ public override async Task Update_where_using_hierarchy(bool async) WHERE ( SELECT count(*)::int FROM "Animals" AS a - WHERE (c."Id" = a."CountryId") AND (a."CountryId" > 0)) > 0 + WHERE c."Id" = a."CountryId" AND a."CountryId" > 0) > 0 """); } @@ -195,7 +195,7 @@ public override async Task Update_where_using_hierarchy_derived(bool async) WHERE ( SELECT count(*)::int FROM "Animals" AS a - WHERE ((c."Id" = a."CountryId") AND (a."Discriminator" = 'Kiwi')) AND (a."CountryId" > 0)) > 0 + WHERE c."Id" = a."CountryId" AND a."Discriminator" = 'Kiwi' AND a."CountryId" > 0) > 0 """); } diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs index 93da4b988..528e569f2 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesNpgsqlTest.cs @@ -63,7 +63,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 6a4851558..77b9facab 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesNpgsqlTest.cs @@ -66,7 +66,7 @@ DELETE FROM "Order Details" AS o WHERE EXISTS ( SELECT 1 FROM "Order Details" AS o0 - WHERE (o0."OrderID" < 10300) AND ((o0."OrderID" = o."OrderID") AND (o0."ProductID" = o."ProductID"))) + WHERE o0."OrderID" < 10300 AND o0."OrderID" = o."OrderID" AND o0."ProductID" = o."ProductID") """); } @@ -88,7 +88,7 @@ WHERE o0."OrderID" < 10300 ORDER BY o0."OrderID" NULLS FIRST OFFSET @__p_0 ) AS t - WHERE (t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID")) + WHERE t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -110,7 +110,7 @@ WHERE o0."OrderID" < 10300 ORDER BY o0."OrderID" NULLS FIRST LIMIT @__p_0 ) AS t - WHERE (t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID")) + WHERE t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -132,7 +132,7 @@ WHERE o0."OrderID" < 10300 ORDER BY o0."OrderID" NULLS FIRST LIMIT @__p_0 OFFSET @__p_0 ) AS t - WHERE (t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID")) + WHERE t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -153,7 +153,7 @@ SELECT 1 WHERE o0."OrderID" < 10300 OFFSET @__p_0 ) AS t - WHERE (t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID")) + WHERE t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -174,7 +174,7 @@ SELECT 1 WHERE o0."OrderID" < 10300 LIMIT @__p_0 ) AS t - WHERE (t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID")) + WHERE t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -195,7 +195,7 @@ SELECT 1 WHERE o0."OrderID" < 10300 LIMIT @__p_0 OFFSET @__p_0 ) AS t - WHERE (t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID")) + WHERE t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -210,7 +210,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" @@ -227,15 +227,15 @@ public override async Task Delete_Where_predicate_with_GroupBy_aggregate_2(bool """ DELETE FROM "Order Details" AS o USING "Orders" AS o0 -WHERE (o."OrderID" = o0."OrderID") AND EXISTS ( +WHERE o."OrderID" = o0."OrderID" AND EXISTS ( SELECT 1 FROM "Orders" AS o1 GROUP BY o1."CustomerID" - HAVING (count(*)::int > 9) AND (( + 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) - LIMIT 1) = o0."OrderID")) + WHERE o1."CustomerID" = o2."CustomerID" OR (o1."CustomerID" IS NULL AND o2."CustomerID" IS NULL) + LIMIT 1) = o0."OrderID") """); } @@ -276,7 +276,7 @@ LIMIT @__p_0 OFFSET @__p_0 ) AS t LIMIT @__p_2 OFFSET @__p_1 ) AS t0 - WHERE (t0."OrderID" = o."OrderID") AND (t0."ProductID" = o."ProductID")) + WHERE t0."OrderID" = o."OrderID" AND t0."ProductID" = o."ProductID") """); } @@ -299,7 +299,7 @@ public override async Task Delete_SelectMany(bool async) """ DELETE FROM "Order Details" AS o0 USING "Orders" AS o -WHERE (o."OrderID" = o0."OrderID") AND (o."OrderID" < 10250) +WHERE o."OrderID" = o0."OrderID" AND o."OrderID" < 10250 """); } @@ -318,7 +318,7 @@ INNER JOIN ( FROM "Order Details" AS o1 WHERE o1."ProductID" > 0 ) AS t ON o0."OrderID" = t."OrderID" - WHERE (o0."OrderID" < 10250) AND ((t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID"))) + WHERE o0."OrderID" < 10250 AND t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -330,7 +330,7 @@ public override async Task Delete_Where_using_navigation(bool async) """ DELETE FROM "Order Details" AS o USING "Orders" AS o0 -WHERE (o."OrderID" = o0."OrderID") AND (date_part('year', o0."OrderDate")::int = 2000) +WHERE o."OrderID" = o0."OrderID" AND date_part('year', o0."OrderDate")::int = 2000 """); } @@ -346,7 +346,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") """); } @@ -368,7 +368,7 @@ WHERE o0."OrderID" < 10250 FROM "Order Details" AS o1 WHERE o1."OrderID" > 11250 ) AS t - WHERE (t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID")) + WHERE t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -390,7 +390,7 @@ UNION ALL FROM "Order Details" AS o1 WHERE o1."OrderID" > 11250 ) AS t - WHERE (t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID")) + WHERE t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -412,7 +412,7 @@ WHERE o0."OrderID" < 10250 FROM "Order Details" AS o1 WHERE o1."OrderID" > 11250 ) AS t - WHERE (t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID")) + WHERE t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -434,7 +434,7 @@ WHERE o0."OrderID" < 10250 FROM "Order Details" AS o1 WHERE o1."OrderID" > 11250 ) AS t - WHERE (t."OrderID" = o."OrderID") AND (t."ProductID" = o."ProductID")) + WHERE t."OrderID" = o."OrderID" AND t."ProductID" = o."ProductID") """); } @@ -473,7 +473,7 @@ SELECT 1 FROM "Order Details" WHERE "OrderID" < 10300 ) AS m - WHERE (m."OrderID" = o."OrderID") AND (m."ProductID" = o."ProductID")) + WHERE m."OrderID" = o."OrderID" AND m."ProductID" = o."ProductID") """); } @@ -489,7 +489,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") """); } @@ -534,7 +534,7 @@ WHERE o1."OrderID" < 10300 ORDER BY o1."OrderID" NULLS FIRST LIMIT @__p_1 OFFSET @__p_0 ) AS t ON o0."OrderID" = t."OrderID" - WHERE (o0."OrderID" < 10276) AND ((o0."OrderID" = o."OrderID") AND (o0."ProductID" = o."ProductID"))) + WHERE o0."OrderID" < 10276 AND o0."OrderID" = o."OrderID" AND o0."ProductID" = o."ProductID") """); } @@ -555,7 +555,7 @@ WHERE o1."OrderID" < 10300 ORDER BY o1."OrderID" NULLS FIRST LIMIT 100 OFFSET 0 ) AS t - WHERE (o0."OrderID" < 10276) AND ((o0."OrderID" = o."OrderID") AND (o0."ProductID" = o."ProductID"))) + WHERE o0."OrderID" < 10276 AND o0."OrderID" = o."OrderID" AND o0."ProductID" = o."ProductID") """); } @@ -576,7 +576,7 @@ WHERE o1."OrderID" < o0."OrderID" ORDER BY o1."OrderID" NULLS FIRST LIMIT 100 OFFSET 0 ) AS t ON TRUE - WHERE (o0."OrderID" < 10276) AND ((o0."OrderID" = o."OrderID") AND (o0."ProductID" = o."ProductID"))) + WHERE o0."OrderID" < 10276 AND o0."OrderID" = o."OrderID" AND o0."ProductID" = o."ProductID") """); } @@ -597,7 +597,7 @@ WHERE o1."OrderID" < o0."OrderID" ORDER BY o1."OrderID" NULLS FIRST LIMIT 100 OFFSET 0 ) AS t ON TRUE - WHERE (o0."OrderID" < 10276) AND ((o0."OrderID" = o."OrderID") AND (o0."ProductID" = o."ProductID"))) + WHERE o0."OrderID" < 10276 AND o0."OrderID" = o."OrderID" AND o0."ProductID" = o."ProductID") """); } @@ -864,7 +864,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" @@ -892,12 +892,12 @@ WHERE EXISTS ( SELECT 1 FROM "Orders" AS o GROUP BY o."CustomerID" - HAVING (count(*)::int > 11) AND (( + 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) - LIMIT 1) = c."CustomerID")) + WHERE o."CustomerID" = o0."CustomerID" OR (o."CustomerID" IS NULL AND o0."CustomerID" IS NULL) + LIMIT 1) = c."CustomerID") """); } @@ -941,7 +941,7 @@ public override async Task Update_Where_using_navigation_2_set_constant(bool asy SET "Quantity" = 1::smallint FROM "Orders" AS o0 LEFT JOIN "Customers" AS c ON o0."CustomerID" = c."CustomerID" -WHERE (o."OrderID" = o0."OrderID") AND (c."City" = 'Seattle') +WHERE o."OrderID" = o0."OrderID" AND c."City" = 'Seattle' """); } @@ -954,7 +954,7 @@ public override async Task Update_Where_SelectMany_set_null(bool async) UPDATE "Orders" AS o SET "OrderDate" = NULL FROM "Customers" AS c -WHERE (c."CustomerID" = o."CustomerID") AND (c."CustomerID" LIKE 'F%') +WHERE c."CustomerID" = o."CustomerID" AND c."CustomerID" LIKE 'F%' """); } @@ -1167,7 +1167,7 @@ public override async Task Update_with_join_set_constant(bool async) FROM "Orders" AS o WHERE o."OrderID" < 10300 ) AS t -WHERE (c."CustomerID" = t."CustomerID") AND (c."CustomerID" LIKE 'F%') +WHERE c."CustomerID" = t."CustomerID" AND c."CustomerID" LIKE 'F%' """); } @@ -1224,7 +1224,7 @@ public override async Task Update_with_cross_apply_set_constant(bool async) JOIN LATERAL ( SELECT o."OrderID", o."CustomerID", o."EmployeeID", o."OrderDate" FROM "Orders" AS o - WHERE (o."OrderID" < 10300) AND (date_part('year', o."OrderDate")::int < length(c0."ContactName")::int) + WHERE o."OrderID" < 10300 AND date_part('year', o."OrderDate")::int < length(c0."ContactName")::int ) AS t ON TRUE WHERE c0."CustomerID" LIKE 'F%' ) AS t0 @@ -1246,7 +1246,7 @@ public override async Task Update_with_outer_apply_set_constant(bool async) LEFT JOIN LATERAL ( SELECT o."OrderID", o."CustomerID", o."EmployeeID", o."OrderDate" FROM "Orders" AS o - WHERE (o."OrderID" < 10300) AND (date_part('year', o."OrderDate")::int < length(c0."ContactName")::int) + WHERE o."OrderID" < 10300 AND date_part('year', o."OrderDate")::int < length(c0."ContactName")::int ) AS t ON TRUE WHERE c0."CustomerID" LIKE 'F%' ) AS t0 @@ -1269,7 +1269,7 @@ public override async Task Update_with_cross_join_left_join_set_constant(bool as CROSS JOIN ( SELECT c1."CustomerID", c1."Address", c1."City", c1."CompanyName", c1."ContactName", c1."ContactTitle", c1."Country", c1."Fax", c1."Phone", c1."PostalCode", c1."Region" FROM "Customers" AS c1 - WHERE c1."City" IS NOT NULL AND (c1."City" LIKE 'S%') + WHERE c1."City" IS NOT NULL AND c1."City" LIKE 'S%' ) AS t LEFT JOIN ( SELECT o."OrderID", o."CustomerID", o."EmployeeID", o."OrderDate" @@ -1297,12 +1297,12 @@ public override async Task Update_with_cross_join_cross_apply_set_constant(bool CROSS JOIN ( SELECT c1."CustomerID" FROM "Customers" AS c1 - WHERE c1."City" IS NOT NULL AND (c1."City" LIKE 'S%') + WHERE c1."City" IS NOT NULL AND c1."City" LIKE 'S%' ) AS t JOIN LATERAL ( SELECT o."OrderID", o."CustomerID", o."EmployeeID", o."OrderDate" FROM "Orders" AS o - WHERE (o."OrderID" < 10300) AND (date_part('year', o."OrderDate")::int < length(c0."ContactName")::int) + WHERE o."OrderID" < 10300 AND date_part('year', o."OrderDate")::int < length(c0."ContactName")::int ) AS t0 ON TRUE WHERE c0."CustomerID" LIKE 'F%' ) AS t1 @@ -1325,12 +1325,12 @@ public override async Task Update_with_cross_join_outer_apply_set_constant(bool CROSS JOIN ( SELECT c1."CustomerID", c1."Address", c1."City", c1."CompanyName", c1."ContactName", c1."ContactTitle", c1."Country", c1."Fax", c1."Phone", c1."PostalCode", c1."Region" FROM "Customers" AS c1 - WHERE c1."City" IS NOT NULL AND (c1."City" LIKE 'S%') + WHERE c1."City" IS NOT NULL AND c1."City" LIKE 'S%' ) AS t LEFT JOIN LATERAL ( SELECT o."OrderID", o."CustomerID", o."EmployeeID", o."OrderDate" FROM "Orders" AS o - WHERE (o."OrderID" < 10300) AND (date_part('year', o."OrderDate")::int < length(c0."ContactName")::int) + WHERE o."OrderID" < 10300 AND date_part('year', o."OrderDate")::int < length(c0."ContactName")::int ) AS t0 ON TRUE WHERE c0."CustomerID" LIKE 'F%' ) AS t1 @@ -1438,7 +1438,7 @@ await AssertUpdate( SET "Quantity" = 1::smallint FROM "Products" AS p, "Orders" AS o0 -WHERE (o."OrderID" = o0."OrderID") AND ((o."ProductID" = p."ProductID") AND (p."Discontinued" AND (o0."OrderDate" > TIMESTAMP '1990-01-01 00:00:00'))) +WHERE o."OrderID" = o0."OrderID" AND o."ProductID" = p."ProductID" AND p."Discontinued" AND o0."OrderDate" > TIMESTAMP '1990-01-01 00:00:00' """); } diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs index d8dba72a0..b41aabb9b 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesNpgsqlTest.cs @@ -28,7 +28,7 @@ public override async Task Delete_where_hierarchy_derived(bool async) AssertSql( """ DELETE FROM "Kiwi" AS k -WHERE (k."CountryId" = 1) AND (k."Name" = 'Great spotted kiwi') +WHERE k."CountryId" = 1 AND k."Name" = 'Great spotted kiwi' """); } @@ -48,7 +48,7 @@ UNION ALL SELECT k."Id", k."CountryId", k."Name", k."Species", k."EagleId", k."IsFlightless", NULL AS "Group", k."FoundOn", 'Kiwi' AS "Discriminator" FROM "Kiwi" AS k ) AS t - WHERE ((t."CountryId" = 1) AND (c."Id" = t."CountryId")) AND (t."CountryId" > 0)) > 0 + WHERE t."CountryId" = 1 AND c."Id" = t."CountryId" AND t."CountryId" > 0) > 0 """); } @@ -65,7 +65,7 @@ SELECT count(*)::int SELECT k."Id", k."CountryId", k."Name", k."Species", k."EagleId", k."IsFlightless", NULL AS "Group", k."FoundOn", 'Kiwi' AS "Discriminator" FROM "Kiwi" AS k ) AS t - WHERE ((t."CountryId" = 1) AND (c."Id" = t."CountryId")) AND (t."CountryId" > 0)) > 0 + WHERE t."CountryId" = 1 AND c."Id" = t."CountryId" AND t."CountryId" > 0) > 0 """); } @@ -126,7 +126,7 @@ public override async Task Update_where_hierarchy_derived(bool async) """ UPDATE "Kiwi" AS k SET "Name" = 'Kiwi' -WHERE (k."CountryId" = 1) AND (k."Name" = 'Great spotted kiwi') +WHERE k."CountryId" = 1 AND k."Name" = 'Great spotted kiwi' """); } @@ -147,7 +147,7 @@ UNION ALL SELECT k."Id", k."CountryId", k."Name", k."Species", k."EagleId", k."IsFlightless", NULL AS "Group", k."FoundOn", 'Kiwi' AS "Discriminator" FROM "Kiwi" AS k ) AS t - WHERE ((t."CountryId" = 1) AND (c."Id" = t."CountryId")) AND (t."CountryId" > 0)) > 0 + WHERE t."CountryId" = 1 AND c."Id" = t."CountryId" AND t."CountryId" > 0) > 0 """); } @@ -165,7 +165,7 @@ SELECT count(*)::int SELECT k."Id", k."CountryId", k."Name", k."Species", k."EagleId", k."IsFlightless", NULL AS "Group", k."FoundOn", 'Kiwi' AS "Discriminator" FROM "Kiwi" AS k ) AS t - WHERE ((t."CountryId" = 1) AND (c."Id" = t."CountryId")) AND (t."CountryId" > 0)) > 0 + WHERE t."CountryId" = 1 AND c."Id" = t."CountryId" AND t."CountryId" > 0) > 0 """); } diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs index f0bb0bf1a..58a9d0108 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesNpgsqlTest.cs @@ -48,7 +48,7 @@ UNION ALL SELECT k."Id", k."CountryId", k."Name", k."Species", k."EagleId", k."IsFlightless", NULL AS "Group", k."FoundOn", 'Kiwi' AS "Discriminator" FROM "Kiwi" AS k ) AS t - WHERE (c."Id" = t."CountryId") AND (t."CountryId" > 0)) > 0 + WHERE c."Id" = t."CountryId" AND t."CountryId" > 0) > 0 """); } @@ -65,7 +65,7 @@ SELECT count(*)::int SELECT k."Id", k."CountryId", k."Name", k."Species", k."EagleId", k."IsFlightless", NULL AS "Group", k."FoundOn", 'Kiwi' AS "Discriminator" FROM "Kiwi" AS k ) AS t - WHERE (c."Id" = t."CountryId") AND (t."CountryId" > 0)) > 0 + WHERE c."Id" = t."CountryId" AND t."CountryId" > 0) > 0 """); } @@ -147,7 +147,7 @@ UNION ALL SELECT k."Id", k."CountryId", k."Name", k."Species", k."EagleId", k."IsFlightless", NULL AS "Group", k."FoundOn", 'Kiwi' AS "Discriminator" FROM "Kiwi" AS k ) AS t - WHERE (c."Id" = t."CountryId") AND (t."CountryId" > 0)) > 0 + WHERE c."Id" = t."CountryId" AND t."CountryId" > 0) > 0 """); } @@ -165,7 +165,7 @@ SELECT count(*)::int SELECT k."Id", k."CountryId", k."Name", k."Species", k."EagleId", k."IsFlightless", NULL AS "Group", k."FoundOn", 'Kiwi' AS "Discriminator" FROM "Kiwi" AS k ) AS t - WHERE (c."Id" = t."CountryId") AND (t."CountryId" > 0)) > 0 + WHERE c."Id" = t."CountryId" AND t."CountryId" > 0) > 0 """); } diff --git a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs index 0a7811817..89bc6c5b1 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesNpgsqlTest.cs @@ -41,7 +41,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 (a."CountryId" > 0)) > 0 + WHERE a."CountryId" = 1 AND c."Id" = a."CountryId" AND a."CountryId" > 0) > 0 """); } @@ -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 """); } @@ -132,7 +132,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 (a."CountryId" > 0)) > 0 + WHERE a."CountryId" = 1 AND c."Id" = a."CountryId" 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 983e50d96..189e70269 100644 --- a/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesNpgsqlTest.cs @@ -111,7 +111,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 (a."CountryId" > 0)) > 0 + WHERE c."Id" = a."CountryId" AND a."CountryId" > 0) > 0 """); } @@ -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 928b71871..475b29583 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ArrayArrayQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ArrayArrayQueryTest.cs @@ -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) """); } @@ -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) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs index fc9f4ea57..0333ece2f 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ArrayListQueryTest.cs @@ -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) """); } @@ -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) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/BigIntegerQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/BigIntegerQueryTest.cs index b53deed97..635ca19eb 100644 --- a/test/EFCore.PG.FunctionalTests/Query/BigIntegerQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/BigIntegerQueryTest.cs @@ -128,7 +128,7 @@ await AssertQuery( """ SELECT e."Id", e."BigInteger" FROM "Entities" AS e -WHERE (e."BigInteger" % 2) = 0 +WHERE e."BigInteger" % 2 = 0 """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/CitextQueryTest.cs index 4863889bf..451e6acc5 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_1))::citext = @__param_0_1::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_1))::citext = @__param_0_1::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_1::citext)) +WHERE @__param_0 = '' OR (s."CaseInsensitiveText" IS NOT NULL AND right(s."CaseInsensitiveText", length(@__param_0_1))::citext = @__param_0_1::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 """); } @@ -158,7 +158,7 @@ public void Contains_param_pattern() SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE (@__param_0 = '') OR (strpos(s."CaseInsensitiveText", @__param_0) > 0) +WHERE @__param_0 = '' OR strpos(s."CaseInsensitiveText", @__param_0) > 0 LIMIT 2 """); } @@ -177,7 +177,7 @@ public void Contains_param_instance() SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE (s."CaseInsensitiveText" = '') OR (strpos(@__param_0, s."CaseInsensitiveText") > 0) +WHERE s."CaseInsensitiveText" = '' OR strpos(@__param_0, s."CaseInsensitiveText") > 0 LIMIT 2 """); } @@ -193,7 +193,7 @@ public void IndexOf_literal() """ SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE (strpos(s."CaseInsensitiveText", 'ometex') - 1) = 1 +WHERE strpos(s."CaseInsensitiveText", 'ometex') - 1 = 1 LIMIT 2 """); } @@ -212,7 +212,7 @@ public void IndexOf_param_pattern() SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE (strpos(s."CaseInsensitiveText", @__param_0) - 1) = 1 +WHERE strpos(s."CaseInsensitiveText", @__param_0) - 1 = 1 LIMIT 2 """); } @@ -231,7 +231,7 @@ public void IndexOf_param_instance() SELECT s."Id", s."CaseInsensitiveText" FROM "SomeEntities" AS s -WHERE (strpos(@__param_0, s."CaseInsensitiveText") - 1) = 5 +WHERE strpos(@__param_0, s."CaseInsensitiveText") - 1 = 5 LIMIT 2 """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/Ef6GroupByNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/Ef6GroupByNpgsqlTest.cs index 7a1019cb3..9c367fd25 100644 --- a/test/EFCore.PG.FunctionalTests/Query/Ef6GroupByNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/Ef6GroupByNpgsqlTest.cs @@ -23,15 +23,15 @@ 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) +WHERE p."MiddleInitial" = 'Q' AND p."Age" = 20 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 """); } @@ -41,18 +41,18 @@ public override async Task Whats_new_2021_sample_5(bool async) await base.Whats_new_2021_sample_5(async); AssertSql( - """ +""" 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 """); } @@ -62,11 +62,11 @@ public override async Task Whats_new_2021_sample_6(bool async) await base.Whats_new_2021_sample_6(async); AssertSql( - """ +""" SELECT ( SELECT p1."MiddleInitial" FROM "Person" AS p1 - WHERE (p1."Age" = 20) AND (p."Id" = p1."Id") + WHERE p1."Age" = 20 AND p."Id" = p1."Id" LIMIT 1) FROM "Person" AS p WHERE p."Age" = 20 @@ -74,7 +74,7 @@ GROUP BY p."Id" ORDER BY ( SELECT p1."MiddleInitial" FROM "Person" AS p1 - WHERE (p1."Age" = 20) AND (p."Id" = p1."Id") + WHERE p1."Age" = 20 AND p."Id" = p1."Id" LIMIT 1) NULLS FIRST """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/EntitySplittingQueryNpgsqlTest.cs index f3074e695..27310dd78 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" @@ -705,8 +705,8 @@ UNION ALL LEFT JOIN ( SELECT o."BaseEntityId", o."Id", o."OwnedIntValue1", o."OwnedIntValue2", o1."OwnedIntValue3", o0."OwnedIntValue4", o."OwnedStringValue1", o."OwnedStringValue2", o1."OwnedStringValue3", o0."OwnedStringValue4" FROM "OwnedReferencePart1" AS o - INNER JOIN "OwnedReferencePart4" AS o0 ON (o."BaseEntityId" = o0."BaseEntityId") AND (o."Id" = o0."Id") - INNER JOIN "OwnedReferencePart3" AS o1 ON (o."BaseEntityId" = o1."BaseEntityId") AND (o."Id" = o1."Id") + INNER JOIN "OwnedReferencePart4" AS o0 ON o."BaseEntityId" = o0."BaseEntityId" AND o."Id" = o0."Id" + INNER JOIN "OwnedReferencePart3" AS o1 ON o."BaseEntityId" = o1."BaseEntityId" AND o."Id" = o1."Id" ) AS t0 ON t."Id" = t0."BaseEntityId" ORDER BY t."Id" NULLS FIRST, t0."BaseEntityId" NULLS FIRST """); @@ -751,8 +751,8 @@ UNION ALL LEFT JOIN ( SELECT o."MiddleEntityId", o."Id", o."OwnedIntValue1", o."OwnedIntValue2", o1."OwnedIntValue3", o0."OwnedIntValue4", o."OwnedStringValue1", o."OwnedStringValue2", o1."OwnedStringValue3", o0."OwnedStringValue4" FROM "OwnedReferencePart1" AS o - INNER JOIN "OwnedReferencePart4" AS o0 ON (o."MiddleEntityId" = o0."MiddleEntityId") AND (o."Id" = o0."Id") - INNER JOIN "OwnedReferencePart3" AS o1 ON (o."MiddleEntityId" = o1."MiddleEntityId") AND (o."Id" = o1."Id") + INNER JOIN "OwnedReferencePart4" AS o0 ON o."MiddleEntityId" = o0."MiddleEntityId" AND o."Id" = o0."Id" + INNER JOIN "OwnedReferencePart3" AS o1 ON o."MiddleEntityId" = o1."MiddleEntityId" AND o."Id" = o1."Id" ) AS t0 ON t."Id" = t0."MiddleEntityId" ORDER BY t."Id" NULLS FIRST, t0."MiddleEntityId" NULLS FIRST """); diff --git a/test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs index 5fb1a2f79..f3637122c 100644 --- a/test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs @@ -189,7 +189,7 @@ await AssertQuery( SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE ((@__start_0 <= date_trunc('day', m."Timeline" AT TIME ZONE 'UTC')::timestamptz) AND (m."Timeline" < @__end_1)) AND m."Timeline" = ANY (@__dates_2) +WHERE @__start_0 <= date_trunc('day', m."Timeline" AT TIME ZONE 'UTC')::timestamptz AND m."Timeline" < @__end_1 AND m."Timeline" = ANY (@__dates_2) """); } @@ -303,7 +303,7 @@ public override async Task Where_TimeSpan_Milliseconds(bool async) """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (floor(date_part('millisecond', m."Duration"))::int % 1000) = 1 +WHERE floor(date_part('millisecond', m."Duration"))::int % 1000 = 1 """); } @@ -319,7 +319,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (date_part('epoch', m."Duration") / 86400.0) < 0.042000000000000003 +WHERE date_part('epoch', m."Duration") / 86400.0 < 0.042000000000000003 """); } @@ -335,7 +335,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (date_part('epoch', m."Duration") / 3600.0) < 1.02 +WHERE date_part('epoch', m."Duration") / 3600.0 < 1.02 """); } @@ -351,7 +351,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (date_part('epoch', m."Duration") / 60.0) < 61.0 +WHERE date_part('epoch', m."Duration") / 60.0 < 61.0 """); } @@ -383,7 +383,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (date_part('epoch', m."Duration") / 0.001) < 3700000.0 +WHERE date_part('epoch', m."Duration") / 0.001 < 3700000.0 """); } @@ -537,7 +537,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (m."Date" + INTERVAL '3 years') = DATE '1993-11-10' +WHERE m."Date" + INTERVAL '3 years' = DATE '1993-11-10' """); } @@ -552,7 +552,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (m."Date" + INTERVAL '3 months') = DATE '1991-02-10' +WHERE m."Date" + INTERVAL '3 months' = DATE '1991-02-10' """); } @@ -567,7 +567,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (m."Date" + INTERVAL '3 days') = DATE '1990-11-13' +WHERE m."Date" + INTERVAL '3 days' = DATE '1990-11-13' """); } @@ -634,7 +634,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (m."Time" + INTERVAL '3 hours') = TIME '13:15:50.5' +WHERE m."Time" + INTERVAL '3 hours' = TIME '13:15:50.5' """); } @@ -649,7 +649,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (m."Time" + INTERVAL '3 mins') = TIME '10:18:50.5' +WHERE m."Time" + INTERVAL '3 mins' = TIME '10:18:50.5' """); } @@ -664,7 +664,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (m."Time" + INTERVAL '03:00:00') = TIME '13:15:50.5' +WHERE m."Time" + INTERVAL '03:00:00' = TIME '13:15:50.5' """); } @@ -679,7 +679,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (m."Time" >= TIME '10:00:00') AND (m."Time" < TIME '11:00:00') +WHERE m."Time" >= TIME '10:00:00' AND m."Time" < TIME '11:00:00' """); } @@ -694,7 +694,7 @@ await AssertQuery( """ SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE (m."Time" - TIME '10:00:00') = INTERVAL '00:15:50.5' +WHERE m."Time" - TIME '10:00:00' = INTERVAL '00:15:50.5' """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs index a916832b3..f8f2b94d4 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 7427f8859..cb5976b6f 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs @@ -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/JsonStringQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs index f51989495..8f31ae7a7 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs @@ -143,7 +143,7 @@ public void JsonContains_with_string_column() """ SELECT count(*)::int FROM "JsonEntities" AS j -WHERE j."CustomerJsonb" @> CAST(('{"Name": "' || COALESCE(j."SomeString", '')) || '", "Age": 25}' AS jsonb) +WHERE j."CustomerJsonb" @> CAST('{"Name": "' || COALESCE(j."SomeString", '') || '", "Age": 25}' AS jsonb) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs index 86a5ba368..c8867f408 100644 --- a/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/LTreeQueryTest.cs @@ -211,7 +211,7 @@ public void LTree_concat() """ SELECT l."Id", l."Path", l."PathAsString", l."SomeString" FROM "LTreeEntities" AS l -WHERE (l."Path"::text || '.Astronomy') = 'Top.Science.Astronomy' +WHERE l."Path"::text || '.Astronomy' = 'Top.Science.Astronomy' LIMIT 2 """); } @@ -428,7 +428,7 @@ public void Subpath2() """ SELECT l."Id", l."Path", l."PathAsString", l."SomeString" FROM "LTreeEntities" AS l -WHERE (nlevel(l."Path") > 2) AND (subpath(l."Path", 2) = 'Astronomy.Astrophysics') +WHERE nlevel(l."Path") > 2 AND subpath(l."Path", 2) = 'Astronomy.Astrophysics' LIMIT 2 """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/LegacyTimestampQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/LegacyTimestampQueryTest.cs index bdca2b7c8..96c6f620d 100644 --- a/test/EFCore.PG.FunctionalTests/Query/LegacyTimestampQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/LegacyTimestampQueryTest.cs @@ -67,7 +67,7 @@ public virtual async Task Where_datetime_utcnow() SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeOffset", e."TimestamptzDateTime" FROM "Entities" AS e -WHERE (now() AT TIME ZONE 'UTC') <> @__myDatetime_0 +WHERE now() AT TIME ZONE 'UTC' <> @__myDatetime_0 """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/NetworkQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NetworkQueryNpgsqlTest.cs index 1c4d91df1..daa049ea4 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 """); } @@ -925,7 +925,7 @@ public void IPAddress_inet_Add_int() """ SELECT n."Id", n."Cidr", n."Inet", n."Macaddr", n."Macaddr8", n."TextInet", n."TextMacaddr" FROM "NetTestEntities" AS n -WHERE (n."Inet" + 1) = INET '192.168.1.2' +WHERE n."Inet" + 1 = INET '192.168.1.2' LIMIT 2 """); } @@ -956,7 +956,7 @@ public void IPAddress_inet_Subtract_int() """ SELECT n."Id", n."Cidr", n."Inet", n."Macaddr", n."Macaddr8", n."TextInet", n."TextMacaddr" FROM "NetTestEntities" AS n -WHERE (n."Inet" - 1) = INET '192.168.1.1' +WHERE n."Inet" - 1 = INET '192.168.1.1' LIMIT 2 """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs index f7daf2f81..e5c49de7a 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs @@ -118,7 +118,7 @@ public override async Task Collate_case_insensitive(bool async) """ SELECT count(*)::int FROM "Customers" AS c -WHERE (c."ContactName" COLLATE "some-case-insensitive-collation") = 'maria anders' +WHERE c."ContactName" COLLATE "some-case-insensitive-collation" = 'maria anders' """); } @@ -130,7 +130,7 @@ public override async Task Collate_case_sensitive(bool async) """ SELECT count(*)::int FROM "Customers" AS c -WHERE (c."ContactName" COLLATE "POSIX") = 'maria anders' +WHERE c."ContactName" COLLATE "POSIX" = 'maria anders' """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindFunctionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindFunctionsQueryNpgsqlTest.cs index 22ebc2d97..288ffba5d 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 ee8f05077..aa8f866fa 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindGroupByQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindGroupByQueryNpgsqlTest.cs @@ -269,7 +269,7 @@ public override async Task GroupBy_aggregate_projecting_conditional_expression(b SELECT o."OrderDate" AS "Key", CASE WHEN count(*)::int = 0 THEN 1 ELSE COALESCE(sum(CASE - WHEN (o."OrderID" % 2) = 0 THEN 1 + WHEN o."OrderID" % 2 = 0 THEN 1 ELSE 0 END), 0)::int / count(*)::int END AS "SomeValue" @@ -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,10 +2278,10 @@ 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) +WHERE e."Title" = 'Sales Representative' AND e."EmployeeID" = 1 GROUP BY e."Title" """); } @@ -2296,7 +2296,7 @@ public override async Task GroupBy_Shadow2(bool async) FROM ( SELECT e."Title" FROM "Employees" AS e - WHERE (e."Title" = 'Sales Representative') AND (e."EmployeeID" = 1) + WHERE e."Title" = 'Sales Representative' AND e."EmployeeID" = 1 GROUP BY e."Title" ) AS t LEFT JOIN ( @@ -2304,7 +2304,7 @@ LEFT JOIN ( FROM ( SELECT e0."EmployeeID", e0."City", e0."Country", e0."FirstName", e0."ReportsTo", e0."Title", ROW_NUMBER() OVER(PARTITION BY e0."Title" ORDER BY e0."EmployeeID" NULLS FIRST) AS row FROM "Employees" AS e0 - WHERE (e0."Title" = 'Sales Representative') AND (e0."EmployeeID" = 1) + WHERE e0."Title" = 'Sales Representative' AND e0."EmployeeID" = 1 ) AS t1 WHERE t1.row <= 1 ) AS t0 ON t."Title" = t0."Title" @@ -2320,7 +2320,7 @@ public override async Task GroupBy_Shadow3(bool async) SELECT ( SELECT e0."Title" FROM "Employees" AS e0 - WHERE (e0."EmployeeID" = 1) AND (e."EmployeeID" = e0."EmployeeID") + WHERE e0."EmployeeID" = 1 AND e."EmployeeID" = e0."EmployeeID" LIMIT 1) FROM "Employees" AS e WHERE e."EmployeeID" = 1 @@ -2669,13 +2669,13 @@ public override async Task GroupBy_Count_in_projection(bool async) SELECT o."OrderID", o."OrderDate", EXISTS ( SELECT 1 FROM "Order Details" AS o0 - WHERE (o."OrderID" = o0."OrderID") AND (o0."ProductID" < 25)) AS "HasOrderDetails", ( + WHERE o."OrderID" = o0."OrderID" AND o0."ProductID" < 25) AS "HasOrderDetails", ( SELECT count(*)::int FROM ( SELECT p."ProductName" FROM "Order Details" AS o1 INNER JOIN "Products" AS p ON o1."ProductID" = p."ProductID" - WHERE (o."OrderID" = o1."OrderID") AND (o1."ProductID" < 25) + WHERE o."OrderID" = o1."OrderID" AND o1."ProductID" < 25 GROUP BY p."ProductName" ) AS t) > 1 AS "HasMultipleProducts" FROM "Orders" AS o @@ -2915,7 +2915,7 @@ public override async Task GroupBy_Min_Where_optional_relationship_2(bool async) FROM "Orders" AS o LEFT JOIN "Customers" AS c ON o."CustomerID" = c."CustomerID" GROUP BY c."CustomerID" -HAVING (count(*)::int < 2) OR (count(*)::int > 2) +HAVING count(*)::int < 2 OR count(*)::int > 2 """); } @@ -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)) """); } @@ -3225,14 +3225,14 @@ public override async Task Where_select_function_groupby_followed_by_another_sel AssertSql( """ SELECT o."CustomerID" AS "Key", COALESCE(sum(CASE - WHEN (2020 - date_part('year', o."OrderDate")::int) <= 30 THEN o."OrderID" + WHEN 2020 - date_part('year', o."OrderDate")::int <= 30 THEN o."OrderID" ELSE 0 END), 0)::int AS "Sum1", COALESCE(sum(CASE - WHEN ((2020 - date_part('year', o."OrderDate")::int) > 30) AND ((2020 - date_part('year', o."OrderDate")::int) <= 60) THEN o."OrderID" + WHEN 2020 - date_part('year', o."OrderDate")::int > 30 AND 2020 - date_part('year', o."OrderDate")::int <= 60 THEN o."OrderID" 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 @@ -3482,7 +3482,7 @@ public override async Task Complex_query_with_group_by_in_subquery5(bool async) """ SELECT t.c, t."ProductID", t0."CustomerID", t0."City" FROM ( - SELECT COALESCE(sum(o."ProductID" + (o."OrderID" * 1000)), 0)::int AS c, o."ProductID", min(o."OrderID" / 100) AS c0 + SELECT COALESCE(sum(o."ProductID" + o."OrderID" * 1000), 0)::int AS c, o."ProductID", min(o."OrderID" / 100) AS c0 FROM "Order Details" AS o INNER JOIN "Orders" AS o0 ON o."OrderID" = o0."OrderID" LEFT JOIN "Customers" AS c ON o0."CustomerID" = c."CustomerID" @@ -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 @@ -3788,7 +3788,7 @@ LEFT JOIN ( LEFT JOIN "Customers" AS c0 ON o0."CustomerID" = c0."CustomerID" ) AS t3 ) AS t2 - WHERE (1 < t2.row) AND (t2.row <= 3) + WHERE 1 < t2.row AND t2.row <= 3 ) AS t1 ON t0."Key" = t1."Key" ORDER BY t0."Key" NULLS FIRST, t1."OrderID" NULLS FIRST """); diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindMiscellaneousQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindMiscellaneousQueryNpgsqlTest.cs index b7f3cc12e..8213d5540 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindMiscellaneousQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindMiscellaneousQueryNpgsqlTest.cs @@ -72,7 +72,7 @@ await AssertQuery( """ SELECT o."OrderID", o."CustomerID", o."EmployeeID", o."OrderDate" FROM "Orders" AS o -WHERE (o."OrderDate" - INTERVAL '1 00:00:00') = TIMESTAMP '1997-10-08 00:00:00' +WHERE o."OrderDate" - INTERVAL '1 00:00:00' = TIMESTAMP '1997-10-08 00:00:00' """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindSetOperationsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindSetOperationsQueryNpgsqlTest.cs index 454808f19..977273c33 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindSetOperationsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindSetOperationsQueryNpgsqlTest.cs @@ -144,7 +144,7 @@ await AssertQuery( SELECT o1."OrderID", o1."CustomerID" FROM "Orders" AS o1 ) AS t0 -WHERE (t0."CustomerID" = ( +WHERE t0."CustomerID" = ( SELECT t1."CustomerID" FROM ( SELECT NULL::int AS "OrderID", o2."CustomerID" @@ -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" diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindWhereQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindWhereQueryNpgsqlTest.cs index 898a63191..6c7cda82b 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindWhereQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindWhereQueryNpgsqlTest.cs @@ -234,7 +234,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."City" <> 'Sao Paulo') OR c."City" IS NULL) OR ((c."Country" <> 'Brazil') OR c."Country" IS NULL) +WHERE c."City" <> 'Sao Paulo' OR c."City" IS NULL OR c."Country" <> 'Brazil' OR c."Country" IS NULL """); } @@ -471,7 +471,7 @@ public async Task Row_value_not_equals() """ SELECT count(*)::int FROM "Customers" AS c -WHERE (c."CustomerID" <> 'OCEAN') OR ((c."City" <> 'Buenos Aires') OR c."City" IS NULL) +WHERE c."CustomerID" <> 'OCEAN' OR c."City" <> 'Buenos Aires' OR c."City" IS NULL """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/NullSemanticsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NullSemanticsQueryNpgsqlTest.cs index e0173afd4..3a4c20734 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NullSemanticsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NullSemanticsQueryNpgsqlTest.cs @@ -69,19 +69,19 @@ await AssertQueryScalar(async, ss => ss.Set() """ SELECT e."Id" FROM "Entities1" AS e -WHERE ((e."IntA", e."BoolA") = (e."IntB", e."BoolB")) AND ((e."NullableStringA" = e."NullableStringB") OR (e."NullableStringA" IS NULL AND e."NullableStringB" IS NULL)) +WHERE (e."IntA", e."BoolA") = (e."IntB", e."BoolB") AND (e."NullableStringA" = e."NullableStringB" OR (e."NullableStringA" IS NULL AND e."NullableStringB" IS NULL)) """, // """ SELECT e."Id" FROM "Entities1" AS e -WHERE ((e."IntA", e."BoolA") = (e."IntB", e."BoolB")) AND ((e."NullableStringA" = e."NullableStringB") OR (e."NullableStringA" IS NULL AND e."NullableStringB" IS NULL)) +WHERE (e."IntA", e."BoolA") = (e."IntB", e."BoolB") AND (e."NullableStringA" = e."NullableStringB" OR (e."NullableStringA" IS NULL AND e."NullableStringB" IS NULL)) """, // """ SELECT e."Id" FROM "Entities1" AS e -WHERE ((e."IntA", e."StringA") = (e."IntB", e."StringB")) AND ((e."NullableBoolA" = e."NullableBoolB") OR (e."NullableBoolA" IS NULL AND e."NullableBoolB" IS NULL)) +WHERE (e."IntA", e."StringA") = (e."IntB", e."StringB") AND (e."NullableBoolA" = e."NullableBoolB" OR (e."NullableBoolA" IS NULL AND e."NullableBoolB" IS NULL)) """); } @@ -119,25 +119,25 @@ SELECT e."Id" """ SELECT e."Id" FROM "Entities1" AS e -WHERE (e."IntA" <> e."IntB") OR ((e."StringA" <> e."NullableStringB") OR e."NullableStringB" IS NULL) +WHERE e."IntA" <> e."IntB" OR e."StringA" <> e."NullableStringB" OR e."NullableStringB" IS NULL """, // """ SELECT e."Id" FROM "Entities1" AS e -WHERE (e."IntA" <> e."IntB") OR ((e."NullableStringA" <> e."StringB") OR e."NullableStringA" IS NULL) +WHERE e."IntA" <> e."IntB" OR e."NullableStringA" <> e."StringB" OR e."NullableStringA" IS NULL """, // """ SELECT e."Id" FROM "Entities1" AS e -WHERE (e."IntA" <> e."IntB") OR (((e."NullableStringA" <> e."NullableStringB") OR (e."NullableStringA" IS NULL OR e."NullableStringB" IS NULL)) AND (e."NullableStringA" IS NOT NULL OR e."NullableStringB" IS NOT NULL)) +WHERE e."IntA" <> e."IntB" OR ((e."NullableStringA" <> e."NullableStringB" OR e."NullableStringA" IS NULL OR e."NullableStringB" IS NULL) AND (e."NullableStringA" IS NOT NULL OR e."NullableStringB" IS NOT NULL)) """, // """ SELECT e."Id" FROM "Entities1" AS e -WHERE ((e."IntA", e."StringA") <> (e."IntB", e."StringB")) OR (((e."NullableBoolA" <> e."NullableBoolB") OR (e."NullableBoolA" IS NULL OR e."NullableBoolB" IS NULL)) AND (e."NullableBoolA" IS NOT NULL OR e."NullableBoolB" IS NOT NULL)) +WHERE (e."IntA", e."StringA") <> (e."IntB", e."StringB") OR ((e."NullableBoolA" <> e."NullableBoolB" OR e."NullableBoolA" IS NULL OR e."NullableBoolB" IS NULL) AND (e."NullableBoolA" IS NOT NULL OR e."NullableBoolB" IS NOT NULL)) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/OperatorsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/OperatorsQueryNpgsqlTest.cs index f21fe18ba..6c5b0e3fd 100644 --- a/test/EFCore.PG.FunctionalTests/Query/OperatorsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/OperatorsQueryNpgsqlTest.cs @@ -52,23 +52,22 @@ CROSS JOIN "OperatorEntityString" AS o0 CROSS JOIN "OperatorEntityString" AS o1 CROSS JOIN "OperatorEntityString" AS o2 CROSS JOIN "OperatorEntityInt" AS o3 -WHERE ((((o."Value" = 'A') AND o."Value" IS NOT NULL) AND ((o0."Value" = 'A') AND o0."Value" IS NOT NULL)) OR (((o1."Value" = 'B') AND o1."Value" IS NOT NULL) AND ((o2."Value" = 'B') AND o2."Value" IS NOT NULL))) AND (o3."Value" = 2) +WHERE ((o."Value" = 'A' AND o."Value" IS NOT NULL AND o0."Value" = 'A' AND o0."Value" IS NOT NULL) OR (o1."Value" = 'B' AND o1."Value" IS NOT NULL AND o2."Value" = 'B' AND o2."Value" IS NOT NULL)) AND o3."Value" = 2 ORDER BY o."Id" NULLS FIRST, o0."Id" NULLS FIRST, o1."Id" NULLS FIRST, o2."Id" NULLS FIRST, o3."Id" NULLS FIRST """); } - [ConditionalFact(Skip = "#2217")] public override async Task Projection_with_not_and_negation_on_integer() { await base.Projection_with_not_and_negation_on_integer(); AssertSql( """ -SELECT ~(-(-([o1].[Value] + [o].[Value] + CAST(2 AS bigint)))) % (-([o0].[Value] + [o0].[Value]) - [o].[Value]) -FROM [OperatorEntityLong] AS [o] -CROSS JOIN [OperatorEntityLong] AS [o0] -CROSS JOIN [OperatorEntityLong] AS [o1] -ORDER BY [o].[Id], [o0].[Id], [o1].[Id] +SELECT (~(-(-(o1."Value" + o."Value" + 2)))) % (-(o0."Value" + o0."Value") - o."Value") +FROM "OperatorEntityLong" AS o +CROSS JOIN "OperatorEntityLong" AS o0 +CROSS JOIN "OperatorEntityLong" AS o1 +ORDER BY o."Id" NULLS FIRST, o0."Id" NULLS FIRST, o1."Id" NULLS FIRST """); } @@ -121,103 +120,6 @@ SELECT o."Id" """); } -// [ConditionalTheory] -// [MemberData(nameof(IsAsyncData))] -// public virtual async Task Where_AtTimeZone_datetimeoffset_constant(bool async) -// { -// var contextFactory = await InitializeAsync(seed: Seed); -// using var context = contextFactory.CreateContext(); -// -// var expected = (from e in ExpectedData.OperatorEntitiesDateTimeOffset -// where e.Value.UtcDateTime == new DateTimeOffset(2000, 1, 1, 18, 0, 0, TimeSpan.Zero) -// select e.Id).ToList(); -// -// var actual = (from e in context.Set() -// where EF.Functions.AtTimeZone(e.Value, "UTC") == new DateTimeOffset(2000, 1, 1, 18, 0, 0, TimeSpan.Zero) -// select e.Id).ToList(); -// -// Assert.Equal(expected.Count, actual.Count); -// for (var i = 0; i < expected.Count; i++) -// { -// Assert.Equal(expected[i], actual[i]); -// } -// -// AssertSql( -// """ -// SELECT [o].[Id] -// FROM [OperatorEntityDateTimeOffset] AS [o] -// WHERE ([o].[Value] AT TIME ZONE 'UTC') = '2000-01-01T18:00:00.0000000+00:00' -// """); -// } -// -// [ConditionalTheory] -// [MemberData(nameof(IsAsyncData))] -// public virtual async Task Where_AtTimeZone_datetimeoffset_parameter(bool async) -// { -// var contextFactory = await InitializeAsync(seed: Seed); -// using var context = contextFactory.CreateContext(); -// -// var dateTime = new DateTimeOffset(2000, 1, 1, 18, 0, 0, TimeSpan.Zero); -// var timeZone = "UTC"; -// -// var expected = (from e in ExpectedData.OperatorEntitiesDateTimeOffset -// where e.Value.UtcDateTime == dateTime -// select e.Id).ToList(); -// -// var actual = (from e in context.Set() -// where EF.Functions.AtTimeZone(e.Value, timeZone) == dateTime -// select e.Id).ToList(); -// -// Assert.Equal(expected.Count, actual.Count); -// for (var i = 0; i < expected.Count; i++) -// { -// Assert.Equal(expected[i], actual[i]); -// } -// -// AssertSql( -// """ -// @__timeZone_1='UTC' (Size = 8000) (DbType = AnsiString) -// @__dateTime_2='2000-01-01T18:00:00.0000000+00:00' -// -// SELECT [o].[Id] -// FROM [OperatorEntityDateTimeOffset] AS [o] -// WHERE ([o].[Value] AT TIME ZONE @__timeZone_1) = @__dateTime_2 -// """); -// } -// -// [ConditionalTheory] -// [MemberData(nameof(IsAsyncData))] -// public virtual async Task Where_AtTimeZone_datetimeoffset_column(bool async) -// { -// var contextFactory = await InitializeAsync(seed: Seed); -// using var context = contextFactory.CreateContext(); -// -// var expected = (from e1 in ExpectedData.OperatorEntitiesDateTimeOffset -// from e2 in ExpectedData.OperatorEntitiesDateTimeOffset -// where e1.Value == e2.Value.UtcDateTime -// select new { Id1 = e1.Id, Id2 = e2.Id }).ToList(); -// -// var actual = (from e1 in context.Set() -// from e2 in context.Set() -// where EF.Functions.AtTimeZone(e1.Value, "UTC") == e2.Value -// select new { Id1 = e1.Id, Id2 = e2.Id }).ToList(); -// -// Assert.Equal(expected.Count, actual.Count); -// for (var i = 0; i < expected.Count; i++) -// { -// Assert.Equal(expected[i].Id1, actual[i].Id1); -// Assert.Equal(expected[i].Id2, actual[i].Id2); -// } -// -// AssertSql( -// """ -// SELECT [o].[Id] AS [Id1], [o0].[Id] AS [Id2] -// FROM [OperatorEntityDateTimeOffset] AS [o] -// CROSS JOIN [OperatorEntityDateTimeOffset] AS [o0] -// WHERE ([o].[Value] AT TIME ZONE 'UTC') = [o0].[Value] -// """); - // } - protected override void Seed(OperatorsContext ctx) { ctx.Set().AddRange(ExpectedData.OperatorEntitiesString); diff --git a/test/EFCore.PG.FunctionalTests/Query/TPCGearsOfWarQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/TPCGearsOfWarQueryNpgsqlTest.cs index ed2277930..3448662ee 100644 --- a/test/EFCore.PG.FunctionalTests/Query/TPCGearsOfWarQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/TPCGearsOfWarQueryNpgsqlTest.cs @@ -49,7 +49,7 @@ await AssertQuery( SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE ((@__start_0 <= date_trunc('day', m."Timeline" AT TIME ZONE 'UTC')::timestamptz) AND (m."Timeline" < @__end_1)) AND m."Timeline" = ANY (@__dates_2) +WHERE @__start_0 <= date_trunc('day', m."Timeline" AT TIME ZONE 'UTC')::timestamptz AND m."Timeline" < @__end_1 AND m."Timeline" = ANY (@__dates_2) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/TPTGearsOfWarQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/TPTGearsOfWarQueryNpgsqlTest.cs index 55fb84d20..e4ac3f0e2 100644 --- a/test/EFCore.PG.FunctionalTests/Query/TPTGearsOfWarQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/TPTGearsOfWarQueryNpgsqlTest.cs @@ -53,7 +53,7 @@ await AssertQuery( SELECT m."Id", m."CodeName", m."Date", m."Duration", m."Rating", m."Time", m."Timeline" FROM "Missions" AS m -WHERE ((@__start_0 <= date_trunc('day', m."Timeline" AT TIME ZONE 'UTC')::timestamptz) AND (m."Timeline" < @__end_1)) AND m."Timeline" = ANY (@__dates_2) +WHERE @__start_0 <= date_trunc('day', m."Timeline" AT TIME ZONE 'UTC')::timestamptz AND m."Timeline" < @__end_1 AND m."Timeline" = ANY (@__dates_2) """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs index 49ab1ab78..741a53013 100644 --- a/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/TimestampQueryTest.cs @@ -409,7 +409,7 @@ await AssertQuery( """ SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" FROM "Entities" AS e -WHERE (e."TimestampDateTimeOffset" AT TIME ZONE 'UTC') = TIMESTAMP '1998-04-12 13:26:38' +WHERE e."TimestampDateTimeOffset" AT TIME ZONE 'UTC' = TIMESTAMP '1998-04-12 13:26:38' """); } @@ -572,7 +572,7 @@ await AssertQuery( """ SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" FROM "Entities" AS e -WHERE (e."TimestampDateTime" AT TIME ZONE 'UTC') = TIMESTAMPTZ '1998-04-12 15:26:38Z' +WHERE e."TimestampDateTime" AT TIME ZONE 'UTC' = TIMESTAMPTZ '1998-04-12 15:26:38Z' """); } @@ -589,7 +589,7 @@ await AssertQuery( """ SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" FROM "Entities" AS e -WHERE (e."TimestamptzDateTime" AT TIME ZONE 'UTC') = TIMESTAMP '1998-04-12 13:26:38' +WHERE e."TimestamptzDateTime" AT TIME ZONE 'UTC' = TIMESTAMP '1998-04-12 13:26:38' """); } @@ -606,7 +606,7 @@ await AssertQuery( """ SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" FROM "Entities" AS e -WHERE (e."TimestamptzDateTime" AT TIME ZONE 'UTC') = TIMESTAMP '1998-04-12 13:26:38' +WHERE e."TimestamptzDateTime" AT TIME ZONE 'UTC' = TIMESTAMP '1998-04-12 13:26:38' """); } @@ -642,7 +642,7 @@ await AssertQuery( """ SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" FROM "Entities" AS e -WHERE (e."TimestamptzDateTime" AT TIME ZONE 'Europe/Berlin') = TIMESTAMP '1998-04-12 15:26:38' +WHERE e."TimestamptzDateTime" AT TIME ZONE 'Europe/Berlin' = TIMESTAMP '1998-04-12 15:26:38' """); } @@ -744,7 +744,7 @@ await AssertQuery( """ SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" FROM "Entities" AS e -WHERE (CAST(e."TimestamptzDateTime" AT TIME ZONE 'UTC' AS date) + TIME '15:26:38') = TIMESTAMP '1998-04-12 15:26:38' +WHERE CAST(e."TimestamptzDateTime" AT TIME ZONE 'UTC' AS date) + TIME '15:26:38' = TIMESTAMP '1998-04-12 15:26:38' """); } diff --git a/test/EFCore.PG.FunctionalTests/Query/TrigramsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/TrigramsQueryNpgsqlTest.cs index d34234a9b..6158e0d91 100644 --- a/test/EFCore.PG.FunctionalTests/Query/TrigramsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/TrigramsQueryNpgsqlTest.cs @@ -194,7 +194,7 @@ public void Operator_precedence() """ SELECT t."Id", t."Text" FROM "TrigramsTestEntities" AS t -WHERE ((COALESCE(t."Text", '') || ' ') || COALESCE(t."Text", '')) % 'query' +WHERE (COALESCE(t."Text", '') || ' ' || COALESCE(t."Text", '')) % 'query' """); } diff --git a/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs b/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs index 8fc8fb783..4d56af53d 100644 --- a/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs +++ b/test/EFCore.PG.NodaTime.FunctionalTests/NodaTimeQueryNpgsqlTest.cs @@ -45,7 +45,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (n."LocalDate" + INTERVAL 'P1M') > n."LocalDate" +WHERE n."LocalDate" + INTERVAL 'P1M' > n."LocalDate" """); } @@ -62,7 +62,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE ((n."Instant" + INTERVAL '1 00:00:00') - n."Instant") = INTERVAL '1 00:00:00' +WHERE (n."Instant" + INTERVAL '1 00:00:00') - n."Instant" = INTERVAL '1 00:00:00' """); } @@ -79,7 +79,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE ((n."LocalDateTime" + INTERVAL 'P1D') - n."LocalDateTime") = INTERVAL 'P1D' +WHERE (n."LocalDateTime" + INTERVAL 'P1D') - n."LocalDateTime" = INTERVAL 'P1D' """); } @@ -96,7 +96,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE ((n."ZonedDateTime" + INTERVAL '1 00:00:00') - n."ZonedDateTime") = INTERVAL '1 00:00:00' +WHERE (n."ZonedDateTime" + INTERVAL '1 00:00:00') - n."ZonedDateTime" = INTERVAL '1 00:00:00' """); } @@ -167,7 +167,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE ((n."LocalTime" + INTERVAL 'PT1H') - n."LocalTime") = INTERVAL 'PT1H' +WHERE (n."LocalTime" + INTERVAL 'PT1H') - n."LocalTime" = INTERVAL 'PT1H' """); } @@ -348,7 +348,7 @@ await AssertQuery( SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (n."LocalDateTime" AT TIME ZONE 'Europe/Berlin') = @__ToInstant_0 +WHERE n."LocalDateTime" AT TIME ZONE 'Europe/Berlin' = @__ToInstant_0 """); } @@ -369,7 +369,7 @@ await AssertQuery( SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (n."LocalDateTime" AT TIME ZONE n."TimeZoneId") = @__ToInstant_0 +WHERE n."LocalDateTime" AT TIME ZONE n."TimeZoneId" = @__ToInstant_0 """); } @@ -939,7 +939,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (date_part('epoch', n."Duration") / 86400.0) > 27.0 +WHERE date_part('epoch', n."Duration") / 86400.0 > 27.0 """); } @@ -956,7 +956,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (date_part('epoch', n."Duration") / 3600.0) < 700.0 +WHERE date_part('epoch', n."Duration") / 3600.0 < 700.0 """); } @@ -973,7 +973,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (date_part('epoch', n."Duration") / 60.0) < 40000.0 +WHERE date_part('epoch', n."Duration") / 60.0 < 40000.0 """); } @@ -1007,7 +1007,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (date_part('epoch', n."Duration") / 0.001) = 2365448020.0 +WHERE date_part('epoch', n."Duration") / 0.001 = 2365448020.0 """); } @@ -1206,7 +1206,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (upper(n."Interval") - lower(n."Interval")) = INTERVAL '5 00:00:00' +WHERE upper(n."Interval") - lower(n."Interval") = INTERVAL '5 00:00:00' """); } @@ -1310,7 +1310,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (upper(n."DateInterval") - lower(n."DateInterval")) = 5 +WHERE upper(n."DateInterval") - lower(n."DateInterval") = 5 """); } @@ -1344,7 +1344,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (upper(n."DateInterval") - INTERVAL 'P1D') = DATE '2018-04-24' +WHERE upper(n."DateInterval") - INTERVAL 'P1D' = DATE '2018-04-24' """); } @@ -1552,7 +1552,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (n."Instant" AT TIME ZONE 'Europe/Berlin') = TIMESTAMP '2018-04-20T12:31:33.666' +WHERE n."Instant" AT TIME ZONE 'Europe/Berlin' = TIMESTAMP '2018-04-20T12:31:33.666' """); } @@ -1810,7 +1810,7 @@ await AssertQuery( """ SELECT n."Id", n."DateInterval", n."Duration", n."Instant", n."InstantRange", n."Interval", n."LocalDate", n."LocalDate2", n."LocalDateRange", n."LocalDateTime", n."LocalTime", n."Long", n."OffsetTime", n."Period", n."TimeZoneId", n."ZonedDateTime" FROM "NodaTimeTypes" AS n -WHERE (n."Instant" AT TIME ZONE 'UTC') = TIMESTAMP '2018-04-20T10:31:33.666' +WHERE n."Instant" AT TIME ZONE 'UTC' = TIMESTAMP '2018-04-20T10:31:33.666' """); }