Skip to content

Commit

Permalink
Update to EF Core 8.0.2 (#1866)
Browse files Browse the repository at this point in the history
* Update dependencies and versions.

* Add new tests.

* Update test baselines.

* Implement efcore#32234 related test.

* Implement tests.

* Rename OffsetReferencesOuterQuery to WhereSubqueryReferencesOuterQuery.

* Copy EF Core fix.
  • Loading branch information
lauxjpn committed Mar 7, 2024
1 parent 2ba0d90 commit 9a8cdcf
Show file tree
Hide file tree
Showing 26 changed files with 372 additions and 126 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
fail-fast: false
matrix:
dbVersion:
- 8.0.34-mysql
- 5.7.43-mysql
- 8.0.36-mysql
- 5.7.44-mysql
- 11.2.2-mariadb
- 11.1.3-mariadb
- 11.0.4-mariadb
Expand Down
8 changes: 4 additions & 4 deletions Dependencies.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup Label="Common Versions">
<EFCoreVersion>[8.0.1,8.0.999]</EFCoreVersion>
<EFCoreVersion>[8.0.2,8.0.999]</EFCoreVersion>
</PropertyGroup>

<ItemGroup Label="Dependencies">
Expand All @@ -13,12 +13,12 @@
<PackageReference Update="MySqlConnector.DependencyInjection" Version="2.3.5" />

<PackageReference Update="NetTopologySuite" Version="2.5.0" />
<PackageReference Update="System.Text.Json" Version="8.0.1" />
<PackageReference Update="System.Text.Json" Version="8.0.2" />
<PackageReference Update="Newtonsoft.Json" Version="13.0.3" />

<PackageReference Update="Castle.Core" Version="5.1.1" />
<PackageReference Update="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Update="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.1" />
<PackageReference Update="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Update="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.2" />
<PackageReference Update="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Update="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Update="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
Expand Down
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
<Import Project="Version.props" />
<Import Project="Development.props" Condition="Exists('Development.props')" />

<PropertyGroup>
<LocalEFCoreRepositoryConfiguration Condition="'$(LocalEFCoreRepositoryConfiguration)' == ''">Debug</LocalEFCoreRepositoryConfiguration>
<LocalMySqlConnectorRepositoryConfiguration Condition="'$(LocalMySqlConnectorRepositoryConfiguration)' == ''">debug</LocalMySqlConnectorRepositoryConfiguration>
<DefineConstants Condition="'$(LocalEFCoreRepository)' != '' And '$(LocalEFCoreRepositoryConfiguration)' == 'Debug'">$(DefineConstants);EFCORE_DEBUG_BUILD</DefineConstants>
<DefineConstants Condition="'$(LocalMySqlConnectorRepository)' != '' And '$(LocalMySqlConnectorRepositoryConfiguration)' == 'Debug'">$(DefineConstants);MYSQLCONNECTOR_DEBUG_BUILD</DefineConstants>
</PropertyGroup>

<PropertyGroup>
<StrongNameKeyId>Pomelo.EntityFrameworkCore.MySql</StrongNameKeyId>
<PackageTags>pomelo;mysql;mariadb;Entity Framework Core;entity-framework-core;ef;efcore;ef core;orm;sql</PackageTags>
Expand Down
6 changes: 2 additions & 4 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
<add key="pomelo-nightly-debug-azdo" value="https://pkgs.dev.azure.com/pomelo-efcore/Pomelo.EntityFrameworkCore.MySql/_packaging/pomelo-efcore-debug/nuget/v3/index.json" />
<add key="pomelo-nightly-public-myget" value="https://www.myget.org/F/pomelo/api/v3/index.json" />
<add key="pomelo-nightly-debug-myget" value="https://www.myget.org/F/pomelo-debug/api/v3/index.json" />

<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />

<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
</packageSources>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@
<!-- TODO: Can be removed because it is already contained in EFCore.MySql. -->
<ItemGroup Condition="'$(LocalMySqlConnectorRepository)' != ''">
<Reference Include="MySqlConnector">
<HintPath>$(LocalMySqlConnectorRepository)\artifacts\bin\MySqlConnector\debug_$(MySqlConnectorTargetFramework)\MySqlConnector.dll</HintPath>
<HintPath>$(LocalMySqlConnectorRepository)\artifacts\bin\MySqlConnector\$(LocalMySqlConnectorRepositoryConfiguration)_$(MySqlConnectorTargetFramework)\MySqlConnector.dll</HintPath>
</Reference>
</ItemGroup>

<!-- TODO: Can be removed because it is already contained in EFCore.MySql. -->
<!-- TODO: Check, whether the following references are really all in use. -->
<ItemGroup Condition="'$(LocalEFCoreRepository)' != ''">
<Reference Include="Microsoft.EntityFrameworkCore">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Abstractions">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Abstractions.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Analyzers">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Analyzers.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Analyzers.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Relational">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Relational.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Relational.dll</HintPath>
</Reference>

<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@
<!-- TODO: Can be removed because it is already contained in EFCore.MySql. -->
<ItemGroup Condition="'$(LocalMySqlConnectorRepository)' != ''">
<Reference Include="MySqlConnector">
<HintPath>$(LocalMySqlConnectorRepository)\artifacts\bin\MySqlConnector\debug_$(MySqlConnectorTargetFramework)\MySqlConnector.dll</HintPath>
<HintPath>$(LocalMySqlConnectorRepository)\artifacts\bin\MySqlConnector\$(LocalMySqlConnectorRepositoryConfiguration)_$(MySqlConnectorTargetFramework)\MySqlConnector.dll</HintPath>
</Reference>
</ItemGroup>

<!-- TODO: Can be removed because it is already contained in EFCore.MySql. -->
<!-- TODO: Check, whether the following references are really all in use. -->
<ItemGroup Condition="'$(LocalEFCoreRepository)' != ''">
<Reference Include="Microsoft.EntityFrameworkCore">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Abstractions">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Abstractions.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Analyzers">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Analyzers.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Analyzers.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Relational">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Relational.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Relational.dll</HintPath>
</Reference>

<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
Expand Down
10 changes: 5 additions & 5 deletions src/EFCore.MySql.NTS/EFCore.MySql.NTS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@
<!-- TODO: Can be removed because it is already contained in EFCore.MySql. -->
<ItemGroup Condition="'$(LocalMySqlConnectorRepository)' != ''">
<Reference Include="MySqlConnector">
<HintPath>$(LocalMySqlConnectorRepository)\artifacts\bin\MySqlConnector\debug_$(MySqlConnectorTargetFramework)\MySqlConnector.dll</HintPath>
<HintPath>$(LocalMySqlConnectorRepository)\artifacts\bin\MySqlConnector\$(LocalMySqlConnectorRepositoryConfiguration)_$(MySqlConnectorTargetFramework)\MySqlConnector.dll</HintPath>
</Reference>
</ItemGroup>

<!-- TODO: Can be removed because it is already contained in EFCore.MySql. -->
<!-- TODO: Check, whether the following references are really all in use. -->
<ItemGroup Condition="'$(LocalEFCoreRepository)' != ''">
<Reference Include="Microsoft.EntityFrameworkCore">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Abstractions">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Abstractions.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Analyzers">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Analyzers.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Analyzers.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Relational">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Relational.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Relational.dll</HintPath>
</Reference>

<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
Expand Down
10 changes: 5 additions & 5 deletions src/EFCore.MySql/EFCore.MySql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@

<ItemGroup Condition="'$(LocalEFCoreRepository)' != ''">
<Reference Include="Microsoft.EntityFrameworkCore">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Abstractions">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Abstractions.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Analyzers">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Analyzers.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Analyzers.dll</HintPath>
</Reference>
<Reference Include="Microsoft.EntityFrameworkCore.Relational">
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\Debug\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Relational.dll</HintPath>
<HintPath>$(LocalEFCoreRepository)\artifacts\bin\EFCore.Relational\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTargetFramework)\Microsoft.EntityFrameworkCore.Relational.dll</HintPath>
</Reference>

<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
Expand All @@ -55,7 +55,7 @@

<ItemGroup Condition="'$(LocalMySqlConnectorRepository)' != ''">
<Reference Include="MySqlConnector">
<HintPath>$(LocalMySqlConnectorRepository)\artifacts\bin\MySqlConnector\debug_$(MySqlConnectorTargetFramework)\MySqlConnector.dll</HintPath>
<HintPath>$(LocalMySqlConnectorRepository)\artifacts\bin\MySqlConnector\$(LocalMySqlConnectorRepositoryConfiguration)_$(MySqlConnectorTargetFramework)\MySqlConnector.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.MySql/Infrastructure/MariaDbServerVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.EntityFrameworkCore
public class MariaDbServerVersion : ServerVersion
{
public static readonly string MariaDbTypeIdentifier = nameof(ServerType.MariaDb).ToLowerInvariant();
public static readonly ServerVersion LatestSupportedServerVersion = new MariaDbServerVersion(new Version(10, 9, 4));
public static readonly ServerVersion LatestSupportedServerVersion = new MariaDbServerVersion(new Version(11, 3, 2));

public override ServerVersionSupport Supports { get; }

Expand Down Expand Up @@ -90,7 +90,7 @@ internal MariaDbServerVersionSupport([NotNull] ServerVersion serverVersion)
public override bool JsonValue => true;
public override bool Values => ServerVersion.Version >= new Version(10, 3, 3);
public override bool ValuesWithRows => false;
public override bool OffsetReferencesOuterQuery => false;
public override bool WhereSubqueryReferencesOuterQuery => false;

public override bool JsonTableImplementationStable => false;
public override bool JsonTableImplementationWithoutMariaDbBugs => false;
Expand Down
4 changes: 2 additions & 2 deletions src/EFCore.MySql/Infrastructure/MySqlServerVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.EntityFrameworkCore
public class MySqlServerVersion : ServerVersion
{
public static readonly string MySqlTypeIdentifier = nameof(ServerType.MySql).ToLowerInvariant();
public static readonly ServerVersion LatestSupportedServerVersion = new MySqlServerVersion(new Version(8, 0, 31));
public static readonly ServerVersion LatestSupportedServerVersion = new MySqlServerVersion(new Version(8, 0, 36));

public override ServerVersionSupport Supports { get; }

Expand Down Expand Up @@ -93,7 +93,7 @@ internal MySqlServerVersionSupport([NotNull] ServerVersion serverVersion)
public override bool JsonValue => ServerVersion.Version >= new Version(8, 0, 21);
public override bool Values => false;
public override bool ValuesWithRows => ServerVersion.Version >= new Version(8, 0, 19);
public override bool OffsetReferencesOuterQuery => false;
public override bool WhereSubqueryReferencesOuterQuery => false;

public override bool JsonTableImplementationStable => false;
public override bool JsonTableImplementationWithoutMySqlBugs => false; // Other non-fatal bugs regarding JSON_TABLE.
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.MySql/Infrastructure/ServerVersionSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public virtual bool PropertyOrVersion(string propertyNameOrServerVersion)
public virtual bool JsonValue => false;
public virtual bool Values => false;
public virtual bool ValuesWithRows => false;
public virtual bool OffsetReferencesOuterQuery => false;
public virtual bool WhereSubqueryReferencesOuterQuery => false;

public virtual bool JsonTableImplementationStable => JsonTable;
public virtual bool JsonTableImplementationWithoutMySqlBugs => JsonTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
Expand Down Expand Up @@ -538,7 +539,9 @@ protected virtual SqlExpression GetLikeExpressionUsingParameter(QueryCompilation
QueryCompilationContext.QueryContextParameter);

var escapedPatternParameter =
queryCompilationContext.RegisterRuntimeParameter(patternParameter.Name + "_rewritten", lambda);
queryCompilationContext.RegisterRuntimeParameter(
$"{patternParameter.Name}_{methodType.ToString().ToLower(CultureInfo.InvariantCulture)}",
lambda);

return _sqlExpressionFactory.Like(
targetTransform(target),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class MySqlQuerySqlGenerator : QuerySqlGenerator
private string _removeTableAliasOld;
private string _removeTableAliasNew;

private static readonly bool _useOldBehavior32375 =
AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue32375", out var enabled32375) && enabled32375;

/// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
Expand Down Expand Up @@ -543,6 +546,11 @@ protected override void GenerateValues(ValuesExpression valuesExpression)
return;
}

if (!_useOldBehavior32375 && valuesExpression.RowValues.Count == 0)
{
throw new InvalidOperationException(RelationalStrings.EmptyCollectionNotSupportedAsInlineQueryRoot);
}

var rowValues = valuesExpression.RowValues;

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ public override async Task Update_Where_set_property_plus_parameter(bool async)

AssertExecuteUpdateSql(
"""
@__value_0='Abc' (Size = 30)
@__value_0='Abc' (Size = 4000)

UPDATE `Customers` AS `c`
SET `c`.`ContactName` = CONCAT(COALESCE(`c`.`ContactName`, ''), @__value_0)
Expand Down
Loading

0 comments on commit 9a8cdcf

Please sign in to comment.