Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,6 @@ ASALocalRun/

# Local History for Visual Studio
.localhistory/

#VSCode
.vscode/
15 changes: 10 additions & 5 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{
"version": "0.1.0",
"version": "2.0.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"label": "build",
"type": "shell",
"command": "dotnet",
"args": [
"build",
"${workspaceRoot}/test/EFCore.MySql.IntegrationTests/EFCore.MySql.IntegrationTests.csproj"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
"problemMatcher": "$msCompile",
"group": {
"_id": "build",
"isDefault": false
}
}
]
}
21 changes: 8 additions & 13 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
-->
<EFCoreVersion>[9.0.0,9.0.999]</EFCoreVersion>
</PropertyGroup>

<ItemGroup Label="Dependencies">
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="$(EFCoreVersion)" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="$(EFCoreVersion)" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="$(EFCoreVersion)" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="$(EFCoreVersion)" />

<PackageVersion Include="MySqlConnector" Version="2.4.0" />
<PackageVersion Include="MySqlConnector" Version="2.5.0" />
<PackageVersion Include="MySqlConnector.DependencyInjection" Version="2.4.0" />

<PackageVersion Include="NetTopologySuite" Version="2.5.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />

<PackageVersion Include="NetTopologySuite" Version="2.6.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
<PackageVersion Include="Castle.Core" Version="5.1.1" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.0" />
Expand All @@ -28,27 +24,26 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.0" /> <!-- CHECK: used? -->
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<!-- CHECK: used? -->
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.103" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="System.Collections.Immutable" Version="9.0.0" />
<PackageVersion Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="9.0.0" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />

<!-- Keep at the same level that the EF Core projects use. -->
<PackageVersion Include="xunit.assert" Version="2.9.2" />
<PackageVersion Include="xunit.core" Version="2.9.2" />
<PackageVersion Include="xunit.runner.console" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />

<!-- Needed when using EFCore.Design assembly from local EF Core repository. -->
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.10.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "9.0.100",
"version": "10.0.103",
"allowPrerelease": false,
"rollForward": "latestFeature"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ protected override void GenerateLimitOffset(SelectExpression selectExpression)
}
}

// Single-argument aggregates: generate Name(arg) to match historical SQL shape.
// EF Core 9.x base now generates Name((arg)); we keep the old format for backward compatibility.
private static readonly HashSet<string> SingleArgAggregateFunctions = new(StringComparer.OrdinalIgnoreCase)
{
"AVG", "MAX", "MIN", "SUM", "COUNT", "BIT_AND", "BIT_OR", "BIT_XOR",
"STD", "STDDEV", "STDDEV_POP", "STDDEV_SAMP", "VAR_POP", "VAR_SAMP", "VARIANCE",
};

protected override Expression VisitSqlFunction(SqlFunctionExpression sqlFunctionExpression)
{
if (sqlFunctionExpression.Name.StartsWith("@@", StringComparison.Ordinal))
Expand All @@ -258,6 +266,16 @@ protected override Expression VisitSqlFunction(SqlFunctionExpression sqlFunction
return sqlFunctionExpression;
}

if (SingleArgAggregateFunctions.Contains(sqlFunctionExpression.Name)
&& sqlFunctionExpression.Arguments.Count == 1)
{
Sql.Append(sqlFunctionExpression.Name);
Sql.Append("(");
Visit(sqlFunctionExpression.Arguments[0]);
Sql.Append(")");
return sqlFunctionExpression;
}

return base.VisitSqlFunction(sqlFunctionExpression);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -84,7 +84,9 @@ public virtual async Task Where_contains_query_escapes(bool async)
{
using (var context = CreateContext())
{
var artistNames = new[]
// Use List<string> so Contains binds to Enumerable.Contains; array can bind to
// MemoryExtensions.Contains(ReadOnlySpan) and break the expression interpreter.
var artistNames = new List<string>
{
@"Back\slasher's",
@"John's Chill Box"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
Expand Down Expand Up @@ -26,7 +27,8 @@ public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async)
var dto = MySqlTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0)));
var start = dto.AddDays(-1);
var end = dto.AddDays(1);
var dates = new[] { dto };
// Use List to avoid ReadOnlySpan in expression tree (same as EscapesMySqlTestBase).
var dates = new List<DateTimeOffset> { dto };

return AssertQuery(
async,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
Expand Down Expand Up @@ -9147,7 +9148,8 @@ public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool a
var dto = MySqlTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0)));
var start = dto.AddDays(-1);
var end = dto.AddDays(1);
var dates = new[] { dto };
// Use List to avoid ReadOnlySpan in expression tree (same as GearsOfWarQueryMySqlTest).
var dates = new List<DateTimeOffset> { dto };

await AssertQuery(
async,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
Expand Down Expand Up @@ -28,7 +29,8 @@ public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async)
var dto = MySqlTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0)));
var start = dto.AddDays(-1);
var end = dto.AddDays(1);
var dates = new[] { dto };
// Use List to avoid ReadOnlySpan in expression tree (same as GearsOfWarQueryMySqlTest).
var dates = new List<DateTimeOffset> { dto };

return AssertQuery(
async,
Expand Down
2 changes: 2 additions & 0 deletions test/EFCore.MySql.FunctionalTests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Functional Tests

**Configuring the Database**

The functional tests are intended to be run against **MySQL 8.0+** or an equivalent **MariaDB** version (see the main README for tested versions).

Configure your MySQL database by opening the `config.json.example` file, specifying the connection string and saving the changed file as `config.json`.

**Running Functional Tests**
Expand Down
2 changes: 2 additions & 0 deletions test/EFCore.MySql.IntegrationTests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Integration and Performance Tests

**Configuring the Database**

The integration tests are intended to be run against **MySQL 8.0+** or an equivalent **MariaDB** version (see the main README for tested versions).

1. Configure your MySQL database by opening the `config.json.example` file, specifying the connection string and saving the changed file as `config.json`.
2. Run the `scripts/rebuild.ps1` PowerShell script on Linux or Windows to rebuild all migrations (for installing PowerShell, see [Install PowerShell on Windows, Linux, and macOS](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell)). Any time you make changes to the database models, run the rebuild script again.

Expand Down