Skip to content

Commit b64c1d5

Browse files
authored
Sync to EF RC1 (#264)
1 parent 42d6065 commit b64c1d5

25 files changed

Lines changed: 1202 additions & 723 deletions

Dependencies.targets

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
3-
<DotNetVersion>[9.0.0-preview.7.24405.4,9.0.999]</DotNetVersion>
4-
<EFCoreVersion>[9.0.0-preview.7.24405.3,9.0.999]</EFCoreVersion>
5-
<MSLibVersion>[9.0.0-preview.7.24405.7,9.0.999]</MSLibVersion>
3+
<DotNetVersion>[9.0.100-rc.1.24452.12,9.0.999]</DotNetVersion>
4+
<EFCoreVersion>[9.0.0-rc.1.24451.1,9.0.999]</EFCoreVersion>
5+
<MSLibVersion>[9.0.0-rc.1.24431.7,9.0.999]</MSLibVersion>
66
</PropertyGroup>
77

88
<ItemGroup>
@@ -28,9 +28,9 @@
2828
<PackageReference Update="Microsoft.EntityFrameworkCore.Design" Version="$(EFCoreVersion)" />
2929
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="$(EFCoreVersion)" /> <!-- Should be same as efcoreversion. preview6 was broken and published separately -->
3030
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="$(MSLibVersion)" />
31-
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.11.0-release-24373-02" />
32-
<PackageReference Update="MSTest.TestAdapter" Version="3.5.2" />
33-
<PackageReference Update="MSTest.TestFramework" Version="3.5.2" />
31+
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.11.1" />
32+
<PackageReference Update="MSTest.TestAdapter" Version="3.6.0" />
33+
<PackageReference Update="MSTest.TestFramework" Version="3.6.0" />
3434
<PackageReference Update="coverlet.collector" Version="6.0.2" />
3535
<PackageReference Update="Newtonsoft.Json" Version="13.0.3" />
3636

@@ -45,6 +45,6 @@
4545

4646
<!-- EFCore.Jet.Tests -->
4747
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="$(MSLibVersion)" />
48-
<PackageReference Update="Moq" Version="4.20.70" />
48+
<PackageReference Update="Moq" Version="4.20.72" />
4949
</ItemGroup>
5050
</Project>

global.json

Lines changed: 1 addition & 1 deletion
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.24452.12",
44
"allowPrerelease": true,
55
"rollForward": "latestFeature"
66
}

src/EFCore.Jet/Migrations/Internal/JetHistoryRepository.cs

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public override string GetDeleteScript(string migrationId)
128128
.ToString();
129129
}
130130

131-
public override IDisposable GetDatabaseLock(TimeSpan timeout)
131+
public override IDisposable GetDatabaseLock()
132132
{
133133
if (!InterpretExistsResult(Dependencies.RawSqlCommandBuilder.Build(CreateExistsSql(LockTableName))
134134
.ExecuteScalar(CreateRelationalCommandParameters())))
@@ -144,8 +144,7 @@ public override IDisposable GetDatabaseLock(TimeSpan timeout)
144144
}
145145

146146
var retryDelay = _retryDelay;
147-
var startTime = DateTimeOffset.UtcNow;
148-
while (DateTimeOffset.UtcNow - startTime < timeout)
147+
while (true)
149148
{
150149
var dbLock = CreateMigrationDatabaseLock();
151150
int? insertCount = 0;
@@ -164,17 +163,6 @@ public override IDisposable GetDatabaseLock(TimeSpan timeout)
164163
return dbLock;
165164
}
166165

167-
using var reader = CreateGetLockCommand().ExecuteReader(CreateRelationalCommandParameters());
168-
if (reader.Read())
169-
{
170-
var timestamp = reader.DbDataReader.GetFieldValue<DateTimeOffset>(1);
171-
if (DateTimeOffset.UtcNow - timestamp > timeout)
172-
{
173-
var id = reader.DbDataReader.GetFieldValue<int>(0);
174-
CreateDeleteLockCommand(id).ExecuteNonQuery(CreateRelationalCommandParameters());
175-
}
176-
}
177-
178166
Thread.Sleep(retryDelay);
179167
if (retryDelay < TimeSpan.FromMinutes(1))
180168
{
@@ -185,7 +173,7 @@ public override IDisposable GetDatabaseLock(TimeSpan timeout)
185173
throw new TimeoutException();
186174
}
187175

188-
public override async Task<IAsyncDisposable> GetDatabaseLockAsync(TimeSpan timeout, CancellationToken cancellationToken = new CancellationToken())
176+
public override async Task<IAsyncDisposable> GetDatabaseLockAsync(CancellationToken cancellationToken = new CancellationToken())
189177
{
190178
if (!InterpretExistsResult(await Dependencies.RawSqlCommandBuilder.Build(CreateExistsSql(LockTableName))
191179
.ExecuteScalarAsync(CreateRelationalCommandParameters(), cancellationToken).ConfigureAwait(false)))
@@ -204,8 +192,7 @@ await CreateLockTableCommand()
204192
}
205193

206194
var retryDelay = _retryDelay;
207-
var startTime = DateTimeOffset.UtcNow;
208-
while (DateTimeOffset.UtcNow - startTime < timeout)
195+
while (true)
209196
{
210197
var dbLock = CreateMigrationDatabaseLock();
211198
int? insertCount = 0;
@@ -225,19 +212,6 @@ await CreateLockTableCommand()
225212
return dbLock;
226213
}
227214

228-
using var reader = await CreateGetLockCommand().ExecuteReaderAsync(CreateRelationalCommandParameters(), cancellationToken)
229-
.ConfigureAwait(false);
230-
if (await reader.ReadAsync(cancellationToken).ConfigureAwait(false))
231-
{
232-
var timestamp = await reader.DbDataReader.GetFieldValueAsync<DateTimeOffset>(1).ConfigureAwait(false);
233-
if (DateTimeOffset.UtcNow - timestamp > timeout)
234-
{
235-
var id = await reader.DbDataReader.GetFieldValueAsync<int>(0).ConfigureAwait(false);
236-
await CreateDeleteLockCommand(id).ExecuteNonQueryAsync(CreateRelationalCommandParameters(), cancellationToken)
237-
.ConfigureAwait(false);
238-
}
239-
}
240-
241215
await Task.Delay(_retryDelay, cancellationToken).ConfigureAwait(true);
242216
if (retryDelay < TimeSpan.FromMinutes(1))
243217
{
@@ -266,11 +240,6 @@ private IRelationalCommand CreateInsertLockCommand(DateTimeOffset timestamp)
266240
""");
267241
}
268242

269-
private IRelationalCommand CreateGetLockCommand()
270-
=> Dependencies.RawSqlCommandBuilder.Build($"""
271-
SELECT TOP 1 `Id`, `Timestamp` FROM `{LockTableName}`;
272-
""");
273-
274243
private IRelationalCommand CreateDeleteLockCommand(int? id = null)
275244
{
276245
var sql = $"""

src/EFCore.Jet/Query/Internal/JetLocateScalarSubqueryVisitor.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,22 @@ protected override Expression VisitJsonScalar(JsonScalarExpression jsonScalarExp
403403

404404
protected override Expression VisitValues(ValuesExpression valuesExpression)
405405
{
406-
var rowValues = new RowValueExpression[valuesExpression.RowValues.Count];
407-
for (var i = 0; i < rowValues.Length; i++)
406+
switch (valuesExpression)
408407
{
409-
rowValues[i] = (RowValueExpression)Visit(valuesExpression.RowValues[i]);
408+
case { RowValues: not null }:
409+
var rowValues = new RowValueExpression[valuesExpression.RowValues!.Count];
410+
for (var i = 0; i < rowValues.Length; i++)
411+
{
412+
rowValues[i] = (RowValueExpression)Visit(valuesExpression.RowValues[i]);
413+
}
414+
return valuesExpression.Update(rowValues);
415+
416+
case { ValuesParameter: not null }:
417+
var valuesParameter = (SqlParameterExpression)Visit(valuesExpression.ValuesParameter);
418+
return valuesExpression.Update(valuesParameter);
419+
420+
default:
421+
throw new UnreachableException();
410422
}
411-
return valuesExpression.Update(rowValues);
412423
}
413424
}

src/EFCore.Jet/Query/Internal/JetParameterBasedSqlProcessor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class JetParameterBasedSqlProcessor : RelationalParameterBasedSqlProcesso
2424
/// </summary>
2525
public JetParameterBasedSqlProcessor(
2626
RelationalParameterBasedSqlProcessorDependencies dependencies,
27-
bool useRelationalNulls)
28-
: base(dependencies, useRelationalNulls)
27+
RelationalParameterBasedSqlProcessorParameters parameters)
28+
: base(dependencies, parameters)
2929
{
3030
}
3131

@@ -64,7 +64,7 @@ protected override Expression ProcessSqlNullability(
6464
Check.NotNull(selectExpression, nameof(selectExpression));
6565
Check.NotNull(parametersValues, nameof(parametersValues));
6666

67-
return new JetSqlNullabilityProcessor(Dependencies, UseRelationalNulls).Process(
67+
return new JetSqlNullabilityProcessor(Dependencies, Parameters).Process(
6868
selectExpression, parametersValues, out canCache);
6969
}
7070
}

src/EFCore.Jet/Query/Internal/JetParameterBasedSqlProcessorFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public JetParameterBasedSqlProcessorFactory(RelationalParameterBasedSqlProcessor
3535
/// any release. You should only use it directly in your code with extreme caution and knowing that
3636
/// doing so can result in application failures when updating to a new Entity Framework Core release.
3737
/// </summary>
38-
public virtual RelationalParameterBasedSqlProcessor Create(bool useRelationalNulls)
39-
=> new JetParameterBasedSqlProcessor(Dependencies, useRelationalNulls);
38+
public RelationalParameterBasedSqlProcessor Create(RelationalParameterBasedSqlProcessorParameters parameters)
39+
=> new JetParameterBasedSqlProcessor(Dependencies, parameters);
4040
}

src/EFCore.Jet/Query/Internal/JetSqlNullabilityProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public class JetSqlNullabilityProcessor : SqlNullabilityProcessor
2222
/// </summary>
2323
public JetSqlNullabilityProcessor(
2424
RelationalParameterBasedSqlProcessorDependencies dependencies,
25-
bool useRelationalNulls)
26-
: base(dependencies, useRelationalNulls)
25+
RelationalParameterBasedSqlProcessorParameters parameters)
26+
: base(dependencies, parameters)
2727
{
2828
}
2929

src/EFCore.Jet/Query/Internal/SearchConditionConvertingExpressionVisitor.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22
using System;
33
using System.Collections.Generic;
4+
using System.Diagnostics;
45
using System.Linq.Expressions;
56
using EntityFrameworkCore.Jet.Utilities;
67
using Microsoft.EntityFrameworkCore.Diagnostics;
@@ -648,14 +649,24 @@ protected override Expression VisitValues(ValuesExpression valuesExpression)
648649
{
649650
var parentSearchCondition = _isSearchCondition;
650651
_isSearchCondition = false;
651-
652-
var rowValues = new RowValueExpression[valuesExpression.RowValues.Count];
653-
for (var i = 0; i < rowValues.Length; i++)
652+
switch (valuesExpression)
654653
{
655-
rowValues[i] = (RowValueExpression)Visit(valuesExpression.RowValues[i]);
656-
}
654+
case { RowValues: not null }:
655+
var rowValues = new RowValueExpression[valuesExpression.RowValues!.Count];
656+
for (var i = 0; i < rowValues.Length; i++)
657+
{
658+
rowValues[i] = (RowValueExpression)Visit(valuesExpression.RowValues[i]);
659+
}
660+
_isSearchCondition = parentSearchCondition;
661+
return valuesExpression.Update(rowValues);
657662

658-
_isSearchCondition = parentSearchCondition;
659-
return valuesExpression.Update(rowValues);
663+
case { ValuesParameter: not null }:
664+
var valuesParameter = (SqlParameterExpression)Visit(valuesExpression.ValuesParameter);
665+
_isSearchCondition = parentSearchCondition;
666+
return valuesExpression.Update(valuesParameter);
667+
668+
default:
669+
throw new UnreachableException();
670+
}
660671
}
661672
}

src/EFCore.Jet/Query/Sql/Internal/JetQuerySqlGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ protected override Expression VisitValues(ValuesExpression valuesExpression)
816816
/// </summary>
817817
protected override void GenerateValues(ValuesExpression valuesExpression)
818818
{
819-
if (valuesExpression.RowValues.Count == 0)
819+
if (valuesExpression.RowValues is null || valuesExpression.RowValues.Count == 0)
820820
{
821821
throw new InvalidOperationException(RelationalStrings.EmptyCollectionNotSupportedAsInlineQueryRoot);
822822
}

0 commit comments

Comments
 (0)