From 7ea91f5aab43af56895c6fe5a94cc8ab758d725c Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Sat, 28 Mar 2020 14:25:36 +0100 Subject: [PATCH] Sync to EF 5.0.0-preview.3.20177.3 Commit 87714065027c161e29d8b5901813a07682e93538 --- Directory.Build.targets | 4 ++-- .../NpgsqlSqlTranslatingExpressionVisitor.cs | 2 +- .../CustomConvertersNpgsqlTest.cs | 8 +++++++ .../GraphUpdatesNpgsqlTest.cs | 2 +- .../ProxyGraphUpdatesNpgsqlTest.cs | 6 +++--- .../NorthwindDbFunctionsQueryNpgsqlTest.cs | 21 ++++++++++++------- .../Query/UdfDbFunctionNpgsqlTests.cs | 19 ----------------- .../TestRelationalCommandBuilderFactory.cs | 1 + 8 files changed, 29 insertions(+), 34 deletions(-) rename test/EFCore.PG.FunctionalTests/{ => GraphUpdates}/GraphUpdatesNpgsqlTest.cs (95%) rename test/EFCore.PG.FunctionalTests/{ => GraphUpdates}/ProxyGraphUpdatesNpgsqlTest.cs (96%) diff --git a/Directory.Build.targets b/Directory.Build.targets index 9fcaa6d12..e14c7ef7e 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,7 +1,7 @@  - 5.0.0-preview.3.20170.2 - 3.1.2 + 5.0.0-preview.3.20177.3 + 3.1.3 4.1.3 diff --git a/src/EFCore.PG/Query/Internal/NpgsqlSqlTranslatingExpressionVisitor.cs b/src/EFCore.PG/Query/Internal/NpgsqlSqlTranslatingExpressionVisitor.cs index 331eb1569..5bfda3832 100644 --- a/src/EFCore.PG/Query/Internal/NpgsqlSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.PG/Query/Internal/NpgsqlSqlTranslatingExpressionVisitor.cs @@ -141,7 +141,7 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) if (sqlOperand.Type == typeof(byte[]) && (sqlOperand.TypeMapping == null || sqlOperand.TypeMapping is NpgsqlByteArrayTypeMapping)) { - return SqlExpressionFactory.Function( + return _sqlExpressionFactory.Function( "LENGTH", new[] { sqlOperand }, nullable: true, diff --git a/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs index ece563fa9..e29eec95f 100644 --- a/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs @@ -31,6 +31,14 @@ public override void Where_bool_gets_converted_to_equality_when_value_conversion [Fact(Skip="https://github.com/aspnet/EntityFrameworkCore/issues/14159")] public override void Can_query_using_any_data_type_nullable_shadow() {} + [Fact(Skip="https://github.com/dotnet/efcore/issues/18147")] + public override void Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_EFProperty() + => base.Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_EFProperty(); + + [Fact(Skip="https://github.com/dotnet/efcore/issues/18147")] + public override void Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_indexer() + => base.Where_bool_gets_converted_to_equality_when_value_conversion_is_used_using_indexer(); + public class CustomConvertersNpgsqlFixture : CustomConvertersFixtureBase { public override bool StrictEquality => true; diff --git a/test/EFCore.PG.FunctionalTests/GraphUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/GraphUpdates/GraphUpdatesNpgsqlTest.cs similarity index 95% rename from test/EFCore.PG.FunctionalTests/GraphUpdatesNpgsqlTest.cs rename to test/EFCore.PG.FunctionalTests/GraphUpdates/GraphUpdatesNpgsqlTest.cs index ba0f714e4..71802c847 100644 --- a/test/EFCore.PG.FunctionalTests/GraphUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/GraphUpdates/GraphUpdatesNpgsqlTest.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Logging; using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; -namespace Npgsql.EntityFrameworkCore.PostgreSQL +namespace Npgsql.EntityFrameworkCore.PostgreSQL.GraphUpdates { public class GraphUpdatesNpgsqlTest : GraphUpdatesTestBase diff --git a/test/EFCore.PG.FunctionalTests/ProxyGraphUpdatesNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/GraphUpdates/ProxyGraphUpdatesNpgsqlTest.cs similarity index 96% rename from test/EFCore.PG.FunctionalTests/ProxyGraphUpdatesNpgsqlTest.cs rename to test/EFCore.PG.FunctionalTests/GraphUpdates/ProxyGraphUpdatesNpgsqlTest.cs index 4af101390..3a31d3f24 100644 --- a/test/EFCore.PG.FunctionalTests/ProxyGraphUpdatesNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/GraphUpdates/ProxyGraphUpdatesNpgsqlTest.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.Logging; using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities; -namespace Npgsql.EntityFrameworkCore.PostgreSQL +namespace Npgsql.EntityFrameworkCore.PostgreSQL.GraphUpdates { public class ProxyGraphUpdatesNpgsqlTest { @@ -74,7 +74,7 @@ public class ProxyGraphUpdatesWithChangeTrackingNpgsqlFixture : ProxyGraphUpdate protected override string StoreName { get; } = "ProxyGraphChangeTrackingUpdatesTest"; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder.UseChangeDetectionProxies()); + => base.AddOptions(builder.UseChangeTrackingProxies()); protected override IServiceCollection AddServices(IServiceCollection serviceCollection) => base.AddServices(serviceCollection.AddEntityFrameworkProxies()); @@ -103,7 +103,7 @@ public class ProxyGraphUpdatesWithChangeTrackingAndLazyLoadingNpgsqlFixture : Pr protected override string StoreName { get; } = "ProxyGraphChangeTrackingAndLazyLoadingUpdatesTest"; public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - => base.AddOptions(builder.UseLazyLoadingProxies().UseChangeDetectionProxies()); + => base.AddOptions(builder.UseLazyLoadingProxies().UseChangeTrackingProxies()); protected override IServiceCollection AddServices(IServiceCollection serviceCollection) => base.AddServices(serviceCollection.AddEntityFrameworkProxies()); diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs index 48dad7fc6..2c6125cdf 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs @@ -1,6 +1,8 @@ using System.Linq; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; using Xunit.Abstractions; @@ -18,23 +20,26 @@ public NorthwindDbFunctionsQueryNpgsqlTest(NorthwindQueryNpgsqlFixture EF.Functions.Like(c.ContactName, "%M%")); + await AssertCount( + async, + ss => ss.Set(), + ss => ss.Set(), + c => EF.Functions.Like(c.ContactName, "%M%"), + c => c.ContactName.Contains("M")); - Assert.Equal(19, count); AssertSql( @"SELECT COUNT(*)::INT FROM ""Customers"" AS c WHERE c.""ContactName"" LIKE '%M%'"); } - public override void Like_identity() + public override async Task Like_identity(bool async) { - base.Like_identity(); + await base.Like_identity(async); AssertSql( @"SELECT COUNT(*)::INT @@ -42,9 +47,9 @@ public override void Like_identity() WHERE c.""ContactName"" LIKE c.""ContactName"" ESCAPE ''"); } - public override void Like_literal_with_escape() + public override async Task Like_literal_with_escape(bool async) { - base.Like_literal_with_escape(); + await base.Like_literal_with_escape(async); AssertSql( @"SELECT COUNT(*)::INT diff --git a/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs b/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs index d74108466..86778fc2b 100644 --- a/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs +++ b/test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs @@ -913,25 +913,6 @@ RETURNS TABLE (""OrderId"" INT, ""CustomerId"" INT, ""OrderDate"" TIMESTAMP) HAVING COUNT(""ProductId"") > 1 $$ LANGUAGE SQL"); - context.Database.ExecuteSqlRaw(@" - CREATE FUNCTION ""GetCreditCards"" (""customerId"" INT) - RETURNS TABLE (""Id"" INT, ""CreditCard_CreditCardType"" INT, ""CreditCard_Number"" TEXT) - AS $$ - SELECT ""Id"", ""CreditCard_CreditCardType"", ""CreditCard_Number"" - FROM ""Customers"" AS c - WHERE c.""CreditCard_CreditCardType"" IS NOT NULL AND c.""CreditCard_Number"" IS NOT NULL - AND c.""Id"" = $1 - $$ LANGUAGE SQL"); - - context.Database.ExecuteSqlRaw(@" - CREATE FUNCTION""GetPhoneInformation"" (""customerId"" INT, ""areaCode"" VARCHAR(3)) - RETURNS TABLE (""PhoneType"" INT, ""Number"" TEXT, ""CustomerId"" INT, ""Id"" INT) - AS $$ - SELECT ""PhoneType"", ""Number"", ""CustomerId"", ""Id"" - FROM ""PhoneInformation"" AS pi - WHERE pi.""CustomerId"" = $1 AND POSITION($2 IN pi.""Number"") = 1 - $$ LANGUAGE SQL"); - context.Database.ExecuteSqlRaw(@" CREATE FUNCTION ""AddValues"" (a INT, b INT) RETURNS INT AS $$ SELECT $1 + $2 $$ LANGUAGE SQL"); diff --git a/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs b/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs index fd8d569f7..2643ba39d 100644 --- a/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs +++ b/test/EFCore.PG.FunctionalTests/TestUtilities/TestRelationalCommandBuilderFactory.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Storage;