Skip to content

Commit

Permalink
update to match efc 9 ga
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJollyAU committed Nov 30, 2024
1 parent dd24f9a commit 4bdfe95
Show file tree
Hide file tree
Showing 36 changed files with 404 additions and 680 deletions.
10 changes: 5 additions & 5 deletions Dependencies.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<DotNetVersion>[9.0.0-rc.2.24473.5,9.0.999]</DotNetVersion>
<EFCoreVersion>[9.0.0-rc.2.24474.1,9.0.999]</EFCoreVersion>
<MSLibVersion>[9.0.0-rc.2.24473.5,9.0.999]</MSLibVersion>
<DotNetVersion>[9.0.0,9.0.999]</DotNetVersion>
<EFCoreVersion>[9.0.0,9.0.999]</EFCoreVersion>
<MSLibVersion>[9.0.0,9.0.999]</MSLibVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -29,8 +29,8 @@
<PackageReference Update="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="$(EFCoreVersion)" />
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="$(MSLibVersion)" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Update="MSTest.TestAdapter" Version="3.6.1" />
<PackageReference Update="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Update="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Update="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Update="coverlet.collector" Version="6.0.2" />
<PackageReference Update="Newtonsoft.Json" Version="13.0.3" />

Expand Down
5 changes: 0 additions & 5 deletions EFCore.Jet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.Jet.Odbc", "src\EFCo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.Jet.OleDb", "src\EFCore.Jet.OleDb\EFCore.Jet.OleDb.csproj", "{FFC89A2D-F68F-47E3-BA00-47E9C0BEDB71}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{05A38BCD-0042-446F-8E89-84090230BE76}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
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-rc.2.24474.11",
"version": "9.0.100",
"allowPrerelease": true,
"rollForward": "latestFeature"
}
Expand Down
26 changes: 26 additions & 0 deletions src/EFCore.Jet/Query/Sql/Internal/JetQuerySqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,22 @@ private List<ColumnExpression> ExtractColumnExpressions(SqlUnaryExpression unary
return result;
}

protected override Expression VisitInnerJoin(InnerJoinExpression innerJoinExpression)
{
parent.Push(innerJoinExpression);
var result = base.VisitInnerJoin(innerJoinExpression);
parent.Pop();
return result;
}

protected override Expression VisitLeftJoin(LeftJoinExpression leftJoinExpression)
{
parent.Push(leftJoinExpression);
var result = base.VisitLeftJoin(leftJoinExpression);
parent.Pop();
return result;
}

protected override Expression VisitProjection(ProjectionExpression projectionExpression)
{
if (projectionExpression.Expression is SqlConstantExpression { Value: null } constantExpression && (constantExpression.Type == typeof(int) || constantExpression.Type == typeof(double) || constantExpression.Type == typeof(float) || constantExpression.Type == typeof(decimal) || constantExpression.Type == typeof(short)))
Expand Down Expand Up @@ -1037,5 +1053,15 @@ protected override void CheckComposableSqlTrimmed(ReadOnlySpan<char> sql)
throw new InvalidOperationException(RelationalStrings.FromSqlNonComposable);
}
}

protected override bool RequiresParentheses(SqlExpression outerExpression, SqlExpression innerExpression)
{
var withinjoin = parent.Any(x => x is JoinExpressionBase);
if (outerExpression is SqlBinaryExpression { OperatorType: ExpressionType.OrElse, Right: SqlBinaryExpression } && withinjoin)
{
return true;
}
return base.RequiresParentheses(outerExpression, innerExpression);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
}
}

[ConditionalFact]
[ConditionalFact(Skip = "Jet can't return server generated guid's when it is the key. Currently using client geerated guid's")]
public async Task Insert_with_server_generated_GUID_key()
{
using var testStore = await JetTestStore.CreateInitializedAsync(DatabaseName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,195 +66,6 @@ IF NOT EXISTS (SELECT * FROM `INFORMATION_SCHEMA.TABLES` WHERE `TABLE_NAME` = '_
ignoreLineEndingDifferences: true);
}

public override void Can_generate_up_scripts()
{
base.Can_generate_up_scripts();

Assert.Equal(
"""
IF NOT EXISTS (SELECT * FROM `INFORMATION_SCHEMA.TABLES` WHERE `TABLE_NAME` = '__EFMigrationsHistory') THEN CREATE TABLE `__EFMigrationsHistory` (
`MigrationId` varchar(150) NOT NULL,
`ProductVersion` varchar(32) NOT NULL,
CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`)
);
;
BEGIN TRANSACTION;
CREATE TABLE `Table1` (
`Id` integer NOT NULL,
`Foo` integer NOT NULL,
`Description` varchar(255) NOT NULL,
CONSTRAINT `PK_Table1` PRIMARY KEY (`Id`)
);
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('00000000000001_Migration1', '7.0.0-test');
ALTER TABLE `Table1` RENAME COLUMN `Foo` TO `Bar`;
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('00000000000002_Migration2', '7.0.0-test');
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('00000000000003_Migration3', '7.0.0-test');
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('00000000000004_Migration4', '7.0.0-test');
INSERT INTO Table1 (Id, Bar, Description) VALUES (-1, 3, 'Value With
Empty Lines')
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('00000000000005_Migration5', '7.0.0-test');
INSERT INTO Table1 (Id, Bar, Description) VALUES (-2, 4, 'GO
Value With
Empty Lines')
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('00000000000006_Migration6', '7.0.0-test');
INSERT INTO Table1 (Id, Bar, Description) VALUES (-3, 5, 'GO
Value With
GO
Empty Lines
GO')
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('00000000000007_Migration7', '7.0.0-test');
COMMIT TRANSACTION;
""",
Sql,
ignoreLineEndingDifferences: true);
}

public override void Can_generate_one_up_script()
{
base.Can_generate_one_up_script();

Assert.Equal(
"""
BEGIN TRANSACTION;
ALTER TABLE `Table1` RENAME COLUMN `Foo` TO `Bar`;
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('00000000000002_Migration2', '7.0.0-test');
COMMIT TRANSACTION;
""",
Sql,
ignoreLineEndingDifferences: true);
}

public override void Can_generate_up_script_using_names()
{
base.Can_generate_up_script_using_names();

Assert.Equal(
"""
BEGIN TRANSACTION;
ALTER TABLE `Table1` RENAME COLUMN `Foo` TO `Bar`;
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('00000000000002_Migration2', '7.0.0-test');
COMMIT TRANSACTION;
""",
Sql,
ignoreLineEndingDifferences: true);
}

public override void Can_generate_idempotent_up_scripts()
=> Assert.Throws<NotSupportedException>(() => base.Can_generate_idempotent_up_scripts());

public override void Can_generate_idempotent_up_scripts_noTransactions()
=> Assert.Throws<NotSupportedException>(() => base.Can_generate_idempotent_up_scripts_noTransactions());

public override void Can_generate_down_scripts()
{
base.Can_generate_down_scripts();

Assert.Equal(
"""
BEGIN TRANSACTION;
ALTER TABLE `Table1` RENAME COLUMN `Bar` TO `Foo`;
DELETE FROM `__EFMigrationsHistory`
WHERE `MigrationId` = '00000000000002_Migration2';
DROP TABLE `Table1`;
DELETE FROM `__EFMigrationsHistory`
WHERE `MigrationId` = '00000000000001_Migration1';
COMMIT TRANSACTION;
""",
Sql,
ignoreLineEndingDifferences: true);
}

public override void Can_generate_idempotent_down_scripts()
=> Assert.Throws<NotSupportedException>(() => base.Can_generate_idempotent_down_scripts());

public override void Can_generate_one_down_script()
{
base.Can_generate_one_down_script();

Assert.Equal(
"""
BEGIN TRANSACTION;
ALTER TABLE `Table1` RENAME COLUMN `Bar` TO `Foo`;
DELETE FROM `__EFMigrationsHistory`
WHERE `MigrationId` = '00000000000002_Migration2';
COMMIT TRANSACTION;
""",
Sql,
ignoreLineEndingDifferences: true);
}

public override void Can_generate_down_script_using_names()
{
base.Can_generate_down_script_using_names();

Assert.Equal(
"""
BEGIN TRANSACTION;
ALTER TABLE `Table1` RENAME COLUMN `Bar` TO `Foo`;
DELETE FROM `__EFMigrationsHistory`
WHERE `MigrationId` = '00000000000002_Migration2';
COMMIT TRANSACTION;
""",
Sql,
ignoreLineEndingDifferences: true);
}

public override void Can_get_active_provider()
{
base.Can_get_active_provider();
Expand Down Expand Up @@ -922,6 +733,12 @@ public override void Can_diff_against_3_0_ASP_NET_Identity_model()
DiffSnapshot(new AspNetIdentity30ModelSnapshot(), context);
}

protected override Task ExecuteSqlAsync(string value)
{
((JetTestStore)Fixture.TestStore).ExecuteScript(value);
return Task.CompletedTask;
}

public class AspNetIdentity30ModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
Expand Down
Loading

0 comments on commit 4bdfe95

Please sign in to comment.