Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and test suite (EF Core 8.0.13) #1979

Merged
merged 1 commit into from
Mar 2, 2025
Merged
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
28 changes: 14 additions & 14 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.3,8.0.999]</EFCoreVersion>
<EFCoreVersion>[8.0.13,8.0.999]</EFCoreVersion>
</PropertyGroup>

<ItemGroup Label="Dependencies">
Expand All @@ -16,26 +16,26 @@
<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.3" />
<PackageReference Update="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.3" />
<PackageReference Update="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.13" />
<PackageReference Update="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.13" />
<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" />
<PackageReference Update="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Update="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageReference Update="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Update="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
<PackageReference Update="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Update="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="8.0.2" />
<PackageReference Update="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageReference Update="Moq" Version="4.20.70" />
<PackageReference Update="Moq" Version="4.20.72" />
<PackageReference Update="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Update="System.ComponentModel.TypeConverter" Version="4.3.0" />
<PackageReference Update="System.Diagnostics.DiagnosticSource" Version="8.0.0" />
<PackageReference Update="GitHubActionsTestLogger" Version="2.3.3" />
<PackageReference Update="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
<PackageReference Update="GitHubActionsTestLogger" Version="2.4.1" />

<!-- Keep at the same level that the EF Core projects use. -->
<PackageReference Update="xunit.assert" Version="2.4.2" />
Expand Down
2 changes: 1 addition & 1 deletion dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "8.0.3",
"version": "8.0.13",
"commands": [
"dotnet-ef"
]
Expand Down
121 changes: 121 additions & 0 deletions test/EFCore.MySql.FunctionalTests/MigrationsMySqlTest.cs
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.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
Expand All @@ -9,6 +10,7 @@
using Microsoft.EntityFrameworkCore.Migrations.Design;
using Microsoft.EntityFrameworkCore.Scaffolding;
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Microsoft.Extensions.DependencyInjection;
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;
Expand Down Expand Up @@ -1302,6 +1304,125 @@ public override Task Rename_table()
},
withConventions: false);

public override async Task Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table()
{
await Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table_core("'[3, 2, 1]'");

AssertSql(
"""
ALTER TABLE `Customers` ADD `Numbers` varchar(127) CHARACTER SET utf8mb4 NOT NULL DEFAULT '[3, 2, 1]';
""");
}

protected override Task Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table_core(string defaultValueSql)
=> Test(
builder => builder.Entity(
"Customer", e =>
{
e.Property<int>("Id").ValueGeneratedOnAdd();
e.HasKey("Id");
e.Property<string>("Name");
e.ToTable("Customers");
}),
builder => builder.Entity(
"Customer", e =>
{
e.Property<int>("Id").ValueGeneratedOnAdd();
e.HasKey("Id");
e.Property<string>("Name");
e.Property<List<int>>("Numbers").IsRequired()
.HasMaxLength(127) // <-- MySQL requires a `varchar(n)` instead of a `longtext` type for default value support
.HasDefaultValueSql(defaultValueSql);
e.ToTable("Customers");
}),
model =>
{
var customersTable = Assert.Single(model.Tables.Where(t => t.Name == "Customers"));

Assert.Collection(
customersTable.Columns,
c => Assert.Equal("Id", c.Name),
c => Assert.Equal("Name", c.Name),
c => Assert.Equal("Numbers", c.Name));
Assert.Same(
customersTable.Columns.Single(c => c.Name == "Id"),
Assert.Single(customersTable.PrimaryKey!.Columns));
});

public override Task Add_required_primitve_collection_with_custom_converter_and_custom_default_value_to_existing_table()
=> Test(
builder => builder.Entity(
"Customer", e =>
{
e.Property<int>("Id").ValueGeneratedOnAdd();
e.HasKey("Id");
e.Property<string>("Name");
e.ToTable("Customers");
}),
builder => builder.Entity(
"Customer", e =>
{
e.Property<int>("Id").ValueGeneratedOnAdd();
e.HasKey("Id");
e.Property<string>("Name");
e.Property<List<int>>("Numbers")
.HasMaxLength(127) // <-- MySQL requires a `varchar(n)` instead of a `longtext` type for default value support
.HasConversion(new ValueConverter<List<int>, string>(
convertToProviderExpression: x => x != null && x.Count > 0 ? "some numbers" : "nothing",
convertFromProviderExpression: x => x == "nothing" ? new List<int> { } : new List<int> { 7, 8, 9 }))
.HasDefaultValue(new List<int> { 42 })
.IsRequired();
e.ToTable("Customers");
}),
model =>
{
var customersTable = Assert.Single(model.Tables.Where(t => t.Name == "Customers"));

Assert.Collection(
customersTable.Columns,
c => Assert.Equal("Id", c.Name),
c => Assert.Equal("Name", c.Name),
c => Assert.Equal("Numbers", c.Name));
Assert.Same(
customersTable.Columns.Single(c => c.Name == "Id"),
Assert.Single(customersTable.PrimaryKey!.Columns));
});

public override Task Add_required_primitve_collection_with_custom_default_value_to_existing_table()
=> Test(
builder => builder.Entity(
"Customer", e =>
{
e.Property<int>("Id").ValueGeneratedOnAdd();
e.HasKey("Id");
e.Property<string>("Name");
e.ToTable("Customers");
}),
builder => builder.Entity(
"Customer", e =>
{
e.Property<int>("Id").ValueGeneratedOnAdd();
e.HasKey("Id");
e.Property<string>("Name");
e.Property<List<int>>("Numbers")
.HasMaxLength(127) // <-- MySQL requires a `varchar(n)` instead of a `longtext` type for default value support
.IsRequired().HasDefaultValue(new List<int> { 1, 2, 3 });
e.ToTable("Customers");
}),
model =>
{
var customersTable = Assert.Single(model.Tables.Where(t => t.Name == "Customers"));

Assert.Collection(
customersTable.Columns,
c => Assert.Equal("Id", c.Name),
c => Assert.Equal("Name", c.Name),
c => Assert.Equal("Numbers", c.Name));
Assert.Same(
customersTable.Columns.Single(c => c.Name == "Id"),
Assert.Single(customersTable.PrimaryKey!.Columns));
});

// The constraint name for a primary key is always PRIMARY in MySQL.
protected override bool AssertConstraintNames
=> false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;

namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query;

public class AdHocAdvancedMappingsQueryMySqlTest : AdHocAdvancedMappingsQueryRelationalTestBase
{
protected override ITestStoreFactory TestStoreFactory
=> MySqlTestStoreFactory.Instance;

public override async Task Two_similar_complex_properties_projected_with_split_query1()
{
await base.Two_similar_complex_properties_projected_with_split_query1();

AssertSql(
"""
SELECT `o`.`Id`
FROM `Offers` AS `o`
ORDER BY `o`.`Id`
""",
//
"""
SELECT `t`.`Id`, `t`.`NestedId`, `t`.`OfferId`, `t`.`payment_brutto`, `t`.`payment_netto`, `t`.`Id0`, `t`.`payment_brutto0`, `t`.`payment_netto0`, `o`.`Id`
FROM `Offers` AS `o`
INNER JOIN (
SELECT `v`.`Id`, `v`.`NestedId`, `v`.`OfferId`, `v`.`payment_brutto`, `v`.`payment_netto`, `n`.`Id` AS `Id0`, `n`.`payment_brutto` AS `payment_brutto0`, `n`.`payment_netto` AS `payment_netto0`
FROM `Variation` AS `v`
LEFT JOIN `NestedEntity` AS `n` ON `v`.`NestedId` = `n`.`Id`
) AS `t` ON `o`.`Id` = `t`.`OfferId`
ORDER BY `o`.`Id`
""");
}

public override async Task Two_similar_complex_properties_projected_with_split_query2()
{
await base.Two_similar_complex_properties_projected_with_split_query2();

AssertSql(
"""
SELECT `o`.`Id`
FROM `Offers` AS `o`
WHERE `o`.`Id` = 1
ORDER BY `o`.`Id`
LIMIT 2
""",
//
"""
SELECT `t0`.`Id`, `t0`.`NestedId`, `t0`.`OfferId`, `t0`.`payment_brutto`, `t0`.`payment_netto`, `t0`.`Id0`, `t0`.`payment_brutto0`, `t0`.`payment_netto0`, `t`.`Id`
FROM (
SELECT `o`.`Id`
FROM `Offers` AS `o`
WHERE `o`.`Id` = 1
LIMIT 1
) AS `t`
INNER JOIN (
SELECT `v`.`Id`, `v`.`NestedId`, `v`.`OfferId`, `v`.`payment_brutto`, `v`.`payment_netto`, `n`.`Id` AS `Id0`, `n`.`payment_brutto` AS `payment_brutto0`, `n`.`payment_netto` AS `payment_netto0`
FROM `Variation` AS `v`
LEFT JOIN `NestedEntity` AS `n` ON `v`.`NestedId` = `n`.`Id`
) AS `t0` ON `t`.`Id` = `t0`.`OfferId`
ORDER BY `t`.`Id`
""");
}

public override async Task Projecting_one_of_two_similar_complex_types_picks_the_correct_one()
{
await base.Projecting_one_of_two_similar_complex_types_picks_the_correct_one();

AssertSql(
"""
@__p_0='10'

SELECT `a`.`Id`, `t`.`Info_Created0` AS `Created`
FROM (
SELECT `c`.`Id`, `b`.`AId`, `b`.`Info_Created` AS `Info_Created0`
FROM `Cs` AS `c`
INNER JOIN `Bs` AS `b` ON `c`.`BId` = `b`.`Id`
WHERE `b`.`AId` = 1
ORDER BY `c`.`Id`
LIMIT @__p_0
) AS `t`
LEFT JOIN `As` AS `a` ON `t`.`AId` = `a`.`Id`
ORDER BY `t`.`Id`
""");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities;

namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query;

public class AdHocComplexTypeQueryMySqlTest : AdHocComplexTypeQueryTestBase
{
public override async Task Complex_type_equals_parameter_with_nested_types_with_property_of_same_name()
{
await base.Complex_type_equals_parameter_with_nested_types_with_property_of_same_name();

AssertSql(
"""
@__entity_equality_container_0_Id='1' (Nullable = true)
@__entity_equality_container_0_Containee1_Id='2' (Nullable = true)
@__entity_equality_container_0_Containee2_Id='3' (Nullable = true)

SELECT `e`.`Id`, `e`.`ComplexContainer_Id`, `e`.`ComplexContainer_Containee1_Id`, `e`.`ComplexContainer_Containee2_Id`
FROM `EntityType` AS `e`
WHERE ((`e`.`ComplexContainer_Id` = @__entity_equality_container_0_Id) AND (`e`.`ComplexContainer_Containee1_Id` = @__entity_equality_container_0_Containee1_Id)) AND (`e`.`ComplexContainer_Containee2_Id` = @__entity_equality_container_0_Containee2_Id)
LIMIT 2
""");
}

protected TestSqlLoggerFactory TestSqlLoggerFactory
=> (TestSqlLoggerFactory)ListLoggerFactory;

protected void AssertSql(params string[] expected)
=> TestSqlLoggerFactory.AssertBaseline(expected);

protected override ITestStoreFactory TestStoreFactory
=> MySqlTestStoreFactory.Instance;
}
Loading