Skip to content

Commit

Permalink
Depend on 3.1.0-preview2.19525.5
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
roji committed Nov 3, 2019
1 parent da1d534 commit db3d902
Show file tree
Hide file tree
Showing 37 changed files with 366 additions and 161 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ jobs:
shell: bash

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1.0.2 # Issues with DOTNET_ROOT
uses: actions/setup-dotnet@bb95ce727fd49ec1a65933419cc7c91747785302
with:
dotnet-version: '3.0.100'
dotnet-version: '3.1.100-preview1-014459'

- name: Test
run: dotnet test --configuration Debug
Expand All @@ -80,6 +80,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v1

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@bb95ce727fd49ec1a65933419cc7c91747785302
with:
dotnet-version: '3.1.100-preview1-014459'

- name: Pack NuGet packages (CI versions)
if: startsWith(github.ref, 'refs/heads/')
run: dotnet pack --configuration Release --output nupkgs --version-suffix "ci.$(date -u +%Y%m%dT%H%M%S)+sha.${GITHUB_SHA:0:9}"
Expand Down
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/npgsql/efcore.pg</RepositoryUrl>

<TargetFrameworks>netstandard2.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>

<PackageLicenseExpression>PostgreSQL</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/npgsql/efcore.pg</PackageProjectUrl>
Expand All @@ -24,6 +24,7 @@
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>NU5105</NoWarn>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>

<!-- Signing configuration -->
Expand Down
16 changes: 8 additions & 8 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project>
<ItemGroup>
<PackageReference Update="Microsoft.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational" Version="3.0.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Abstractions" Version="3.0.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="3.0.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Design" Version="3.0.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore" Version="3.1.0-preview2.19525.5" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0-preview2.19525.5" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Abstractions" Version="3.1.0-preview2.19525.5" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="3.1.0-preview2.19525.5" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Design" Version="3.1.0-preview2.19525.5" />

<PackageReference Update="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Update="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
<PackageReference Update="Microsoft.Extensions.Logging" Version="3.0.0" />
<PackageReference Update="Microsoft.Extensions.Configuration.Json" Version="3.1.0-preview2.19525.4" />
<PackageReference Update="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.0-preview2.19525.4" />
<PackageReference Update="Microsoft.Extensions.Logging" Version="3.1.0-preview2.19525.4" />

<PackageReference Update="Npgsql" Version="4.1.1" />
<PackageReference Update="Npgsql.NodaTime" Version="4.1.1" />
Expand Down
14 changes: 14 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
<add key="extensions" value="https://dotnetfeed.blob.core.windows.net/aspnet-extensions/index.json" />
<add key="entityframeworkcore" value="https://dotnetfeed.blob.core.windows.net/aspnet-entityframeworkcore/index.json" />
<add key="entityframework6" value="https://dotnetfeed.blob.core.windows.net/aspnet-entityframework6/index.json" />
<add key="aspnetcore-tooling" value="https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore-tooling/index.json" />
<add key="aspnetcore" value="https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore/index.json" />
<add key="aspnet-blazor" value="https://dotnetfeed.blob.core.windows.net/aspnet-blazor/index.json" />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.0.100"
"version": "3.1.100-preview1-014459"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<Import Project="..\Directory.Build.props" />

<PropertyGroup>
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<!-- There's lots of use of internal EF Core APIs from the tests, suppress the analyzer warnings for those -->
<NoWarn>$(NoWarn);xUnit1004;EF1001</NoWarn>
<NoWarn>$(NoWarn);xUnit1003;xUnit1004;xUnit1013;EF1001</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions test/EFCore.PG.FunctionalTests/BuiltInDataTypesNpgsqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var results
.Select(e => e.Int)
.ToList();

Assert.Equal(0, results.Count);
Assert.Empty(results);

AssertSql(
@"SELECT m.""Int""
Expand All @@ -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)");
}
}

Expand Down
21 changes: 14 additions & 7 deletions test/EFCore.PG.FunctionalTests/CommandInterceptionNpgsqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
13 changes: 12 additions & 1 deletion test/EFCore.PG.FunctionalTests/CustomConvertersNpgsqlTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
using Xunit;
Expand All @@ -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() {}

Expand Down
5 changes: 4 additions & 1 deletion test/EFCore.PG.FunctionalTests/LazyLoadProxySqlNpgsqlTest.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions test/EFCore.PG.FunctionalTests/Query/ArrayQueryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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""
Expand All @@ -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'
Expand All @@ -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""
Expand All @@ -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""
Expand All @@ -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");
}
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Query;
using Xunit;
using Xunit.Abstractions;

namespace Npgsql.EntityFrameworkCore.PostgreSQL.Query
Expand All @@ -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);
}
}
8 changes: 4 additions & 4 deletions test/EFCore.PG.FunctionalTests/Query/EnumQueryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand All @@ -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");
}
}
Expand All @@ -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");
}
}
Expand All @@ -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");
}
}
Expand Down
Loading

0 comments on commit db3d902

Please sign in to comment.