Skip to content

Commit cf31b87

Browse files
ChrisJollyAUgithub-actions
andauthored
Prep for RTM (#290)
* Improve Substring/CharIndex translation in Jet provider Enhance Substring translation by coalescing function arguments to 0 for null safety. Remove redundant assignment in CharIndex translation for cleaner code. * Add DateTime to JetConvertTranslator supported types Added DateTime to the _supportedTypes list in JetConvertTranslator.cs, enabling conversion support for DateTime values in EntityFrameworkCore.Jet queries. * Ensure 'counter' columns are always non-nullable Updated DatabaseColumn creation logic to set IsNullable to false for columns with storeType "counter", regardless of the nullable flag. This ensures "counter" columns are consistently treated as non-nullable in the model. * Refactor FROM clause table handling and variable naming Refactored logic for counting non-cross join tables in FROM clause generation, improving readability and correctness. Renamed variables for clarity, removed unnecessary null-forgiving operators, and standardized use of var for consistency. * Fix Math/MathF translation and SGN function handling Update JetMathTranslator to distinguish between Math and MathF methods, using correct runtime methods and constant types for square root translations. Also, fix SQL function name check from "SIGN" to "SGN" for accurate SQL generation. * Update tests for Jet: deps, locale, SQL, and coverage - Bump Microsoft.Build.Tasks.Core to 18.4.0 and EFCore.* to 10.0.* - Add ModuleInitializer to enforce en-US culture for tests - Update test SQL assertions for new parameter naming (@p1, etc.) - Add/adjust tests for DefaultIfEmpty, Contains, and parameterized collections - Mark unsupported/unstable tests as skipped for Jet - Remove/comment out Jet-unsupported features (collation, idempotent migrations) - Treat NotSupportedException as a valid skip in test runner - Add scaffolding test for non-nullable identity columns - Clean up code and ensure all new/overridden tests assert expected Jet SQL * Update dependencies and set version to 10.0.5 RTM Raised minimum dependency versions to 10.0.5, updated Microsoft.SourceLink.GitHub and test packages, switched prerelease label to "rtm", and bumped .NET SDK to 10.0.201. * Update LINQ query and SQL assertion for parameter names Explicitly cast names to IEnumerable<string> in the query for compatibility. Update expected SQL to use @p1/@p2 parameter names and adjust formatting to match new output. * [GitHub Actions] Update green tests. --------- Co-authored-by: github-actions <github-actions@github.com>
1 parent f200f33 commit cf31b87

66 files changed

Lines changed: 948 additions & 627 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Dependencies.targets

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
3-
<DotNetVersion>[10.0.0,10.0.999]</DotNetVersion>
4-
<EFCoreVersion>[10.0.0,10.0.999]</EFCoreVersion>
5-
<MSLibVersion>[10.0.0,10.0.999]</MSLibVersion>
3+
<DotNetVersion>[10.0.5,10.0.999]</DotNetVersion>
4+
<EFCoreVersion>[10.0.5,10.0.999]</EFCoreVersion>
5+
<MSLibVersion>[10.0.5,10.0.999]</MSLibVersion>
66
</PropertyGroup>
77

88
<ItemGroup>
@@ -14,7 +14,7 @@
1414
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational" Version="$(EFCoreVersion)" />
1515
<PackageReference Update="System.Diagnostics.DiagnosticSource" Version="$(MSLibVersion)" />
1616
<PackageReference Update="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
17-
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
17+
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="10.0.201" />
1818

1919
<!-- EFCore.Jet -->
2020
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="$(MSLibVersion)" />
@@ -28,10 +28,10 @@
2828
<PackageReference Update="Microsoft.EntityFrameworkCore.Design" Version="$(EFCoreVersion)" />
2929
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="$(EFCoreVersion)" />
3030
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="$(MSLibVersion)" />
31-
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="18.0.1" />
32-
<PackageReference Update="MSTest.TestAdapter" Version="4.0.2" />
33-
<PackageReference Update="MSTest.TestFramework" Version="4.0.2" />
34-
<PackageReference Update="coverlet.collector" Version="6.0.4" />
31+
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="18.3.0" />
32+
<PackageReference Update="MSTest.TestAdapter" Version="4.1.0" />
33+
<PackageReference Update="MSTest.TestFramework" Version="4.1.0" />
34+
<PackageReference Update="coverlet.collector" Version="8.0.1" />
3535
<PackageReference Update="Newtonsoft.Json" Version="13.0.4" />
3636

3737
<!-- EFCore.Jet.FunctionalTests -->

Version.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
correctly.
1717
-->
1818
<VersionPrefix>10.0.0</VersionPrefix>
19-
<PreReleaseVersionLabel>beta</PreReleaseVersionLabel>
20-
<PreReleaseVersionIteration>1</PreReleaseVersionIteration>
19+
<PreReleaseVersionLabel>rtm</PreReleaseVersionLabel>
20+
<PreReleaseVersionIteration>0</PreReleaseVersionIteration>
2121

2222
<!--
2323
The following properties will automatically be set by CI builds when appropriate:

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": "10.0.100",
3+
"version": "10.0.201",
44
"allowPrerelease": true,
55
"rollForward": "latestFeature"
66
}

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetConvertTranslator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class JetConvertTranslator(ISqlExpressionFactory sqlExpressionFactory) :
3131
[
3232
typeof(bool),
3333
typeof(byte),
34+
typeof(DateTime),
3435
typeof(decimal),
3536
typeof(double),
3637
typeof(float),

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetMathTranslator.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class JetMathTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMe
115115
nullable: true,
116116
argumentsPropagateNullability: newArguments.Select(_ => true).ToArray(),
117117
method.ReturnType,
118-
sqlFunctionName == "SIGN" ? null : typeMapping);
118+
sqlFunctionName == "SGN" ? null : typeMapping);
119119
}
120120

121121
if (_supportedMethodTranslationsIndirect.Contains(method))
@@ -132,7 +132,9 @@ public class JetMathTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMe
132132
_sqlExpressionFactory.Negate(arguments[0]),
133133
Translate(
134134
null,
135-
typeof(Math).GetMethod(nameof(Math.Sqrt))!,
135+
method.DeclaringType == typeof(MathF)
136+
? typeof(MathF).GetRuntimeMethod(nameof(MathF.Sqrt), [typeof(float)])!
137+
: typeof(Math).GetRuntimeMethod(nameof(Math.Sqrt), [typeof(double)])!,
136138
[
137139
_sqlExpressionFactory.Add(
138140
_sqlExpressionFactory.Negate(
@@ -141,7 +143,7 @@ public class JetMathTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMe
141143
arguments[0]
142144
)
143145
),
144-
_sqlExpressionFactory.Constant(1d)
146+
_sqlExpressionFactory.Constant(method.DeclaringType == typeof(MathF) ? 1f : 1d)
145147
)
146148
],
147149
logger
@@ -160,7 +162,9 @@ public class JetMathTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMe
160162
arguments[0],
161163
Translate(
162164
null,
163-
typeof(Math).GetMethod(nameof(Math.Sqrt)) !,
165+
method.DeclaringType == typeof(MathF)
166+
? typeof(MathF).GetRuntimeMethod(nameof(MathF.Sqrt), [typeof(float)])!
167+
: typeof(Math).GetRuntimeMethod(nameof(Math.Sqrt), [typeof(double)])!,
164168
[
165169
_sqlExpressionFactory.Add(
166170
_sqlExpressionFactory.Negate(
@@ -169,7 +173,7 @@ public class JetMathTranslator(ISqlExpressionFactory sqlExpressionFactory) : IMe
169173
arguments[0]
170174
)
171175
),
172-
_sqlExpressionFactory.Constant(1d)
176+
_sqlExpressionFactory.Constant(method.DeclaringType == typeof(MathF) ? 1f : 1d)
173177
)
174178
],
175179
logger

src/EFCore.Jet/Query/ExpressionTranslators/Internal/JetStringMethodTranslator.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,18 @@ private static readonly MethodInfo _lastOrDefaultMethodInfoWithoutArgs
184184

185185
if (_substringMethodInfoWithTwoArgs.Equals(method))
186186
{
187+
var argument = arguments[0];
188+
//if argument is a function expression, coalesce to 0
189+
if (argument is SqlFunctionExpression or SqlBinaryExpression or SqlUnaryExpression)
190+
{
191+
argument = _sqlExpressionFactory.Coalesce(argument, _sqlExpressionFactory.Constant(0));
192+
}
187193
return _sqlExpressionFactory.Function(
188194
"MID",
189195
[
190196
instance,
191197
_sqlExpressionFactory.Add(
192-
arguments[0],
198+
argument,
193199
_sqlExpressionFactory.Constant(1)),
194200
arguments[1]
195201
],
@@ -296,7 +302,7 @@ private SqlExpression TranslateIndexOf(
296302

297303
var argumentsPropagateNullability = Enumerable.Repeat(true, charIndexArguments.Count);
298304

299-
SqlExpression charIndexExpression = charIndexExpression = _sqlExpressionFactory.Function(
305+
SqlExpression charIndexExpression = _sqlExpressionFactory.Function(
300306
"INSTR",
301307
charIndexArguments,
302308
nullable: true,

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,35 +221,40 @@ private void VisitJetTables(IReadOnlyList<TableExpressionBase> Tables, bool addf
221221

222222
const int maxTablesWithoutBrackets = 2;
223223

224+
var nonCrossTableCount = Tables.Count(t => t is not CrossJoinExpression and not CrossApplyExpression);
225+
224226
Sql.Append(
225227
new string(
226228
'(',
227-
Math.Max(
228-
0,
229-
Tables
230-
.Count(t => !(t is CrossJoinExpression or CrossApplyExpression)) -
231-
maxTablesWithoutBrackets)));
229+
Math.Max(0, nonCrossTableCount - maxTablesWithoutBrackets)));
230+
231+
var nonCrossTablesSeen = 0;
232232

233233
for (var index = 0; index < Tables.Count; index++)
234234
{
235235
var tableExpression = Tables[index];
236236

237237
var isApplyExpression = tableExpression is CrossApplyExpression or OuterApplyExpression;
238-
239238
var isCrossExpression = tableExpression is CrossJoinExpression or CrossApplyExpression;
239+
var isNonCrossExpression = !isCrossExpression;
240240

241241
if (isApplyExpression)
242242
{
243243
throw new UnreachableException();
244244
}
245245

246+
if (isNonCrossExpression)
247+
{
248+
nonCrossTablesSeen++;
249+
}
250+
246251
if (index > 0)
247252
{
248253
if (isCrossExpression)
249254
{
250255
Sql.Append(",");
251256
}
252-
else if (index >= maxTablesWithoutBrackets)
257+
else if (nonCrossTablesSeen > maxTablesWithoutBrackets)
253258
{
254259
Sql.Append(")");
255260
}
@@ -262,28 +267,28 @@ private void VisitJetTables(IReadOnlyList<TableExpressionBase> Tables, bool addf
262267
{
263268
if (expression.JoinPredicate is SqlBinaryExpression binaryJoin)
264269
{
265-
tempcolexp = ExtractColumnExpressions(binaryJoin!);
270+
tempcolexp = ExtractColumnExpressions(binaryJoin);
266271
}
267272
else if (expression.JoinPredicate is SqlUnaryExpression unaryJoin)
268273
{
269-
tempcolexp = ExtractColumnExpressions(unaryJoin!);
274+
tempcolexp = ExtractColumnExpressions(unaryJoin);
270275
}
271276
else
272277
{
273278
tempcolexp = [];
274279
}
275280

276-
bool refrencesfirsttable = false;
277-
foreach (ColumnExpression col in tempcolexp)
281+
var referencesFirstTable = false;
282+
foreach (var col in tempcolexp)
278283
{
279284
if (col.TableAlias == Tables[0].Alias)
280285
{
281-
refrencesfirsttable = true;
286+
referencesFirstTable = true;
282287
break;
283288
}
284289
}
285290

286-
if (refrencesfirsttable)
291+
if (referencesFirstTable)
287292
{
288293
Visit(tableExpression);
289294
continue;

src/EFCore.Jet/Scaffolding/Internal/JetDatabaseModelFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private void GetColumns(DbConnection connection, IReadOnlyList<DatabaseTable> ta
258258
Table = table,
259259
Name = columnName!,
260260
StoreType = storeType,
261-
IsNullable = nullable,
261+
IsNullable = storeType != "counter" && nullable,
262262
DefaultValue = defaultValueobj,
263263
DefaultValueSql = defaultValue,
264264
ComputedColumnSql = null,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using Xunit;
2+
3+
[assembly: CollectionBehavior(
4+
DisableTestParallelization = false,
5+
MaxParallelThreads = 1)]

0 commit comments

Comments
 (0)