Skip to content

Commit 1a95104

Browse files
authored
Sync to EF Core 9.0.0-rc.1.24451.1 (#3260)
1 parent 318c46c commit 1a95104

21 files changed

+247
-122
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
pull_request:
1212

1313
env:
14-
dotnet_sdk_version: '9.0.100-preview.7.24407.12'
14+
dotnet_sdk_version: '9.0.100-rc.1.24451.4'
1515
postgis_version: 3
1616
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
1717

.github/workflows/codeql-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
- cron: '30 22 * * 6'
2828

2929
env:
30-
dotnet_sdk_version: '9.0.100-preview.7.24407.12'
30+
dotnet_sdk_version: '9.0.100-rc.1.24451.4'
3131

3232
jobs:
3333
analyze:

Directory.Packages.props

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
3-
<EFCoreVersion>[9.0.0-preview.7.24405.3]</EFCoreVersion>
4-
<MicrosoftExtensionsVersion>9.0.0-preview.7.24405.7</MicrosoftExtensionsVersion>
3+
<EFCoreVersion>[9.0.0-rc.1.24451.1]</EFCoreVersion>
4+
<MicrosoftExtensionsVersion>9.0.0-rc.1.24431.7</MicrosoftExtensionsVersion>
55
<NpgsqlVersion>8.0.3</NpgsqlVersion>
66
</PropertyGroup>
77

@@ -21,15 +21,16 @@
2121
<PackageVersion Include="Npgsql.NetTopologySuite" Version="$(NpgsqlVersion)" />
2222
<PackageVersion Include="Npgsql.DependencyInjection" Version="$(NpgsqlVersion)" />
2323

24-
<!-- Workaround for unsecure dependency on EF.Specification.Tests -->
24+
<!-- Workaround for unsecure dependencies in EF -->
2525
<PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
26+
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
2627

2728
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
2829
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
29-
<PackageVersion Include="xunit" Version="2.8.1" />
30-
<PackageVersion Include="xunit.assert" Version="2.8.1" />
31-
<PackageVersion Include="xunit.core" Version="2.8.1" />
32-
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1" />
30+
<PackageVersion Include="xunit" Version="2.9.0" />
31+
<PackageVersion Include="xunit.assert" Version="2.9.0" />
32+
<PackageVersion Include="xunit.core" Version="2.9.0" />
33+
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
3334
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
3435
</ItemGroup>
3536
</Project>

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "9.0.100-preview.7.24407.12",
3+
"version": "9.0.100-rc.1.24451.4",
44
"rollForward": "latestMajor",
55
"allowPrerelease": true
66
}

src/EFCore.PG/Migrations/Internal/NpgsqlHistoryRepository.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ await Dependencies.RawSqlCommandBuilder.Build(ExistsSql).ExecuteScalarAsync(
6363
/// any release. You should only use it directly in your code with extreme caution and knowing that
6464
/// doing so can result in application failures when updating to a new Entity Framework Core release.
6565
/// </summary>
66-
public override IDisposable GetDatabaseLock(TimeSpan timeout)
66+
public override IDisposable GetDatabaseLock()
6767
{
6868
// TODO: There are issues with the current lock implementation in EF - most importantly, the lock isn't acquired within a
6969
// transaction so we can't use e.g. LOCK TABLE. This should be fixed for rc.1, see #34439.
@@ -81,7 +81,7 @@ public override IDisposable GetDatabaseLock(TimeSpan timeout)
8181
/// any release. You should only use it directly in your code with extreme caution and knowing that
8282
/// doing so can result in application failures when updating to a new Entity Framework Core release.
8383
/// </summary>
84-
public override Task<IAsyncDisposable> GetDatabaseLockAsync(TimeSpan timeout, CancellationToken cancellationToken = default)
84+
public override Task<IAsyncDisposable> GetDatabaseLockAsync(CancellationToken cancellationToken = default)
8585
{
8686
// TODO: There are issues with the current lock implementation in EF - most importantly, the lock isn't acquired within a
8787
// transaction so we can't use e.g. LOCK TABLE. This should be fixed for rc.1, see #34439.

src/EFCore.PG/Migrations/Internal/NpgsqlMigrator.cs

+13-16
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ public NpgsqlMigrator(
3636
IModelRuntimeInitializer modelRuntimeInitializer,
3737
IDiagnosticsLogger<DbLoggerCategory.Migrations> logger,
3838
IRelationalCommandDiagnosticsLogger commandLogger,
39-
IDatabaseProvider databaseProvider)
39+
IDatabaseProvider databaseProvider,
40+
IMigrationsModelDiffer migrationsModelDiffer,
41+
IDesignTimeModel designTimeModel,
42+
IDbContextOptions contextOptions)
4043
: base(migrationsAssembly, historyRepository, databaseCreator, migrationsSqlGenerator, rawSqlCommandBuilder,
4144
migrationCommandExecutor, connection, sqlGenerationHelper, currentContext, modelRuntimeInitializer, logger,
42-
commandLogger, databaseProvider)
45+
commandLogger, databaseProvider, migrationsModelDiffer, designTimeModel, contextOptions)
4346
{
4447
_historyRepository = historyRepository;
4548
_connection = connection;
@@ -51,7 +54,7 @@ public NpgsqlMigrator(
5154
/// any release. You should only use it directly in your code with extreme caution and knowing that
5255
/// doing so can result in application failures when updating to a new Entity Framework Core release.
5356
/// </summary>
54-
public override void Migrate(string? targetMigration = null)
57+
public override void Migrate(string? targetMigration)
5558
{
5659
var appliedMigrations = _historyRepository.GetAppliedMigrations();
5760

@@ -60,17 +63,15 @@ public override void Migrate(string? targetMigration = null)
6063
PopulateMigrations(
6164
appliedMigrations.Select(t => t.MigrationId),
6265
targetMigration,
63-
out var migrationsToApply,
64-
out var migrationsToRevert,
65-
out _);
66+
out var migratorData);
6667

67-
if (migrationsToRevert.Count + migrationsToApply.Count == 0)
68+
if (migratorData.RevertedMigrations.Count + migratorData.AppliedMigrations.Count == 0)
6869
{
6970
return;
7071
}
7172

7273
// If a PostgreSQL extension, enum or range was added, we want Npgsql to reload all types at the ADO.NET level.
73-
var migrations = migrationsToApply.Count > 0 ? migrationsToApply : migrationsToRevert;
74+
var migrations = migratorData.AppliedMigrations.Count > 0 ? migratorData.AppliedMigrations : migratorData.RevertedMigrations;
7475
var reloadTypes = migrations
7576
.SelectMany(m => m.UpOperations)
7677
.OfType<AlterDatabaseOperation>()
@@ -96,9 +97,7 @@ public override void Migrate(string? targetMigration = null)
9697
/// any release. You should only use it directly in your code with extreme caution and knowing that
9798
/// doing so can result in application failures when updating to a new Entity Framework Core release.
9899
/// </summary>
99-
public override async Task MigrateAsync(
100-
string? targetMigration = null,
101-
CancellationToken cancellationToken = default)
100+
public override async Task MigrateAsync(string? targetMigration, CancellationToken cancellationToken = default)
102101
{
103102
var appliedMigrations = await _historyRepository.GetAppliedMigrationsAsync(cancellationToken).ConfigureAwait(false);
104103

@@ -107,17 +106,15 @@ public override async Task MigrateAsync(
107106
PopulateMigrations(
108107
appliedMigrations.Select(t => t.MigrationId),
109108
targetMigration,
110-
out var migrationsToApply,
111-
out var migrationsToRevert,
112-
out _);
109+
out var migratorData);
113110

114-
if (migrationsToRevert.Count + migrationsToApply.Count == 0)
111+
if (migratorData.RevertedMigrations.Count + migratorData.AppliedMigrations.Count == 0)
115112
{
116113
return;
117114
}
118115

119116
// If a PostgreSQL extension, enum or range was added, we want Npgsql to reload all types at the ADO.NET level.
120-
var migrations = migrationsToApply.Count > 0 ? migrationsToApply : migrationsToRevert;
117+
var migrations = migratorData.AppliedMigrations.Count > 0 ? migratorData.AppliedMigrations : migratorData.RevertedMigrations;
121118
var reloadTypes = migrations
122119
.SelectMany(m => m.UpOperations)
123120
.OfType<AlterDatabaseOperation>()

src/EFCore.PG/Query/Internal/NpgsqlParameterBasedSqlProcessor.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class NpgsqlParameterBasedSqlProcessor : RelationalParameterBasedSqlProce
1616
/// </summary>
1717
public NpgsqlParameterBasedSqlProcessor(
1818
RelationalParameterBasedSqlProcessorDependencies dependencies,
19-
bool useRelationalNulls)
20-
: base(dependencies, useRelationalNulls)
19+
RelationalParameterBasedSqlProcessorParameters parameters)
20+
: base(dependencies, parameters)
2121
{
2222
}
2323

@@ -48,7 +48,7 @@ protected override Expression ProcessSqlNullability(
4848
Check.NotNull(selectExpression, nameof(selectExpression));
4949
Check.NotNull(parametersValues, nameof(parametersValues));
5050

51-
return new NpgsqlSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(
51+
return new NpgsqlSqlNullabilityProcessor(Dependencies, Parameters).Process(
5252
selectExpression, parametersValues, out canCache);
5353
}
5454
}

src/EFCore.PG/Query/Internal/NpgsqlParameterBasedSqlProcessorFactory.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ public NpgsqlParameterBasedSqlProcessorFactory(
2323
}
2424

2525
/// <summary>
26-
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
27-
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
28-
/// any release. You should only use it directly in your code with extreme caution and knowing that
29-
/// doing so can result in application failures when updating to a new Entity Framework Core release.
26+
/// Creates a new <see cref="RelationalParameterBasedSqlProcessor" />.
3027
/// </summary>
31-
public virtual RelationalParameterBasedSqlProcessor Create(bool useRelationalNulls)
32-
=> new NpgsqlParameterBasedSqlProcessor(_dependencies, useRelationalNulls);
28+
/// <param name="parameters">Parameters for <see cref="RelationalParameterBasedSqlProcessor" />.</param>
29+
/// <returns>A relational parameter based sql processor.</returns>
30+
public RelationalParameterBasedSqlProcessor Create(RelationalParameterBasedSqlProcessorParameters parameters)
31+
=> new NpgsqlParameterBasedSqlProcessor(_dependencies, parameters);
3332
}

src/EFCore.PG/Query/Internal/NpgsqlQuerySqlGenerator.cs

+5
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,11 @@ protected override Expression VisitValues(ValuesExpression valuesExpression)
767767
/// </summary>
768768
protected override void GenerateValues(ValuesExpression valuesExpression)
769769
{
770+
if (valuesExpression.RowValues is null)
771+
{
772+
throw new UnreachableException();
773+
}
774+
770775
if (valuesExpression.RowValues.Count == 0)
771776
{
772777
throw new InvalidOperationException(RelationalStrings.EmptyCollectionNotSupportedAsInlineQueryRoot);

src/EFCore.PG/Query/Internal/NpgsqlSqlNullabilityProcessor.cs

+8-7
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ public class NpgsqlSqlNullabilityProcessor : SqlNullabilityProcessor
1111
private readonly ISqlExpressionFactory _sqlExpressionFactory;
1212

1313
/// <summary>
14-
/// Creates a new instance of the <see cref="NpgsqlSqlNullabilityProcessor" /> class.
14+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
15+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
16+
/// any release. You should only use it directly in your code with extreme caution and knowing that
17+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
1518
/// </summary>
16-
/// <param name="dependencies">Parameter object containing dependencies for this class.</param>
17-
/// <param name="useRelationalNulls">A bool value indicating whether relational null semantics are in use.</param>
1819
public NpgsqlSqlNullabilityProcessor(
1920
RelationalParameterBasedSqlProcessorDependencies dependencies,
20-
bool useRelationalNulls)
21-
: base(dependencies, useRelationalNulls)
21+
RelationalParameterBasedSqlProcessorParameters parameters)
22+
: base(dependencies, parameters)
2223
{
2324
_sqlExpressionFactory = dependencies.SqlExpressionFactory;
2425
}
@@ -101,7 +102,7 @@ SqlExpression VisitRowValueComparison(
101102
// visit that (that adds the compensation). We then chain all such expressions together with AND.
102103
var valueBinaryExpression = Visit(
103104
_sqlExpressionFactory.MakeBinary(
104-
operatorType, visitedLeftValue, visitedRightValue, typeMapping: null, existingExpr: sqlBinaryExpression)!,
105+
operatorType, visitedLeftValue, visitedRightValue, typeMapping: null, existingExpression: sqlBinaryExpression)!,
105106
allowOptimizedExpansion,
106107
out _);
107108

@@ -144,7 +145,7 @@ visitedRightValues is null
144145
? rightRowValue
145146
: new PgRowValueExpression(visitedRightValues, leftRowValue.Type, leftRowValue.TypeMapping),
146147
typeMapping: null,
147-
existingExpr: sqlBinaryExpression)!;
148+
existingExpression: sqlBinaryExpression)!;
148149
}
149150

150151
Check.DebugAssert(visitedLeftValues is not null, "visitedLeftValues is not null");

test/EFCore.PG.FunctionalTests/EFCore.PG.FunctionalTests.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
<!-- Workaround for unsecure dependency on EF.Specification.Tests -->
2323
<PackageReference Include="System.Formats.Asn1" />
24+
<PackageReference Include="System.Text.Json" />
2425

2526
<!-- Needed to override xunit dependencies from EFCore projects on versions which aren't available on nuget.org -->
2627
<PackageReference Include="xunit.assert" />

test/EFCore.PG.FunctionalTests/ExecutionStrategyTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private void Test_commit_failure(bool realFailure, Action<TestNpgsqlRetryingExec
9999
}
100100
else
101101
{
102-
Assert.Empty(Fixture.TestSqlLoggerFactory.Log.Where(l => l.Id == CoreEventId.ExecutionStrategyRetrying));
102+
Assert.DoesNotContain(Fixture.TestSqlLoggerFactory.Log, l => l.Id == CoreEventId.ExecutionStrategyRetrying);
103103
}
104104

105105
Assert.Equal(realFailure ? 3 : 2, connection.OpenCount);
@@ -213,7 +213,7 @@ private async Task Test_commit_failure_async(
213213
}
214214
else
215215
{
216-
Assert.Empty(Fixture.TestSqlLoggerFactory.Log.Where(l => l.Id == CoreEventId.ExecutionStrategyRetrying));
216+
Assert.DoesNotContain(Fixture.TestSqlLoggerFactory.Log, l => l.Id == CoreEventId.ExecutionStrategyRetrying);
217217
}
218218

219219
Assert.Equal(realFailure ? 3 : 2, connection.OpenCount);

0 commit comments

Comments
 (0)