Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync to EF 5.0.0-preview.1.20107.7 #1275

Merged
merged 1 commit into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<EFCoreVersion>5.0.0-preview.1.20107.7</EFCoreVersion>
<EFCoreVersion>5.0.0-preview.1.20115.5</EFCoreVersion>
<MicrosoftExtensionsVersion>3.1.1</MicrosoftExtensionsVersion>
<NpgsqlVersion>4.1.3</NpgsqlVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,14 @@ public override ConventionSet CreateConventionSet()

ReplaceConvention(conventionSet.ForeignKeyRemovedConventions, valueGenerationConvention);

ConventionSet.AddBefore(
conventionSet.ModelFinalizedConventions,
valueGenerationStrategyConvention,
typeof(ValidatingConvention));

var storeGenerationConvention =
new NpgsqlStoreGenerationConvention(Dependencies, RelationalDependencies);
ReplaceConvention(conventionSet.PropertyAnnotationChangedConventions, storeGenerationConvention);
ReplaceConvention(
conventionSet.PropertyAnnotationChangedConventions, (RelationalValueGenerationConvention)valueGenerationConvention);

ReplaceConvention(conventionSet.ModelFinalizedConventions, storeGenerationConvention);
conventionSet.ModelFinalizingConventions.Add(valueGenerationStrategyConvention);
ReplaceConvention(conventionSet.ModelFinalizingConventions, storeGenerationConvention);

return conventionSet;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
Expand All @@ -12,7 +13,7 @@ namespace Npgsql.EntityFrameworkCore.PostgreSQL.Metadata.Conventions
/// <see cref="NpgsqlValueGenerationStrategy.IdentityByDefaultColumn"/> for newer PostgreSQL versions,
/// and <see cref="NpgsqlValueGenerationStrategy.SerialColumn"/> for pre-10.0 versions.
/// </summary>
public class NpgsqlValueGenerationStrategyConvention : IModelInitializedConvention, IModelFinalizedConvention
public class NpgsqlValueGenerationStrategyConvention : IModelInitializedConvention, IModelFinalizingConvention
{
[CanBeNull] readonly Version _postgresVersion;

Expand All @@ -36,23 +37,15 @@ public NpgsqlValueGenerationStrategyConvention(
/// </summary>
protected virtual ProviderConventionSetBuilderDependencies Dependencies { get; }

/// <summary>
/// Called after a model is initialized.
/// </summary>
/// <param name="modelBuilder">The builder for the model.</param>
/// <param name="context">Additional information associated with convention execution.</param>
/// <inheritdoc />
public virtual void ProcessModelInitialized(IConventionModelBuilder modelBuilder, IConventionContext<IConventionModelBuilder> context)
=> modelBuilder.HasValueGenerationStrategy(
_postgresVersion != null && _postgresVersion < new Version(10, 0)
? NpgsqlValueGenerationStrategy.SerialColumn
: NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);

/// <summary>
/// Called after a model is finalized.
/// </summary>
/// <param name="modelBuilder">The builder for the model.</param>
/// <param name="context">Additional information associated with convention execution.</param>
public virtual void ProcessModelFinalized(
/// <inheritdoc />
public virtual void ProcessModelFinalizing(
IConventionModelBuilder modelBuilder, IConventionContext<IConventionModelBuilder> context)
{
foreach (var entityType in modelBuilder.Metadata.GetEntityTypes())
Expand Down
28 changes: 0 additions & 28 deletions test/EFCore.PG.FunctionalTests/CommandInterceptionNpgsqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,6 @@ 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)
=> 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)
=> 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)
=> 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)
=> 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)
=> 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)
=> 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)
=> base.Intercept_non_query_to_replace_result(async, inject);

public abstract class InterceptionNpgsqlFixtureBase : InterceptionFixtureBase
{
protected override string StoreName => "CommandInterception";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,8 @@ protected override void Up(MigrationBuilder migrationBuilder)

public override void Can_diff_against_2_2_model()
{
// using (var context = new ModelSnapshot22.BloggingContext())
// {
// DiffSnapshot(new BloggingContextModelSnapshot22(), context);
// }
//
using var context = new ModelSnapshot22.BloggingContext();
var snapshot = new BloggingContextModelSnapshot22();
var sourceModel = snapshot.Model;
var targetModel = context.Model;

var modelDiffer = context.GetService<IMigrationsModelDiffer>();
var operations = modelDiffer.GetDifferences(sourceModel, targetModel);

Assert.Equal(0, operations.Count);
DiffSnapshot(new BloggingContextModelSnapshot22(), context);
}

public class BloggingContextModelSnapshot22 : ModelSnapshot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,6 @@ public NorthwindGroupByQueryNpgsqlTest(NorthwindQueryNpgsqlFixture<NoopModelCust
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}

// https://github.com/dotnet/efcore/pull/19855
public override Task GroupBy_scalar_aggregate_in_set_operation(bool async)
{
return AssertQuery(
async,
ss => ss.Set<Customer>()
.Where(c => c.CustomerID.StartsWith("F"))
.Select(c => new { c.CustomerID, Sequence = 0 })
.Union(ss.Set<Order>()
.GroupBy(o => o.CustomerID)
.Select(g => new
{
CustomerID = g.Key,
Sequence = 1
})),
elementSorter: e => e.CustomerID + "/" + e.Sequence);
}

public override Task GroupBy_Property_Select_Count_with_predicate(bool async)
=> Assert.ThrowsAsync<InvalidOperationException>(
() => base.GroupBy_Property_Select_Count_with_predicate(async));
Expand Down