Skip to content

Commit

Permalink
Sync to EF 5.0.0-preview.3.20177.3
Browse files Browse the repository at this point in the history
Commit 87714065027c161e29d8b5901813a07682e93538
  • Loading branch information
roji committed Mar 28, 2020
1 parent 550fed4 commit 7ea91f5
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 34 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<EFCoreVersion>5.0.0-preview.3.20170.2</EFCoreVersion>
<MicrosoftExtensionsVersion>3.1.2</MicrosoftExtensionsVersion>
<EFCoreVersion>5.0.0-preview.3.20177.3</EFCoreVersion>
<MicrosoftExtensionsVersion>3.1.3</MicrosoftExtensionsVersion>
<NpgsqlVersion>4.1.3</NpgsqlVersion>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GraphUpdatesNpgsqlTest.GraphUpdatesNpgsqlFixture>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,33 +20,36 @@ public NorthwindDbFunctionsQueryNpgsqlTest(NorthwindQueryNpgsqlFixture<NoopModel

#region Like / ILike

public override void Like_literal()
public override async Task Like_literal(bool async)
{
// PostgreSQL like is case-sensitive, while the EF Core "default" (i.e. SqlServer) is insensitive.
// So we override and assert only 19 matches unlike the default's 34.
using var context = CreateContext();
var count = context.Customers.Count(c => EF.Functions.Like(c.ContactName, "%M%"));
await AssertCount(
async,
ss => ss.Set<Customer>(),
ss => ss.Set<Customer>(),
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
FROM ""Customers"" AS c
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
Expand Down
19 changes: 0 additions & 19 deletions test/EFCore.PG.FunctionalTests/Query/UdfDbFunctionNpgsqlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 7ea91f5

Please sign in to comment.