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

Make sure non-shared-type entity types aren't discovered while a shared-type entity type is being added #22413

Merged
merged 1 commit into from
Sep 5, 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
1 change: 1 addition & 0 deletions src/EFCore/Metadata/Internal/InternalModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private InternalEntityTypeBuilder Entity(
return null;
}

using var batch = Metadata.ConventionDispatcher.DelayConventions();
var clrType = type.Type;
EntityType entityType;
if (type.IsNamed)
Expand Down
10 changes: 5 additions & 5 deletions test/EFCore.Specification.Tests/ManyToManyTrackingTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,7 @@ static void ValidateFixup(
}
}

[ConditionalFact(Skip = "Issue #22406")]
[ConditionalFact]
public virtual void Can_insert_many_to_many_shared_with_payload()
{
ExecuteWithStrategyInTransaction(
Expand Down Expand Up @@ -1920,7 +1920,7 @@ void ValidateFixup(DbContext context, IList<EntityOne> leftEntities, IList<Entit
}
}

[ConditionalFact(Skip = "Issue #22406")]
[ConditionalFact]
public virtual void Can_update_many_to_many_shared_with_payload()
{
ExecuteWithStrategyInTransaction(
Expand Down Expand Up @@ -2990,8 +2990,8 @@ public virtual void Can_load_entities_in_any_order(int[] order)
Assert.Equal(112, (joinCount / 2) + deleted);
}

[ConditionalFact(Skip = "Issue #22406")]
public void Can_insert_update_delete_shared_type_entity_type()
[ConditionalFact]
public virtual void Can_insert_update_delete_shared_type_entity_type()
{
ExecuteWithStrategyInTransaction(
context =>
Expand Down Expand Up @@ -3038,7 +3038,7 @@ public void Can_insert_update_delete_shared_type_entity_type()
}

[ConditionalFact]
public void Can_insert_update_delete_proxyable_shared_type_entity_type()
public virtual void Can_insert_update_delete_proxyable_shared_type_entity_type()
{
ExecuteWithStrategyInTransaction(
context =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
.UsingEntity<Dictionary<string, object>>(
"JoinOneToThreePayloadFullShared",
r => r.HasOne<EntityThree>().WithMany(e => e.JoinOnePayloadFullShared).HasForeignKey("ThreeId"),
l => l.HasOne<EntityOne>().WithMany(e => e.JoinThreePayloadFullShared).HasForeignKey("OneId"));
// Disabled - see #22406
//.IndexerProperty<string>("Payload");
l => l.HasOne<EntityOne>().WithMany(e => e.JoinThreePayloadFullShared).HasForeignKey("OneId"))
.IndexerProperty<string>("Payload");

// Nav:6 Payload:Yes Join:Concrete Extra:Self-Ref
modelBuilder.Entity<EntityOne>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
.Property(e => e.Payload)
.HasDefaultValueSql("GETUTCDATE()");

// Disabled - see #22406
// modelBuilder
// .SharedTypeEntity<Dictionary<string, object>>("JoinOneToThreePayloadFullShared")
// .IndexerProperty<string>("Payload")
// .HasDefaultValue("Generated");
modelBuilder
.SharedTypeEntity<Dictionary<string, object>>("JoinOneToThreePayloadFullShared")
.IndexerProperty<string>("Payload")
.HasDefaultValue("Generated");

modelBuilder
.Entity<JoinOneToThreePayloadFull>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.EntityFrameworkCore
Expand All @@ -13,6 +14,21 @@ public ManyToManyTrackingProxySqlServerTest(ManyToManyTrackingProxySqlServerFixt
{
}

public override void Can_insert_many_to_many_shared_with_payload()
{
// Mutable properties aren't proxyable on Dictionary
}

public override void Can_update_many_to_many_shared_with_payload()
{
// Mutable properties aren't proxyable on Dictionary
}

public override void Can_insert_update_delete_shared_type_entity_type()
{
// Mutable properties aren't proxyable on Dictionary
}

protected override bool RequiresDetectChanges
=> false;

Expand All @@ -25,6 +41,15 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build

protected override IServiceCollection AddServices(IServiceCollection serviceCollection)
=> base.AddServices(serviceCollection.AddEntityFrameworkProxies());

protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
{
base.OnModelCreating(modelBuilder, context);

modelBuilder
.SharedTypeEntity<Dictionary<string, object>>("JoinOneToThreePayloadFullShared")
.Ignore("Payload"); // Mutable properties aren't proxyable on Dictionary
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con
.Property(e => e.Payload)
.HasDefaultValueSql("GETUTCDATE()");

// Disabled - see #22406
// modelBuilder
// .SharedTypeEntity<Dictionary<string, object>>("JoinOneToThreePayloadFullShared")
// .IndexerProperty<string>("Payload")
// .HasDefaultValue("Generated");
modelBuilder
.SharedTypeEntity<Dictionary<string, object>>("JoinOneToThreePayloadFullShared")
.IndexerProperty<string>("Payload")
.HasDefaultValue("Generated");

modelBuilder
.Entity<JoinOneToThreePayloadFull>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,17 +659,16 @@ public override async Task Filtered_include_skip_navigation_where(bool async)
{
await base.Filtered_include_skip_navigation_where(async);

// Payload has been removed -- see #22406
// AssertSql(
// @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t].[OneId], [t].[ThreeId], [t].[Payload], [t].[Id], [t].[Name]
// FROM [EntityThrees] AS [e]
// LEFT JOIN (
// SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e0].[Id], [e0].[Name]
// FROM [JoinOneToThreePayloadFullShared] AS [j]
// INNER JOIN [EntityOnes] AS [e0] ON [j].[OneId] = [e0].[Id]
// WHERE [e0].[Id] < 10
// ) AS [t] ON [e].[Id] = [t].[ThreeId]
// ORDER BY [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id]");
AssertSql(
@"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId], [t].[OneId], [t].[ThreeId], [t].[Payload], [t].[Id], [t].[Name]
FROM [EntityThrees] AS [e]
LEFT JOIN (
SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e0].[Id], [e0].[Name]
FROM [JoinOneToThreePayloadFullShared] AS [j]
INNER JOIN [EntityOnes] AS [e0] ON [j].[OneId] = [e0].[Id]
WHERE [e0].[Id] < 10
) AS [t] ON [e].[Id] = [t].[ThreeId]
ORDER BY [e].[Id], [t].[OneId], [t].[ThreeId], [t].[Id]");
}

public override async Task Filtered_include_skip_navigation_order_by(bool async)
Expand Down Expand Up @@ -748,22 +747,21 @@ public override async Task Filtered_then_include_skip_navigation_where(bool asyn
{
await base.Filtered_then_include_skip_navigation_where(async);

// Payload has been removed -- see #22406
// AssertSql(
// @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[Number], [e].[IsGreen], [t0].[EntityRootId], [t0].[EntityThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[OneId], [t0].[ThreeId], [t0].[Payload], [t0].[Id0], [t0].[Name0]
// FROM [EntityRoots] AS [e]
// LEFT JOIN (
// SELECT [e0].[EntityRootId], [e0].[EntityThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [t].[OneId], [t].[ThreeId], [t].[Payload], [t].[Id] AS [Id0], [t].[Name] AS [Name0]
// FROM [EntityRootEntityThree] AS [e0]
// INNER JOIN [EntityThrees] AS [e1] ON [e0].[EntityThreeId] = [e1].[Id]
// LEFT JOIN (
// SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e2].[Id], [e2].[Name]
// FROM [JoinOneToThreePayloadFullShared] AS [j]
// INNER JOIN [EntityOnes] AS [e2] ON [j].[OneId] = [e2].[Id]
// WHERE [e2].[Id] < 10
// ) AS [t] ON [e1].[Id] = [t].[ThreeId]
// ) AS [t0] ON [e].[Id] = [t0].[EntityRootId]
// ORDER BY [e].[Id], [t0].[EntityRootId], [t0].[EntityThreeId], [t0].[Id], [t0].[OneId], [t0].[ThreeId], [t0].[Id0]");
AssertSql(
@"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[Number], [e].[IsGreen], [t0].[EntityRootId], [t0].[EntityThreeId], [t0].[Id], [t0].[CollectionInverseId], [t0].[Name], [t0].[ReferenceInverseId], [t0].[OneId], [t0].[ThreeId], [t0].[Payload], [t0].[Id0], [t0].[Name0]
FROM [EntityRoots] AS [e]
LEFT JOIN (
SELECT [e0].[EntityRootId], [e0].[EntityThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId], [t].[OneId], [t].[ThreeId], [t].[Payload], [t].[Id] AS [Id0], [t].[Name] AS [Name0]
FROM [EntityRootEntityThree] AS [e0]
INNER JOIN [EntityThrees] AS [e1] ON [e0].[EntityThreeId] = [e1].[Id]
LEFT JOIN (
SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e2].[Id], [e2].[Name]
FROM [JoinOneToThreePayloadFullShared] AS [j]
INNER JOIN [EntityOnes] AS [e2] ON [j].[OneId] = [e2].[Id]
WHERE [e2].[Id] < 10
) AS [t] ON [e1].[Id] = [t].[ThreeId]
) AS [t0] ON [e].[Id] = [t0].[EntityRootId]
ORDER BY [e].[Id], [t0].[EntityRootId], [t0].[EntityThreeId], [t0].[Id], [t0].[OneId], [t0].[ThreeId], [t0].[Id0]");
}

public override async Task Filtered_then_include_skip_navigation_order_by_skip_take(bool async)
Expand Down Expand Up @@ -1113,21 +1111,20 @@ public override async Task Filtered_include_skip_navigation_where_split(bool asy
{
await base.Filtered_include_skip_navigation_where_split(async);

// Payload has been removed -- see #22406
// AssertSql(
// @"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId]
// FROM [EntityThrees] AS [e]
// ORDER BY [e].[Id]",
// //
// @"SELECT [t].[OneId], [t].[ThreeId], [t].[Payload], [t].[Id], [t].[Name], [e].[Id]
// FROM [EntityThrees] AS [e]
// INNER JOIN (
// SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e0].[Id], [e0].[Name]
// FROM [JoinOneToThreePayloadFullShared] AS [j]
// INNER JOIN [EntityOnes] AS [e0] ON [j].[OneId] = [e0].[Id]
// WHERE [e0].[Id] < 10
// ) AS [t] ON [e].[Id] = [t].[ThreeId]
// ORDER BY [e].[Id]");
AssertSql(
@"SELECT [e].[Id], [e].[CollectionInverseId], [e].[Name], [e].[ReferenceInverseId]
FROM [EntityThrees] AS [e]
ORDER BY [e].[Id]",
//
@"SELECT [t].[OneId], [t].[ThreeId], [t].[Payload], [t].[Id], [t].[Name], [e].[Id]
FROM [EntityThrees] AS [e]
INNER JOIN (
SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e0].[Id], [e0].[Name]
FROM [JoinOneToThreePayloadFullShared] AS [j]
INNER JOIN [EntityOnes] AS [e0] ON [j].[OneId] = [e0].[Id]
WHERE [e0].[Id] < 10
) AS [t] ON [e].[Id] = [t].[ThreeId]
ORDER BY [e].[Id]");
}

public override async Task Filtered_include_skip_navigation_order_by_split(bool async)
Expand Down Expand Up @@ -1226,35 +1223,34 @@ public override async Task Filtered_then_include_skip_navigation_where_split(boo
{
await base.Filtered_then_include_skip_navigation_where_split(async);

// Payload has been removed -- see #22406
// AssertSql(
// @"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[Number], [e].[IsGreen]
// FROM [EntityRoots] AS [e]
// ORDER BY [e].[Id]",
// //
// @"SELECT [t].[EntityRootId], [t].[EntityThreeId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [e].[Id]
// FROM [EntityRoots] AS [e]
// INNER JOIN (
// SELECT [e0].[EntityRootId], [e0].[EntityThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId]
// FROM [EntityRootEntityThree] AS [e0]
// INNER JOIN [EntityThrees] AS [e1] ON [e0].[EntityThreeId] = [e1].[Id]
// ) AS [t] ON [e].[Id] = [t].[EntityRootId]
// ORDER BY [e].[Id], [t].[EntityRootId], [t].[EntityThreeId], [t].[Id]",
// //
// @"SELECT [t0].[OneId], [t0].[ThreeId], [t0].[Payload], [t0].[Id], [t0].[Name], [e].[Id], [t].[EntityRootId], [t].[EntityThreeId], [t].[Id]
// FROM [EntityRoots] AS [e]
// INNER JOIN (
// SELECT [e0].[EntityRootId], [e0].[EntityThreeId], [e1].[Id]
// FROM [EntityRootEntityThree] AS [e0]
// INNER JOIN [EntityThrees] AS [e1] ON [e0].[EntityThreeId] = [e1].[Id]
// ) AS [t] ON [e].[Id] = [t].[EntityRootId]
// INNER JOIN (
// SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e2].[Id], [e2].[Name]
// FROM [JoinOneToThreePayloadFullShared] AS [j]
// INNER JOIN [EntityOnes] AS [e2] ON [j].[OneId] = [e2].[Id]
// WHERE [e2].[Id] < 10
// ) AS [t0] ON [t].[Id] = [t0].[ThreeId]
// ORDER BY [e].[Id], [t].[EntityRootId], [t].[EntityThreeId], [t].[Id]");
AssertSql(
@"SELECT [e].[Id], [e].[Discriminator], [e].[Name], [e].[Number], [e].[IsGreen]
FROM [EntityRoots] AS [e]
ORDER BY [e].[Id]",
//
@"SELECT [t].[EntityRootId], [t].[EntityThreeId], [t].[Id], [t].[CollectionInverseId], [t].[Name], [t].[ReferenceInverseId], [e].[Id]
FROM [EntityRoots] AS [e]
INNER JOIN (
SELECT [e0].[EntityRootId], [e0].[EntityThreeId], [e1].[Id], [e1].[CollectionInverseId], [e1].[Name], [e1].[ReferenceInverseId]
FROM [EntityRootEntityThree] AS [e0]
INNER JOIN [EntityThrees] AS [e1] ON [e0].[EntityThreeId] = [e1].[Id]
) AS [t] ON [e].[Id] = [t].[EntityRootId]
ORDER BY [e].[Id], [t].[EntityRootId], [t].[EntityThreeId], [t].[Id]",
//
@"SELECT [t0].[OneId], [t0].[ThreeId], [t0].[Payload], [t0].[Id], [t0].[Name], [e].[Id], [t].[EntityRootId], [t].[EntityThreeId], [t].[Id]
FROM [EntityRoots] AS [e]
INNER JOIN (
SELECT [e0].[EntityRootId], [e0].[EntityThreeId], [e1].[Id]
FROM [EntityRootEntityThree] AS [e0]
INNER JOIN [EntityThrees] AS [e1] ON [e0].[EntityThreeId] = [e1].[Id]
) AS [t] ON [e].[Id] = [t].[EntityRootId]
INNER JOIN (
SELECT [j].[OneId], [j].[ThreeId], [j].[Payload], [e2].[Id], [e2].[Name]
FROM [JoinOneToThreePayloadFullShared] AS [j]
INNER JOIN [EntityOnes] AS [e2] ON [j].[OneId] = [e2].[Id]
WHERE [e2].[Id] < 10
) AS [t0] ON [t].[Id] = [t0].[ThreeId]
ORDER BY [e].[Id], [t].[EntityRootId], [t].[EntityThreeId], [t].[Id]");
}

public override async Task Filtered_then_include_skip_navigation_order_by_skip_take_split(bool async)
Expand Down
Loading