Skip to content

Commit

Permalink
Fix HiLo for TPC (#28547)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers authored Jul 30, 2022
1 parent 1ff156c commit 183ed87
Show file tree
Hide file tree
Showing 9 changed files with 707 additions and 671 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected override void ValidateValueGeneration(
{
foreach (var storeGeneratedProperty in key.Properties.Where(
p => (p.ValueGenerated & ValueGenerated.OnAdd) != 0
&& p.GetValueGenerationStrategy() != SqlServerValueGenerationStrategy.Sequence))
&& p.GetValueGenerationStrategy() == SqlServerValueGenerationStrategy.IdentityColumn))
{
logger.TpcStoreGeneratedIdentityWarning(storeGeneratedProperty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public virtual SqlServerSequenceValueGeneratorState GetOrAddSequenceState(
IProperty property,
IRelationalConnection connection)
{
var sequence = property.FindHiLoSequence(
StoreObjectIdentifier.Create(property.DeclaringEntityType, StoreObjectType.Table)!.Value);
var tableIdentifier = StoreObjectIdentifier.Create(property.DeclaringEntityType, StoreObjectType.Table);
var sequence = tableIdentifier != null
? property.FindHiLoSequence(tableIdentifier.Value)
: property.FindHiLoSequence();

Check.DebugAssert(sequence != null, "sequence is null");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.Query;
public abstract class TPCInheritanceQueryTestBase<TFixture> : InheritanceQueryTestBase<TFixture>
where TFixture : TPCInheritanceQueryFixture, new()
{
public TPCInheritanceQueryTestBase(TFixture fixture)
protected TPCInheritanceQueryTestBase(TFixture fixture)
: base(fixture)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.Query;

public class TPCInheritanceQueryHiLoSqlServerFixture : TPCInheritanceQuerySqlServerFixtureBase
{
protected override string StoreName
=> "TPCHiLoInheritanceTest";

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

base.OnModelCreating(modelBuilder, context);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.Query;

public class TPCInheritanceQueryHiLoSqlServerTest : TPCInheritanceQuerySqlServerTestBase<TPCInheritanceQueryHiLoSqlServerFixture>
{
public TPCInheritanceQueryHiLoSqlServerTest(TPCInheritanceQueryHiLoSqlServerFixture fixture)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.Clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace Microsoft.EntityFrameworkCore.Query;

public class TPCInheritanceQuerySqlServerFixture : TPCInheritanceQueryFixture
public class TPCInheritanceQuerySqlServerFixture : TPCInheritanceQuerySqlServerFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
=> SqlServerTestStoreFactory.Instance;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.EntityFrameworkCore.Query;

public abstract class TPCInheritanceQuerySqlServerFixtureBase : TPCInheritanceQueryFixture
{
protected override ITestStoreFactory TestStoreFactory
=> SqlServerTestStoreFactory.Instance;
}
Loading

0 comments on commit 183ed87

Please sign in to comment.