From cccfab3bc42c1e270624b3f9a7639d9d956e882e Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Wed, 30 Oct 2019 22:58:02 +0100 Subject: [PATCH] Depend on 3.1.0-preview2.19525.5 * Remove unneeded RemoveConvert in JSON POCO translator as it has been obsoleted upstream. It wasn't actually necessary anyway. * Target .NET Standard 2.0 * Various test fixes for 3.1 * Correct all test issues flagged by xunit analyzer Closes #1081 --- .github/workflows/build.yml | 2 +- Directory.Build.props | 3 +- Directory.Build.targets | 16 +-- NuGet.Config | 14 +++ global.json | 2 +- .../Internal/IdentitySequenceOptionsData.cs | 2 +- .../Internal/NpgsqlJsonPocoTranslator.cs | 4 +- .../Internal/JsonTraversalExpression.cs | 2 +- test/Directory.Build.props | 4 +- .../BuiltInDataTypesNpgsqlTest.cs | 6 +- .../CommandInterceptionNpgsqlTest.cs | 21 ++-- .../CustomConvertersNpgsqlTest.cs | 13 +- .../LazyLoadProxySqlNpgsqlTest.cs | 5 +- .../Query/ArrayQueryTest.cs | 12 +- .../ComplexNavigationsQueryNpgsqlTest.cs | 18 ++- .../ComplexNavigationsWeakQueryNpgsqlTest.cs | 10 ++ .../Query/EnumQueryTest.cs | 10 +- .../Query/FunkyDataQueryNpgsqlTest.cs | 21 ++-- .../Query/GearsOfWarQueryNpgsqlTest.cs | 18 ++- .../Query/GroupByQueryNpgsqlTest.cs | 33 +++++- .../Query/JsonDomQueryTest.cs | 10 +- .../Query/JsonPocoQueryTest.cs | 6 +- .../Query/JsonStringQueryTest.cs | 4 +- .../Query/NetworkQueryNpgsqlTest.cs | 24 ++-- .../Query/NorthwindQueryNpgsqlFixture.cs | 9 ++ .../Query/QueryNoClientEvalNpgsqlTest.cs | 7 ++ .../Query/RangeQueryNpgsqlTest.cs | 8 +- .../Query/SimpleQueryNpgsqlTest.Functions.cs | 43 ++++--- .../SimpleQueryNpgsqlTest.ResultOperators.cs | 8 ++ .../Query/SimpleQueryNpgsqlTest.Select.cs | 10 ++ .../Query/SimpleQueryNpgsqlTest.Where.cs | 15 ++- .../Query/SimpleQueryNpgsqlTest.cs | 112 +++++++++++------- .../Query/SpatialQueryNpgsqlGeographyTest.cs | 6 +- .../Query/SpatialQueryNpgsqlGeometryTest.cs | 6 +- .../Query/UdfDbFunctionNpgsqlTests.cs | 24 ++-- .../NpgsqlDatabaseModelFactoryTest.cs | 6 +- .../Storage/NpgsqlTypeMappingSourceTest.cs | 1 - 37 files changed, 354 insertions(+), 161 deletions(-) create mode 100644 NuGet.Config create mode 100644 test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.ResultOperators.cs create mode 100644 test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Select.cs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fbcbe1f326..f6973e5a0e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,7 +65,7 @@ jobs: - name: Setup .NET Core SDK uses: actions/setup-dotnet@v1.0.2 # Issues with DOTNET_ROOT with: - dotnet-version: '3.0.100' + dotnet-version: '3.1.100-preview1-014459' - name: Test run: dotnet test --configuration Debug diff --git a/Directory.Build.props b/Directory.Build.props index 629e75de11..3095b895a3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -8,7 +8,7 @@ git git://github.com/npgsql/efcore.pg - netstandard2.1 + netstandard2.0 PostgreSQL https://github.com/npgsql/efcore.pg @@ -24,6 +24,7 @@ 8.0 true NU5105 + true diff --git a/Directory.Build.targets b/Directory.Build.targets index 0bcfcad58b..954a68fda0 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,14 +1,14 @@  - - - - - + + + + + - - - + + + diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000000..8892c65a43 --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/global.json b/global.json index 79422f0cc1..3d6091091f 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.0.100" + "version": "3.1.100-preview1-014459" } } diff --git a/src/EFCore.PG/Metadata/Internal/IdentitySequenceOptionsData.cs b/src/EFCore.PG/Metadata/Internal/IdentitySequenceOptionsData.cs index 35aeb2ca35..c92018752e 100644 --- a/src/EFCore.PG/Metadata/Internal/IdentitySequenceOptionsData.cs +++ b/src/EFCore.PG/Metadata/Internal/IdentitySequenceOptionsData.cs @@ -79,7 +79,7 @@ static string ExtractValue(string value, ref int position) end = value.IndexOf('\'', end + 2); } - var extracted = value[position..end].Replace("''", "'"); + var extracted = value.Substring(position, end - position).Replace("''", "'"); position = end + 1; return extracted.Length == 0 ? null : extracted; diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlJsonPocoTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlJsonPocoTranslator.cs index 561a99730c..a28c88558e 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlJsonPocoTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlJsonPocoTranslator.cs @@ -47,7 +47,7 @@ public SqlExpression TranslateMemberAccess(SqlExpression instance, SqlExpression returnType); } - if (instance.RemoveConvert() is JsonTraversalExpression prevPathTraversal) + if (instance is JsonTraversalExpression prevPathTraversal) { return ConvertFromText( prevPathTraversal.Append(_sqlExpressionFactory.ApplyDefaultTypeMapping(member)), @@ -67,7 +67,7 @@ public SqlExpression TranslateArrayLength(SqlExpression expression) new[] { expression }, typeof(int)); } - if (expression.RemoveConvert() is JsonTraversalExpression traversal) + if (expression is JsonTraversalExpression traversal) { // The traversal expression has ReturnsText=true (e.g. ->> not ->), so we recreate it to return // the JSON object instead. diff --git a/src/EFCore.PG/Query/Expressions/Internal/JsonTraversalExpression.cs b/src/EFCore.PG/Query/Expressions/Internal/JsonTraversalExpression.cs index 1d7596e75b..f083671ba9 100644 --- a/src/EFCore.PG/Query/Expressions/Internal/JsonTraversalExpression.cs +++ b/src/EFCore.PG/Query/Expressions/Internal/JsonTraversalExpression.cs @@ -74,7 +74,7 @@ public JsonTraversalExpression Append(SqlExpression pathComponent) var oldPath = Path; var newPath = new SqlExpression[oldPath.Length + 1]; Array.Copy(oldPath, newPath, oldPath.Length); - newPath[^1] = pathComponent; + newPath[newPath.Length-1] = pathComponent; return new JsonTraversalExpression(Expression, newPath, ReturnsText, Type, TypeMapping); } diff --git a/test/Directory.Build.props b/test/Directory.Build.props index d637723937..a9b9be3f5b 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -3,12 +3,12 @@ - netcoreapp3.0 + netcoreapp3.1 - $(NoWarn);xUnit1004;EF1001 + $(NoWarn);xUnit1003;xUnit1004;xUnit1013;EF1001 diff --git a/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs index d79a0e412a..cd57fd5d35 100644 --- a/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs @@ -38,7 +38,7 @@ var results .Select(e => e.Int) .ToList(); - Assert.Equal(0, results.Count); + Assert.Empty(results); AssertSql( @"SELECT m.""Int"" @@ -60,14 +60,14 @@ var results .Select(e => e.Int) .ToList(); - Assert.Equal(0, results.Count); + Assert.Empty(results); AssertSql( @"@__timeSpan_0='02:01:00' (Nullable = true) (DbType = Object) SELECT m.""Int"" FROM ""MappedNullableDataTypes"" AS m -WHERE ((m.""TimeSpanAsTime"" = @__timeSpan_0) AND ((m.""TimeSpanAsTime"" IS NOT NULL) AND (@__timeSpan_0 IS NOT NULL))) OR ((m.""TimeSpanAsTime"" IS NULL) AND (@__timeSpan_0 IS NULL))"); +WHERE (m.""TimeSpanAsTime"" = @__timeSpan_0) AND (m.""TimeSpanAsTime"" IS NOT NULL)"); } } diff --git a/test/EFCore.PG.FunctionalTests/CommandInterceptionNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/CommandInterceptionNpgsqlTest.cs index 2aee53af43..148ecb3c4a 100644 --- a/test/EFCore.PG.FunctionalTests/CommandInterceptionNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/CommandInterceptionNpgsqlTest.cs @@ -17,25 +17,32 @@ public CommandInterceptionNpgsqlTestBase(InterceptionNpgsqlFixtureBase fixture) } [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/16701")] - public override Task Intercept_non_query_one_app_and_one_injected_interceptor(bool async) => null; + public override Task Intercept_non_query_one_app_and_one_injected_interceptor(bool async) + => base.Intercept_non_query_one_app_and_one_injected_interceptor(async); [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/16701")] - public override Task Intercept_non_query_passively(bool async, bool inject) => null; + public override Task Intercept_non_query_passively(bool async, bool inject) + => base.Intercept_non_query_passively(async, inject); [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/16701")] - public override Task Intercept_non_query_to_mutate_command(bool async, bool inject) => null; + public override Task Intercept_non_query_to_mutate_command(bool async, bool inject) + => base.Intercept_non_query_to_mutate_command(async, inject); [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/16701")] - public override Task Intercept_non_query_to_replace_execution(bool async, bool inject) => null; + public override Task Intercept_non_query_to_replace_execution(bool async, bool inject) + => base.Intercept_non_query_to_replace_execution(async, inject); [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/16701")] - public override Task Intercept_non_query_with_explicitly_composed_app_interceptor(bool async) => null; + public override Task Intercept_non_query_with_explicitly_composed_app_interceptor(bool async) + => base.Intercept_non_query_with_explicitly_composed_app_interceptor(async); [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/16701")] - public override Task Intercept_non_query_with_two_injected_interceptors(bool async) => null; + public override Task Intercept_non_query_with_two_injected_interceptors(bool async) + => base.Intercept_non_query_with_two_injected_interceptors(async); [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/16701")] - public override Task Intercept_non_query_to_replace_result(bool async, bool inject) => null; + public override Task Intercept_non_query_to_replace_result(bool async, bool inject) + => base.Intercept_non_query_to_replace_result(async, inject); public abstract class InterceptionNpgsqlFixtureBase : InterceptionFixtureBase { diff --git a/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs index c8faeef5b8..ece563fa9f 100644 --- a/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs @@ -1,6 +1,5 @@ using System; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; using Xunit; @@ -14,6 +13,18 @@ public CustomConvertersNpgsqlTest(CustomConvertersNpgsqlFixture fixture) { } + [ConditionalFact(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/18147")] + public override void Value_conversion_is_appropriately_used_for_join_condition() + => base.Value_conversion_is_appropriately_used_for_join_condition(); + + [ConditionalFact(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/18147")] + public override void Value_conversion_is_appropriately_used_for_left_join_condition() + => base.Value_conversion_is_appropriately_used_for_left_join_condition(); + + [ConditionalFact(Skip = "https://github.com/aspnet/EntityFrameworkCore/issues/18147")] + public override void Where_bool_gets_converted_to_equality_when_value_conversion_is_used() + => base.Where_bool_gets_converted_to_equality_when_value_conversion_is_used(); + // Disabled: PostgreSQL is case-sensitive public override void Can_insert_and_read_back_with_case_insensitive_string_key() {} diff --git a/test/EFCore.PG.FunctionalTests/LazyLoadProxySqlNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/LazyLoadProxySqlNpgsqlTest.cs index d7e7d77b34..6807ccc1b0 100644 --- a/test/EFCore.PG.FunctionalTests/LazyLoadProxySqlNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/LazyLoadProxySqlNpgsqlTest.cs @@ -1,9 +1,9 @@ using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; +using Xunit; namespace Npgsql.EntityFrameworkCore.PostgreSQL { @@ -14,6 +14,9 @@ public LazyLoadProxyNpgsqlTest(LoadNpgsqlFixture fixture) : base(fixture) => Fixture.TestSqlLoggerFactory.Clear(); + [ConditionalFact] // Requires MARS + public override void Top_level_projection_track_entities_before_passing_to_client_method() {} + protected override void ClearLog() => Fixture.TestSqlLoggerFactory.Clear(); protected override void RecordLog() => Sql = Fixture.TestSqlLoggerFactory.Sql; diff --git a/test/EFCore.PG.FunctionalTests/Query/ArrayQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/ArrayQueryTest.cs index 9226f1208b..027f2fe73e 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ArrayQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ArrayQueryTest.cs @@ -42,7 +42,7 @@ public void Index_with_constant() using (var ctx = Fixture.CreateContext()) { var actual = ctx.SomeEntities.Where(e => e.SomeArray[0] == 3).ToList(); - Assert.Equal(1, actual.Count); + Assert.Single(actual); AssertSql( @"SELECT s.""Id"", s.""SomeArray"", s.""SomeBytea"", s.""SomeList"", s.""SomeMatrix"", s.""SomeText"" @@ -59,7 +59,7 @@ public void Index_with_non_constant() // ReSharper disable once ConvertToConstant.Local var x = 0; var actual = ctx.SomeEntities.Where(e => e.SomeArray[x] == 3).ToList(); - Assert.Equal(1, actual.Count); + Assert.Single(actual); AssertSql( @"@__x_0='0' @@ -76,7 +76,7 @@ public void Index_bytea_with_constant() using (var ctx = Fixture.CreateContext()) { var actual = ctx.SomeEntities.Where(e => e.SomeBytea[0] == 3).ToList(); - Assert.Equal(1, actual.Count); + Assert.Single(actual); AssertSql( @"SELECT s.""Id"", s.""SomeArray"", s.""SomeBytea"", s.""SomeList"", s.""SomeMatrix"", s.""SomeText"" @@ -91,7 +91,7 @@ public void Index_text_with_constant() using (var ctx = Fixture.CreateContext()) { var actual = ctx.SomeEntities.Where(e => e.SomeText[0] == 'f').ToList(); - Assert.Equal(1, actual.Count); + Assert.Single(actual); AssertSql( @"SELECT s.""Id"", s.""SomeArray"", s.""SomeBytea"", s.""SomeList"", s.""SomeMatrix"", s.""SomeText"" @@ -118,7 +118,7 @@ public void SequenceEqual_with_parameter() SELECT s.""Id"", s.""SomeArray"", s.""SomeBytea"", s.""SomeList"", s.""SomeMatrix"", s.""SomeText"" FROM ""SomeEntities"" AS s -WHERE ((s.""SomeArray"" = @__arr_0) AND ((s.""SomeArray"" IS NOT NULL) AND (@__arr_0 IS NOT NULL))) OR ((s.""SomeArray"" IS NULL) AND (@__arr_0 IS NULL)) +WHERE (s.""SomeArray"" = @__arr_0) AND (s.""SomeArray"" IS NOT NULL) LIMIT 2"); } } @@ -248,7 +248,7 @@ public void Any_no_predicate() using (var ctx = Fixture.CreateContext()) { var count = ctx.SomeEntities.Count(e => e.SomeArray.Any()); - Assert.Equal(count, 2); + Assert.Equal(2, count); AssertSql( @"SELECT COUNT(*)::INT diff --git a/test/EFCore.PG.FunctionalTests/Query/ComplexNavigationsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/ComplexNavigationsQueryNpgsqlTest.cs index eadbfa0a34..b78c2cf611 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ComplexNavigationsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ComplexNavigationsQueryNpgsqlTest.cs @@ -1,4 +1,12 @@ -using Microsoft.EntityFrameworkCore.Query; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestModels.ComplexNavigationsModel; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit; namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query { @@ -11,6 +19,14 @@ public ComplexNavigationsQueryNpgsqlTest(ComplexNavigationsQueryNpgsqlFixture fi Fixture.TestSqlLoggerFactory.Clear(); } + [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/18679")] + [MemberData(nameof(IsAsyncData))] + public override Task Include13(bool isAsync) => base.Include13(isAsync); + + [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/18679")] + [MemberData(nameof(IsAsyncData))] + public override Task Include14(bool isAsync) => base.Include13(isAsync); + // Should be fixed but could not verify as temporarily disabled upstream // [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/12970")] // [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.PG.FunctionalTests/Query/ComplexNavigationsWeakQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/ComplexNavigationsWeakQueryNpgsqlTest.cs index debc4370f0..32eeb6b8d7 100644 --- a/test/EFCore.PG.FunctionalTests/Query/ComplexNavigationsWeakQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/ComplexNavigationsWeakQueryNpgsqlTest.cs @@ -1,4 +1,6 @@ +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Query; +using Xunit; using Xunit.Abstractions; namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query @@ -12,5 +14,13 @@ public ComplexNavigationsWeakQueryNpgsqlTest(ComplexNavigationsWeakQueryNpgsqlFi Fixture.TestSqlLoggerFactory.Clear(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + + [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/18679")] + [MemberData(nameof(IsAsyncData))] + public override Task Include13(bool isAsync) => base.Include13(isAsync); + + [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/18679")] + [MemberData(nameof(IsAsyncData))] + public override Task Include14(bool isAsync) => base.Include13(isAsync); } } diff --git a/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs index d9032bc63a..747d99eeca 100644 --- a/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs @@ -16,7 +16,7 @@ public EnumQueryTest(EnumFixture fixture, ITestOutputHelper testOutputHelper) { Fixture = fixture; Fixture.TestSqlLoggerFactory.Clear(); - //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } #region Roundtrip @@ -74,7 +74,7 @@ public void Where_with_parameter() SELECT s.""Id"", s.""EnumValue"", s.""InferredEnum"", s.""MappedEnum"", s.""SchemaQualifiedEnum"", s.""UnmappedEnum"" FROM test.""SomeEntities"" AS s -WHERE (s.""MappedEnum"" = @__sad_0) AND (@__sad_0 IS NOT NULL) +WHERE s.""MappedEnum"" = @__sad_0 LIMIT 2"); } } @@ -93,7 +93,7 @@ public void Where_with_unmapped_enum_parameter_downcasts_are_implicit() SELECT s.""Id"", s.""EnumValue"", s.""InferredEnum"", s.""MappedEnum"", s.""SchemaQualifiedEnum"", s.""UnmappedEnum"" FROM test.""SomeEntities"" AS s -WHERE (s.""UnmappedEnum"" = @__sad_0) AND (@__sad_0 IS NOT NULL) +WHERE s.""UnmappedEnum"" = @__sad_0 LIMIT 2"); } } @@ -112,7 +112,7 @@ public void Where_with_unmapped_enum_parameter_downcasts_do_not_matter() SELECT s.""Id"", s.""EnumValue"", s.""InferredEnum"", s.""MappedEnum"", s.""SchemaQualifiedEnum"", s.""UnmappedEnum"" FROM test.""SomeEntities"" AS s -WHERE (s.""UnmappedEnum"" = @__sad_0) AND (@__sad_0 IS NOT NULL) +WHERE s.""UnmappedEnum"" = @__sad_0 LIMIT 2"); } } @@ -131,7 +131,7 @@ public void Where_with_mapped_enum_parameter_downcasts_do_not_matter() SELECT s.""Id"", s.""EnumValue"", s.""InferredEnum"", s.""MappedEnum"", s.""SchemaQualifiedEnum"", s.""UnmappedEnum"" FROM test.""SomeEntities"" AS s -WHERE (s.""MappedEnum"" = @__sad_0) AND (@__sad_0 IS NOT NULL) +WHERE s.""MappedEnum"" = @__sad_0 LIMIT 2"); } } diff --git a/test/EFCore.PG.FunctionalTests/Query/FunkyDataQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/FunkyDataQueryNpgsqlTest.cs index 043a09665a..c3d0f3df48 100644 --- a/test/EFCore.PG.FunctionalTests/Query/FunkyDataQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/FunkyDataQueryNpgsqlTest.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestModels.FunkyDataModel; @@ -17,17 +18,21 @@ public FunkyDataQueryNpgsqlTest(FunkyDataQueryNpgsqlFixture fixture, ITestOutput //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - [ConditionalFact(Skip = "https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/996")] - public override void String_contains_on_argument_with_wildcard_column() {} + [ConditionalTheory(Skip = "https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/996")] + public override Task String_contains_on_argument_with_wildcard_column(bool isAsync) + => base.String_contains_on_argument_with_wildcard_column(isAsync); - [ConditionalFact(Skip = "https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/996")] - public override void String_contains_on_argument_with_wildcard_column_negated() {} + [ConditionalTheory(Skip = "https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/996")] + public override Task String_contains_on_argument_with_wildcard_column_negated(bool isAsync) + => base.String_contains_on_argument_with_wildcard_column_negated(isAsync); - [ConditionalFact(Skip = "https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/996")] - public override void String_contains_on_argument_with_wildcard_constant() {} + [ConditionalTheory(Skip = "https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/996")] + public override Task String_contains_on_argument_with_wildcard_constant(bool isAsync) + => base.String_contains_on_argument_with_wildcard_constant(isAsync); - [ConditionalFact(Skip = "https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/996")] - public override void String_contains_on_argument_with_wildcard_parameter() {} + [ConditionalTheory(Skip = "https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/996")] + public override Task String_contains_on_argument_with_wildcard_parameter(bool isAsync) + => base.String_contains_on_argument_with_wildcard_parameter(isAsync); public class FunkyDataQueryNpgsqlFixture : FunkyDataQueryFixtureBase { diff --git a/test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs index 1c3639dcc4..78fbb1259f 100644 --- a/test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/GearsOfWarQueryNpgsqlTest.cs @@ -15,7 +15,19 @@ public GearsOfWarQueryNpgsqlTest(GearsOfWarQueryNpgsqlFixture fixture, ITestOutp => Fixture.TestSqlLoggerFactory.Clear(); [Theory(Skip = "https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/874")] - public override Task String_concat_with_null_conditional_argument2(bool isAsync) => Task.CompletedTask; + [MemberData(nameof(IsAsyncData))] + public override Task String_concat_with_null_conditional_argument2(bool isAsync) + => base.String_concat_with_null_conditional_argument2(isAsync); + + [Theory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/18674")] + [MemberData(nameof(IsAsyncData))] + public override Task Concat_with_collection_navigations(bool isAsync) + => base.Concat_with_collection_navigations(isAsync); + + [Theory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/18674")] + [MemberData(nameof(IsAsyncData))] + public override Task Select_navigation_with_concat_and_count(bool isAsync) + => base.Select_navigation_with_concat_and_count(isAsync); #region Ignore DateTimeOffset tests @@ -46,7 +58,9 @@ public GearsOfWarQueryNpgsqlTest(GearsOfWarQueryNpgsqlFixture fixture, ITestOutp public override Task Where_datetimeoffset_utcnow(bool isAsync) => Task.CompletedTask; [ConditionalTheory(Skip = "DateTimeOffset.Date isn't currently translated")] - public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool isAsync) => Task.CompletedTask; + [MemberData(nameof(IsAsyncData))] + public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool isAsync) + => base.DateTimeOffset_Contains_Less_than_Greater_than(isAsync); #endregion Ignore DateTimeOffset tests } diff --git a/test/EFCore.PG.FunctionalTests/Query/GroupByQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/GroupByQueryNpgsqlTest.cs index f6f865fd0e..d4afede31e 100644 --- a/test/EFCore.PG.FunctionalTests/Query/GroupByQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/GroupByQueryNpgsqlTest.cs @@ -1,5 +1,8 @@ -using System.Threading.Tasks; +using System; +using System.Linq; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; using Xunit.Abstractions; @@ -16,6 +19,34 @@ public GroupByQueryNpgsqlTest(NorthwindQueryNpgsqlFixture f //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + [ConditionalTheory] // https://github.com/aspnet/EntityFrameworkCore/pull/18675 + [MemberData(nameof(IsAsyncData))] + public override Task GroupBy_aggregate_projecting_conditional_expression(bool isAsync) + { + return AssertQuery( + isAsync, + ss => ss.Set().GroupBy(o => o.OrderDate).Select( + g => + new { g.Key, SomeValue = g.Count() == 0 ? 1 : g.Sum(o => o.OrderID % 2 == 0 ? 1 : 0) / g.Count() })); + } + + [ConditionalTheory] // https://github.com/aspnet/EntityFrameworkCore/pull/18675 + [MemberData(nameof(IsAsyncData))] + public override Task GroupBy_with_order_by_skip_and_another_order_by(bool isAsync) + { + return AssertQueryScalar( + isAsync, + ss => ss.Set() + .OrderBy(o => o.CustomerID) + .ThenBy(o => o.OrderID) + .Skip(80) + .OrderBy(o => o.CustomerID) + .ThenBy(o => o.OrderID) + .GroupBy(o => o.CustomerID) + .Select(g => g.Sum(o => o.OrderID)) + ); + } + protected override void ClearLog() => Fixture.TestSqlLoggerFactory.Clear(); } diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs index 6e3bc6e52c..d122b36011 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonDomQueryTest.cs @@ -19,7 +19,7 @@ public JsonDomQueryTest(JsonDomQueryFixture fixture, ITestOutputHelper testOutpu { Fixture = fixture; Fixture.TestSqlLoggerFactory.Clear(); - //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } [Fact] @@ -80,14 +80,14 @@ public void Parameter_document() SELECT j.""Id"", j.""CustomerDocument"", j.""CustomerElement"" FROM ""JsonbEntities"" AS j -WHERE (j.""Id"" = @__p_0) AND (@__p_0 IS NOT NULL) +WHERE j.""Id"" = @__p_0 LIMIT 1", // @"@__expected_0='System.Text.Json.JsonDocument' (DbType = Object) SELECT j.""Id"", j.""CustomerDocument"", j.""CustomerElement"" FROM ""JsonbEntities"" AS j -WHERE ((j.""CustomerDocument"" = @__expected_0) AND ((j.""CustomerDocument"" IS NOT NULL) AND (@__expected_0 IS NOT NULL))) OR ((j.""CustomerDocument"" IS NULL) AND (@__expected_0 IS NULL)) +WHERE (j.""CustomerDocument"" = @__expected_0) AND (j.""CustomerDocument"" IS NOT NULL) LIMIT 2"); } } @@ -106,7 +106,7 @@ public void Parameter_element() SELECT j.""Id"", j.""CustomerDocument"", j.""CustomerElement"" FROM ""JsonbEntities"" AS j -WHERE (j.""Id"" = @__p_0) AND (@__p_0 IS NOT NULL) +WHERE j.""Id"" = @__p_0 LIMIT 1", // @"@__expected_0='{""ID"": ""00000000-0000-0000-0000-000000000000"" @@ -127,7 +127,7 @@ public void Parameter_element() SELECT j.""Id"", j.""CustomerDocument"", j.""CustomerElement"" FROM ""JsonbEntities"" AS j -WHERE (j.""CustomerElement"" = @__expected_0) AND (@__expected_0 IS NOT NULL) +WHERE j.""CustomerElement"" = @__expected_0 LIMIT 2"); } } diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs index 6b6ff96f73..1999c020ab 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonPocoQueryTest.cs @@ -19,7 +19,7 @@ public JsonPocoQueryTest(JsonPocoQueryFixture fixture, ITestOutputHelper testOut { Fixture = fixture; Fixture.TestSqlLoggerFactory.Clear(); - //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } [Fact] @@ -88,14 +88,14 @@ public void Parameter() SELECT j.""Id"", j.""Customer"", j.""ToplevelArray"" FROM ""JsonbEntities"" AS j -WHERE (j.""Id"" = @__p_0) AND (@__p_0 IS NOT NULL) +WHERE j.""Id"" = @__p_0 LIMIT 1", // @"@__expected_0='Npgsql.EntityFrameworkCore.PostgreSQL.Query.JsonPocoQueryTest+Customer' (DbType = Object) SELECT j.""Id"", j.""Customer"", j.""ToplevelArray"" FROM ""JsonbEntities"" AS j -WHERE ((j.""Customer"" = @__expected_0) AND ((j.""Customer"" IS NOT NULL) AND (@__expected_0 IS NOT NULL))) OR ((j.""Customer"" IS NULL) AND (@__expected_0 IS NULL)) +WHERE (j.""Customer"" = @__expected_0) AND (j.""Customer"" IS NOT NULL) LIMIT 2"); } } diff --git a/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs b/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs index bfba979fb3..b4ca4cd57b 100644 --- a/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/JsonStringQueryTest.cs @@ -76,7 +76,7 @@ public void Parameter() SELECT j.""Id"", j.""CustomerJson"", j.""CustomerJsonb"" FROM ""JsonEntities"" AS j -WHERE (j.""Id"" = @__p_0) AND (@__p_0 IS NOT NULL) +WHERE j.""Id"" = @__p_0 LIMIT 1", // @"@__expected_0='{""Age"": 25 @@ -96,7 +96,7 @@ public void Parameter() SELECT j.""Id"", j.""CustomerJson"", j.""CustomerJsonb"" FROM ""JsonEntities"" AS j -WHERE ((j.""CustomerJsonb"" = @__expected_0) AND ((j.""CustomerJsonb"" IS NOT NULL) AND (@__expected_0 IS NOT NULL))) OR ((j.""CustomerJsonb"" IS NULL) AND (@__expected_0 IS NULL)) +WHERE (j.""CustomerJsonb"" = @__expected_0) AND (j.""CustomerJsonb"" IS NOT NULL) LIMIT 2"); } } diff --git a/test/EFCore.PG.FunctionalTests/Query/NetworkQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NetworkQueryNpgsqlTest.cs index 0fd7bac7d0..705b12e73f 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NetworkQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NetworkQueryNpgsqlTest.cs @@ -135,7 +135,7 @@ public void IPAddress_inet_LessThan_inet() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.LessThan(x.Inet, IPAddress.Parse("192.168.1.7"))); - Assert.Equal(count, 6); + Assert.Equal(6, count); AssertContainsSql(@"WHERE n.""Inet"" < INET '192.168.1.7'"); } } @@ -162,7 +162,7 @@ public void PhysicalAddress_macaddr_LessThan_macaddr() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.LessThan(x.Macaddr, PhysicalAddress.Parse("12-34-56-00-00-07"))); - Assert.Equal(count, 6); + Assert.Equal(6, count); AssertContainsSql(@"""Macaddr"" < MACADDR '123456000007'"); } } @@ -173,7 +173,7 @@ public void PhysicalAddress_macaddr8_LessThan_macaddr8() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.LessThan(x.Macaddr8, PhysicalAddress.Parse("08-00-2B-01-02-03-04-07"))); - Assert.Equal(count, 6); + Assert.Equal(6, count); AssertContainsSql(@"""Macaddr8"" < MACADDR8 '08002B0102030407'"); } } @@ -184,7 +184,7 @@ public void IPAddress_inet_LessThanOrEqual_inet() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.LessThanOrEqual(x.Inet, IPAddress.Parse("192.168.1.7"))); - Assert.Equal(count, 7); + Assert.Equal(7, count); AssertContainsSql(@"WHERE n.""Inet"" <= INET '192.168.1.7'"); } } @@ -211,7 +211,7 @@ public void PhysicalAddress_macaddr_LessThanOrEqual_macaddr() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.LessThanOrEqual(x.Macaddr, PhysicalAddress.Parse("12-34-56-00-00-07"))); - Assert.Equal(count, 7); + Assert.Equal(7, count); AssertContainsSql(@"""Macaddr"" <= MACADDR '123456000007'"); } } @@ -222,7 +222,7 @@ public void PhysicalAddress_macaddr8_LessThanOrEqual_macaddr8() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.LessThanOrEqual(x.Macaddr8, PhysicalAddress.Parse("08-00-2B-01-02-03-04-07"))); - Assert.Equal(count, 7); + Assert.Equal(7, count); AssertContainsSql(@"""Macaddr8"" <= MACADDR8 '08002B0102030407'"); } } @@ -232,7 +232,7 @@ public void IPAddress_inet_GreaterThanOrEqual_inet() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.GreaterThanOrEqual(x.Inet, IPAddress.Parse("192.168.1.7"))); - Assert.Equal(count, 3); + Assert.Equal(3, count); AssertContainsSql(@"WHERE n.""Inet"" >= INET '192.168.1.7'"); } } @@ -259,7 +259,7 @@ public void PhysicalAddress_macaddr_GreaterThanOrEqual_macaddr() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.GreaterThanOrEqual(x.Macaddr, PhysicalAddress.Parse("12-34-56-00-00-07"))); - Assert.Equal(count, 3); + Assert.Equal(3, count); AssertContainsSql(@"""Macaddr"" >= MACADDR '123456000007'"); } } @@ -270,7 +270,7 @@ public void PhysicalAddress_macaddr8_GreaterThanOrEqual_macaddr8() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.GreaterThanOrEqual(x.Macaddr8, PhysicalAddress.Parse("08-00-2B-01-02-03-04-07"))); - Assert.Equal(count, 3); + Assert.Equal(3, count); AssertContainsSql(@"""Macaddr8"" >= MACADDR8 '08002B0102030407'"); } } @@ -281,7 +281,7 @@ public void IPAddress_inet_GreaterThan_inet() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.GreaterThan(x.Inet, IPAddress.Parse("192.168.1.7"))); - Assert.Equal(count, 2); + Assert.Equal(2, count); AssertContainsSql(@"WHERE n.""Inet"" > INET '192.168.1.7'"); } } @@ -308,7 +308,7 @@ public void PhysicalAddress_macaddr_GreaterThan_macaddr() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.GreaterThan(x.Macaddr, PhysicalAddress.Parse("12-34-56-00-00-07"))); - Assert.Equal(count, 2); + Assert.Equal(2, count); AssertContainsSql(@"""Macaddr"" > MACADDR '123456000007'"); } } @@ -319,7 +319,7 @@ public void PhysicalAddress_macaddr8_GreaterThan_macaddr8() using (var context = Fixture.CreateContext()) { var count = context.NetTestEntities.Count(x => EF.Functions.GreaterThan(x.Macaddr8, PhysicalAddress.Parse("08-00-2B-01-02-03-04-07"))); - Assert.Equal(count, 2); + Assert.Equal(2, count); AssertContainsSql(@"""Macaddr8"" > MACADDR8 '08002B0102030407'"); } } diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindQueryNpgsqlFixture.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindQueryNpgsqlFixture.cs index 9de0c48e13..99ca816dc7 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindQueryNpgsqlFixture.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindQueryNpgsqlFixture.cs @@ -1,7 +1,9 @@ using System; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; +using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure; using Npgsql.EntityFrameworkCore.PostgreSQL.TestModels.Northwind; using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; @@ -12,5 +14,12 @@ public class NorthwindQueryNpgsqlFixture : NorthwindQueryRelat { protected override ITestStoreFactory TestStoreFactory => NpgsqlNorthwindTestStoreFactory.Instance; protected override Type ContextType => typeof(NorthwindNpgsqlContext); + + public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) + { + var optionsBuilder = base.AddOptions(builder); + new NpgsqlDbContextOptionsBuilder(optionsBuilder).ReverseNullOrdering(); + return optionsBuilder; + } } } diff --git a/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlTest.cs index 9ba38c660a..986c41391b 100644 --- a/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/QueryNoClientEvalNpgsqlTest.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore.Query; +using Xunit; namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query { @@ -8,5 +9,11 @@ public QueryNoClientEvalNpgsqlTest(QueryNoClientEvalNpgsqlFixture fixture) : base(fixture) { } + + [ConditionalFact(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/18674")] + public override void Throws_when_join() {} + + [ConditionalFact(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/18674")] + public override void Throws_when_group_join() {} } } diff --git a/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs index ba9a3fa8e9..2b6bca3414 100644 --- a/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/RangeQueryNpgsqlTest.cs @@ -415,8 +415,8 @@ public void UserDefined() using (var context = Fixture.CreateContext()) { var e = context.RangeTestEntities.Single(x => x.FloatRange.UpperBound > 5); - Assert.Equal(e.FloatRange.LowerBound, 0); - Assert.Equal(e.FloatRange.UpperBound, 10); + Assert.Equal(0, e.FloatRange.LowerBound); + Assert.Equal(10, e.FloatRange.UpperBound); } } @@ -427,8 +427,8 @@ public void UserDefinedSchemaQualified() { var e = context.RangeTestEntities.Single(x => x.SchemaRange == NpgsqlRange.Parse("(0,10)")); AssertContainsSql(@"WHERE r.""SchemaRange"" = '(0,10)'::test.""Schema_Range"""); - Assert.Equal(e.SchemaRange.LowerBound, 0); - Assert.Equal(e.SchemaRange.UpperBound, 10); + Assert.Equal(0, e.SchemaRange.LowerBound); + Assert.Equal(10, e.SchemaRange.UpperBound); } } diff --git a/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Functions.cs b/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Functions.cs index d12f6442bd..e011ed598d 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Functions.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Functions.cs @@ -3,7 +3,6 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.Northwind; -using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; using Xunit; namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query @@ -27,7 +26,8 @@ public override async Task Query_expression_with_to_string_and_contains(bool isA } [ConditionalTheory(Skip = "Fixed for PostgreSQL 12.1, https://www.postgresql.org/message-id/CADT4RqAz7oN4vkPir86Kg1_mQBmBxCp-L_%3D9vRpgSNPJf0KRkw%40mail.gmail.com")] - public override Task Indexof_with_emptystring(bool isAsync) => Task.CompletedTask; + public override Task Indexof_with_emptystring(bool isAsync) + => base.Indexof_with_emptystring(isAsync); #region Regex @@ -35,10 +35,11 @@ public override async Task Query_expression_with_to_string_and_contains(bool isA [MemberData(nameof(IsAsyncData))] public async Task Regex_IsMatch(bool isAsync) { - await AssertQuery( + await AssertQuery( isAsync, - cs => cs.Where(c => Regex.IsMatch(c.CompanyName, "^A")), + cs => cs.Set().Where(c => Regex.IsMatch(c.CompanyName, "^A")), entryCount: 4); + AssertContainsSqlFragment(@"WHERE c.""CompanyName"" ~ ('(?p)' || '^A')"); } @@ -46,10 +47,11 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public async Task Regex_IsMatchOptionsNone(bool isAsync) { - await AssertQuery( + await AssertQuery( isAsync, - cs => cs.Where(c => Regex.IsMatch(c.CompanyName, "^A", RegexOptions.None)), + cs => cs.Set().Where(c => Regex.IsMatch(c.CompanyName, "^A", RegexOptions.None)), entryCount: 4); + AssertContainsSqlFragment(@"WHERE c.""CompanyName"" ~ ('(?p)' || '^A')"); } @@ -57,10 +59,11 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public async Task Regex_IsMatchOptionsIgnoreCase(bool isAsync) { - await AssertQuery( + await AssertQuery( isAsync, - cs => cs.Where(c => Regex.IsMatch(c.CompanyName, "^a", RegexOptions.IgnoreCase)), + cs => cs.Set().Where(c => Regex.IsMatch(c.CompanyName, "^a", RegexOptions.IgnoreCase)), entryCount: 4); + AssertContainsSqlFragment(@"WHERE c.""CompanyName"" ~ ('(?ip)' || '^a')"); } @@ -68,10 +71,11 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public async Task Regex_IsMatchOptionsMultiline(bool isAsync) { - await AssertQuery( + await AssertQuery( isAsync, - cs => cs.Where(c => Regex.IsMatch(c.CompanyName, "^A", RegexOptions.Multiline)), + cs => cs.Set().Where(c => Regex.IsMatch(c.CompanyName, "^A", RegexOptions.Multiline)), entryCount: 4); + AssertContainsSqlFragment(@"WHERE c.""CompanyName"" ~ ('(?n)' || '^A')"); } @@ -80,10 +84,11 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public async Task Regex_IsMatchOptionsSingleline(bool isAsync) { - await AssertQuery( + await AssertQuery( isAsync, - cs => cs.Where(c => Regex.IsMatch(c.CompanyName, "^A", RegexOptions.Singleline)), + cs => cs.Set().Where(c => Regex.IsMatch(c.CompanyName, "^A", RegexOptions.Singleline)), entryCount: 4); + AssertContainsSqlFragment(@"WHERE c.""CompanyName"" ~ '^A'"); } @@ -91,10 +96,11 @@ await AssertQuery( [MemberData(nameof(IsAsyncData))] public async Task Regex_IsMatchOptionsIgnorePatternWhitespace(bool isAsync) { - await AssertQuery( + await AssertQuery( isAsync, - cs => cs.Where(c => Regex.IsMatch(c.CompanyName, "^ A", RegexOptions.IgnorePatternWhitespace)), + cs => cs.Set().Where(c => Regex.IsMatch(c.CompanyName, "^ A", RegexOptions.IgnorePatternWhitespace)), entryCount: 4); + AssertContainsSqlFragment(@"WHERE c.""CompanyName"" ~ ('(?px)' || '^ A')"); } @@ -110,6 +116,7 @@ public void Regex_IsMatchOptionsUnsupported() public override async Task Where_guid_newguid(bool isAsync) { await base.Where_guid_newguid(isAsync); + AssertContainsSqlFragment(@"WHERE uuid_generate_v4() <> '00000000-0000-0000-0000-000000000000'"); } @@ -117,13 +124,17 @@ public override async Task Where_guid_newguid(bool isAsync) [MemberData(nameof(IsAsyncData))] public virtual async Task OrderBy_Guid_NewGuid(bool isAsync) { - await AssertQuery(isAsync, ods => ods.OrderBy(od => Guid.NewGuid()).Select(x => x), entryCount: 2155); + await AssertQuery( + isAsync, + ods => ods.Set().OrderBy(od => Guid.NewGuid()).Select(x => x), + entryCount: 2155); + AssertContainsSqlFragment(@"ORDER BY uuid_generate_v4()"); } #endregion void AssertContainsSqlFragment(string expectedFragment) - => Assert.True(Fixture.TestSqlLoggerFactory.SqlStatements.Any(s => s.Contains(expectedFragment))); + => Assert.Contains(Fixture.TestSqlLoggerFactory.SqlStatements, s => s.Contains(expectedFragment)); } } diff --git a/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.ResultOperators.cs b/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.ResultOperators.cs new file mode 100644 index 0000000000..98779d579a --- /dev/null +++ b/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.ResultOperators.cs @@ -0,0 +1,8 @@ +namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query +{ + public partial class SimpleQueryNpgsqlTest + { + // Already removed in 3.1, waiting for nightly build + public override void Paging_operation_on_string_doesnt_issue_warning() {} + } +} diff --git a/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Select.cs b/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Select.cs new file mode 100644 index 0000000000..544b3a01af --- /dev/null +++ b/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Select.cs @@ -0,0 +1,10 @@ +using System.Threading.Tasks; + +namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query +{ + public partial class SimpleQueryNpgsqlTest + { + public override Task Member_binding_after_ctor_arguments_fails_with_client_eval(bool isAsync) + => AssertTranslationFailed(() => base.Member_binding_after_ctor_arguments_fails_with_client_eval(isAsync)); + } +} diff --git a/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Where.cs b/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Where.cs index fdf9556700..bd310621f4 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Where.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.Where.cs @@ -9,18 +9,23 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query public partial class SimpleQueryNpgsqlTest { [Theory(Skip = "SQL translation not implemented, too annoying")] - public override Task Where_datetime_millisecond_component(bool isAsync) => null; + public override Task Where_datetime_millisecond_component(bool isAsync) + => base.Where_datetime_millisecond_component(isAsync); [Theory(Skip = "Translation not implemented yet, #873")] - public override Task Where_datetimeoffset_now_component(bool isAsync) => null; + public override Task Where_datetimeoffset_now_component(bool isAsync) + => base.Where_datetimeoffset_now_component(isAsync); [Theory(Skip = "Translation not implemented yet, #873")] - public override Task Where_datetimeoffset_utcnow_component(bool isAsync) => null; + public override Task Where_datetimeoffset_utcnow_component(bool isAsync) + => base.Where_datetimeoffset_utcnow_component(isAsync); [Theory(Skip = "PostgreSQL only has log(x, base) over numeric, may be possible to cast back and forth though")] - public override Task Where_math_log_new_base(bool isAsync) => null; + public override Task Where_math_log_new_base(bool isAsync) + => base.Where_math_log_new_base(isAsync); [Theory(Skip = "Convert on DateTime not yet supported")] - public override Task Convert_ToString(bool isAsync) => null; + public override Task Convert_ToString(bool isAsync) + => base.Convert_ToString(isAsync); } } diff --git a/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.cs index 5f2c2e2d7a..7e73ec68e2 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SimpleQueryNpgsqlTest.cs @@ -18,11 +18,23 @@ public SimpleQueryNpgsqlTest(NorthwindQueryNpgsqlFixture fi //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } + [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/18674")] + [MemberData(nameof(IsAsyncData))] + public override Task Default_if_empty_top_level_arg(bool isAsync) + => base.Default_if_empty_top_level_arg(isAsync); + + [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/18674")] + [MemberData(nameof(IsAsyncData))] + public override Task Default_if_empty_top_level_arg_followed_by_projecting_constant(bool isAsync) + => base.Default_if_empty_top_level_arg_followed_by_projecting_constant(isAsync); + [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/17379")] - public override Task SelectMany_correlated_with_outer_2(bool isAsync) => null; + public override Task SelectMany_correlated_with_outer_2(bool isAsync) + => base.SelectMany_correlated_with_outer_2(isAsync); [ConditionalTheory(Skip = "https://github.com/aspnet/EntityFrameworkCore/pull/17379")] - public override Task SelectMany_correlated_with_outer_4(bool isAsync) => null; + public override Task SelectMany_correlated_with_outer_4(bool isAsync) + => base.SelectMany_correlated_with_outer_4(isAsync); #region Overrides @@ -42,9 +54,9 @@ public async Task Select_expression_date_add_year_param(bool isAsync) { var years = 2; - await AssertQuery( + await AssertQuery( isAsync, - os => os.Where(o => o.OrderDate != null) + ss => ss.Set().Where(o => o.OrderDate != null) .Select( o => new Order { @@ -101,15 +113,17 @@ public override async Task Contains_with_local_nullable_uint_array_closure(bool [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public Task PadLeft_with_constant(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(x => x.Address.PadLeft(20).EndsWith("Walserweg 21")), + => AssertQuery( + isAsync, + ss => ss.Set().Where(x => x.Address.PadLeft(20).EndsWith("Walserweg 21")), entryCount: 1); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public Task PadLeft_char_with_constant(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(x => x.Address.PadLeft(20, 'a').EndsWith("Walserweg 21")), + => AssertQuery( + isAsync, + ss => ss.Set().Where(x => x.Address.PadLeft(20, 'a').EndsWith("Walserweg 21")), entryCount: 1); [ConditionalTheory] @@ -118,8 +132,9 @@ public Task PadLeft_with_parameter(bool isAsync) { var length = 20; - return AssertQuery(isAsync, cs => cs - .Where(x => x.Address.PadLeft(length).EndsWith("Walserweg 21")), + return AssertQuery( + isAsync, + ss => ss.Set().Where(x => x.Address.PadLeft(length).EndsWith("Walserweg 21")), entryCount: 1); } @@ -129,23 +144,26 @@ public Task PadLeft_char_with_parameter(bool isAsync) { var length = 20; - return AssertQuery(isAsync, cs => cs - .Where(x => x.Address.PadLeft(length, 'a').EndsWith("Walserweg 21")), + return AssertQuery( + isAsync, + ss => ss.Set().Where(x => x.Address.PadLeft(length, 'a').EndsWith("Walserweg 21")), entryCount: 1); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public Task PadRight_with_constant(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(x => x.Address.PadRight(20).StartsWith("Walserweg 21")), + => AssertQuery( + isAsync, + ss => ss.Set().Where(x => x.Address.PadRight(20).StartsWith("Walserweg 21")), entryCount: 1); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public Task PadRight_char_with_constant(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(x => x.Address.PadRight(20).StartsWith("Walserweg 21")), + => AssertQuery( + isAsync, + ss => ss.Set().Where(x => x.Address.PadRight(20).StartsWith("Walserweg 21")), entryCount: 1); [ConditionalTheory] @@ -154,8 +172,9 @@ public Task PadRight_with_parameter(bool isAsync) { var length = 20; - return AssertQuery(isAsync, cs => cs - .Where(x => x.Address.PadRight(length).StartsWith("Walserweg 21")), + return AssertQuery( + isAsync, + ss => ss.Set().Where(x => x.Address.PadRight(length).StartsWith("Walserweg 21")), entryCount: 1); } @@ -165,8 +184,9 @@ public Task PadRight_char_with_parameter(bool isAsync) { var length = 20; - return AssertQuery(isAsync, cs => cs - .Where(x => x.Address.PadRight(length, 'a').StartsWith("Walserweg 21")), + return AssertQuery( + isAsync, + ss => ss.Set().Where(x => x.Address.PadRight(length, 'a').StartsWith("Walserweg 21")), entryCount: 1); } @@ -177,26 +197,32 @@ public Task PadRight_char_with_parameter(bool isAsync) [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public Task Substring_without_length_with_Index_of(bool isAsync) - => AssertQuery(isAsync, cs => cs - .Where(x => x.Address == "Walserweg 21") - .Where(x => x.Address.Substring(x.Address.IndexOf("e")) == "erweg 21"), entryCount: 1); - + => AssertQuery( + isAsync, + ss => ss.Set() + .Where(x => x.Address == "Walserweg 21") + .Where(x => x.Address.Substring(x.Address.IndexOf("e")) == "erweg 21"), + entryCount: 1); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public Task Substring_without_length_with_constant(bool isAsync) - => AssertQuery(isAsync, cs => cs + => AssertQuery( + isAsync, //Walserweg 21 - .Where(x => x.Address.Substring(5) == "rweg 21"), entryCount: 1); + cs => cs.Set().Where(x => x.Address.Substring(5) == "rweg 21"), + entryCount: 1); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public Task Substring_without_length_with_closure(bool isAsync) { var startIndex = 5; - return AssertQuery(isAsync, cs => cs + return AssertQuery( + isAsync, //Walserweg 21 - .Where(x => x.Address.Substring(startIndex) == "rweg 21"), entryCount: 1); + ss => ss.Set().Where(x => x.Address.Substring(startIndex) == "rweg 21"), + entryCount: 1); } #endregion @@ -208,8 +234,9 @@ public Task Substring_without_length_with_closure(bool isAsync) [MemberData(nameof(IsAsyncData))] public async Task Array_Contains_constant(bool isAsync) { - await AssertQuery(isAsync, cs => cs - .Where(c => new[] { "ALFKI", "ANATR" }.Contains(c.CustomerID)), + await AssertQuery( + isAsync, + ss => ss.Set().Where(c => new[] { "ALFKI", "ANATR" }.Contains(c.CustomerID)), entryCount: 2); // Note: for constant lists there's no advantage in using the PostgreSQL-specific x = ANY (a b, c), unlike @@ -227,8 +254,9 @@ public async Task Array_Contains_parameter(bool isAsync) { var ids = new[] { "ALFKI", "ANATR" }; - await AssertQuery(isAsync, cs => cs - .Where(c => ids.Contains(c.CustomerID)), + await AssertQuery( + isAsync, + ss => ss.Set().Where(c => ids.Contains(c.CustomerID)), entryCount: 2); // Instead of c.""CustomerID"" x in ('ALFKI', 'ANATR') we should generate the PostgreSQL-specific x = ANY (a, b, c), which can @@ -257,8 +285,9 @@ public async Task Array_Any_Like(bool isAsync) { var collection = new[] { "A%", "B%", "C%" }; - await AssertQuery(isAsync, cs => cs - .Where(c => collection.Any(y => EF.Functions.Like(c.Address, y))), + await AssertQuery( + isAsync, + ss => ss.Set().Where(c => collection.Any(y => EF.Functions.Like(c.Address, y))), entryCount: 22); AssertSql( @@ -275,8 +304,9 @@ public async Task Array_All_Like(bool isAsync) { var collection = new[] { "A%", "B%", "C%" }; - await AssertQuery(isAsync, cs => cs - .Where(c => collection.All(y => EF.Functions.Like(c.Address, y)))); + await AssertQuery( + isAsync, + ss => ss.Set().Where(c => collection.All(y => EF.Functions.Like(c.Address, y)))); AssertSql( @"@__collection_0='System.String[]' (DbType = Object) @@ -292,8 +322,9 @@ public async Task Array_Any_ILike(bool isAsync) { var collection = new[] { "a%", "b%", "c%" }; - await AssertQuery(isAsync, cs => cs - .Where(c => collection.Any(y => EF.Functions.ILike(c.Address, y))), + await AssertQuery( + isAsync, + ss => ss.Set().Where(c => collection.Any(y => EF.Functions.ILike(c.Address, y))), entryCount: 22); AssertSql( @@ -310,8 +341,9 @@ public async Task Array_All_ILike(bool isAsync) { var collection = new[] { "a%", "b%", "c%" }; - await AssertQuery(isAsync, cs => cs - .Where(c => collection.All(y => EF.Functions.ILike(c.Address, y)))); + await AssertQuery( + isAsync, + ss => ss.Set().Where(c => collection.All(y => EF.Functions.ILike(c.Address, y)))); AssertSql( @"@__collection_0='System.String[]' (DbType = Object) diff --git a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs index c80838768b..1dd6fb7fac 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeographyTest.cs @@ -85,11 +85,11 @@ public override async Task Distance(bool isAsync) public override async Task GeometryType(bool isAsync) { // PostGIS returns "POINT", NTS returns "Point" - await AssertQuery( + await AssertQuery( isAsync, - es => es.Select( + es => es.Set().Select( e => new { e.Id, GeometryType = e.Point == null ? null : e.Point.GeometryType.ToLower() }), - elementSorter: x => x.Id); + x => x.Id); // AssertSql( // @"SELECT p.""Id"", LOWER(GeometryType(p.""Point"")) AS ""GeometryType"" diff --git a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs index a7aa990c75..9b8f249d60 100644 --- a/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/SpatialQueryNpgsqlGeometryTest.cs @@ -218,11 +218,11 @@ public override async Task ExteriorRing(bool isAsync) public override async Task GeometryType(bool isAsync) { // PostGIS returns "POINT", NTS returns "Point" - await AssertQuery( + await AssertQuery( isAsync, - es => es.Select( + es => es.Set().Select( e => new { e.Id, GeometryType = e.Point == null ? null : e.Point.GeometryType.ToLower() }), - elementSorter: x => x.Id); + x => x.Id); // AssertSql( // @"SELECT p.""Id"", LOWER(GeometryType(p.""Point"")) AS ""GeometryType"" diff --git a/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs b/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs index c6e0dee5da..97fae3852f 100644 --- a/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs +++ b/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs @@ -44,7 +44,7 @@ public override void Scalar_Function_With_Translator_Translates_Static() SELECT length(c.""LastName"") FROM ""Customers"" AS c -WHERE (c.""Id"" = @__customerId_0) AND (@__customerId_0 IS NOT NULL) +WHERE c.""Id"" = @__customerId_0 LIMIT 2"); } @@ -98,7 +98,7 @@ public override void Scalar_Function_Anonymous_Type_Select_Parameter_Static() SELECT c.""LastName"", ""CustomerOrderCount""(@__customerId_0) AS ""OrderCount"" FROM ""Customers"" AS c -WHERE (c.""Id"" = @__customerId_0) AND (@__customerId_0 IS NOT NULL) +WHERE c.""Id"" = @__customerId_0 LIMIT 2"); } @@ -113,7 +113,7 @@ public override void Scalar_Function_Anonymous_Type_Select_Nested_Static() SELECT c.""LastName"", ""StarValue""(@__starCount_1, ""CustomerOrderCount""(@__customerId_0)) AS ""OrderCount"" FROM ""Customers"" AS c -WHERE (c.""Id"" = @__customerId_0) AND (@__customerId_0 IS NOT NULL) +WHERE c.""Id"" = @__customerId_0 LIMIT 2"); } @@ -202,7 +202,7 @@ public override void Scalar_Function_Let_Not_Parameter_Static() SELECT c.""LastName"", ""CustomerOrderCount""(@__customerId_0) AS ""OrderCount"" FROM ""Customers"" AS c -WHERE (c.""Id"" = @__customerId_0) AND (@__customerId_0 IS NOT NULL) +WHERE c.""Id"" = @__customerId_0 LIMIT 2"); } @@ -217,7 +217,7 @@ public override void Scalar_Function_Let_Nested_Static() SELECT c.""LastName"", ""StarValue""(@__starCount_0, ""CustomerOrderCount""(@__customerId_1)) AS ""OrderCount"" FROM ""Customers"" AS c -WHERE (c.""Id"" = @__customerId_1) AND (@__customerId_1 IS NOT NULL) +WHERE c.""Id"" = @__customerId_1 LIMIT 2"); } @@ -426,7 +426,7 @@ public override void Scalar_Function_With_Translator_Translates_Instance() SELECT length(c.""LastName"") FROM ""Customers"" AS c -WHERE (c.""Id"" = @__customerId_0) AND (@__customerId_0 IS NOT NULL) +WHERE c.""Id"" = @__customerId_0 LIMIT 2"); } @@ -476,7 +476,7 @@ public override void Scalar_Function_Anonymous_Type_Select_Parameter_Instance() SELECT c.""LastName"", ""CustomerOrderCount""(@__customerId_0) AS ""OrderCount"" FROM ""Customers"" AS c -WHERE (c.""Id"" = @__customerId_0) AND (@__customerId_0 IS NOT NULL) +WHERE c.""Id"" = @__customerId_0 LIMIT 2"); } @@ -491,7 +491,7 @@ public override void Scalar_Function_Anonymous_Type_Select_Nested_Instance() SELECT c.""LastName"", ""StarValue""(@__starCount_2, ""CustomerOrderCount""(@__customerId_0)) AS ""OrderCount"" FROM ""Customers"" AS c -WHERE (c.""Id"" = @__customerId_0) AND (@__customerId_0 IS NOT NULL) +WHERE c.""Id"" = @__customerId_0 LIMIT 2"); } @@ -576,11 +576,11 @@ public override void Scalar_Function_Let_Not_Parameter_Instance() base.Scalar_Function_Let_Not_Parameter_Instance(); AssertSql( - @"@__8__locals1_customerId_1='2' + @"@__customerId_1='2' -SELECT c.""LastName"", ""CustomerOrderCount""(@__8__locals1_customerId_1) AS ""OrderCount"" +SELECT c.""LastName"", ""CustomerOrderCount""(@__customerId_1) AS ""OrderCount"" FROM ""Customers"" AS c -WHERE (c.""Id"" = @__8__locals1_customerId_1) AND (@__8__locals1_customerId_1 IS NOT NULL) +WHERE c.""Id"" = @__customerId_1 LIMIT 2"); } @@ -595,7 +595,7 @@ public override void Scalar_Function_Let_Nested_Instance() SELECT c.""LastName"", ""StarValue""(@__starCount_1, ""CustomerOrderCount""(@__customerId_2)) AS ""OrderCount"" FROM ""Customers"" AS c -WHERE (c.""Id"" = @__customerId_2) AND (@__customerId_2 IS NOT NULL) +WHERE c.""Id"" = @__customerId_2 LIMIT 2"); } diff --git a/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs b/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs index 4eef763467..16a431c6f2 100644 --- a/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs +++ b/test/EFCore.PG.FunctionalTests/Scaffolding/NpgsqlDatabaseModelFactoryTest.cs @@ -460,7 +460,7 @@ CREATE VIEW ""BlogsView"" var table = dbModel.Tables.Single(); Assert.Equal(2, table.Columns.Count); - Assert.Equal(null, table.PrimaryKey); + Assert.Null(table.PrimaryKey); Assert.All( table.Columns, c => { @@ -491,7 +491,7 @@ CREATE MATERIALIZED VIEW ""BlogsView"" var table = dbModel.Tables.Single(); Assert.Equal(2, table.Columns.Count); - Assert.Equal(null, table.PrimaryKey); + Assert.Null(table.PrimaryKey); Assert.All( table.Columns, c => { @@ -839,7 +839,7 @@ public void Computed_values_are_stored() var columns = dbModel.Tables.Single().Columns; // Note that on-the-fly computed columns aren't (yet) supported by PostgreSQL, only stored/persistedcolumns. - Assert.Equal(null, columns.Single(c => c.Name == "SumOfAAndB").DefaultValueSql); + Assert.Null(columns.Single(c => c.Name == "SumOfAAndB").DefaultValueSql); Assert.Equal(@"(""A"" + ""B"")", columns.Single(c => c.Name == "SumOfAAndB").ComputedColumnSql); }, @"DROP TABLE ""ComputedValues"""); diff --git a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs index 596ed4471b..ae7b2f3c46 100644 --- a/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs +++ b/test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs @@ -35,7 +35,6 @@ public void By_StoreType(string storeType, Type expectedClrType) [InlineData(typeof(NpgsqlRange), "dummyrange")] [InlineData(typeof(Geometry), "geometry")] [InlineData(typeof(Point), "geometry")] - [InlineData(typeof(Point), "geometry")] public void By_ClrType(Type clrType, string expectedStoreType) => Assert.Equal(expectedStoreType, ((RelationalTypeMapping)Source.FindMapping(clrType)).StoreType);