Skip to content
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
14 changes: 7 additions & 7 deletions Dependencies.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<DotNetVersion>[9.0.4,9.0.999]</DotNetVersion>
<EFCoreVersion>[9.0.4,9.0.999]</EFCoreVersion>
<MSLibVersion>[9.0.4,9.0.999]</MSLibVersion>
<DotNetVersion>[9.0.6,9.0.999]</DotNetVersion>
<EFCoreVersion>[9.0.6,9.0.999]</EFCoreVersion>
<MSLibVersion>[9.0.6,9.0.999]</MSLibVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -28,16 +28,16 @@
<PackageReference Update="Microsoft.EntityFrameworkCore.Design" Version="$(EFCoreVersion)" />
<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.13.0" />
<PackageReference Update="MSTest.TestAdapter" Version="3.8.3" />
<PackageReference Update="MSTest.TestFramework" Version="3.8.3" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Update="MSTest.TestAdapter" Version="3.9.3" />
<PackageReference Update="MSTest.TestFramework" Version="3.9.3" />
<PackageReference Update="coverlet.collector" Version="6.0.4" />
<PackageReference Update="Newtonsoft.Json" Version="13.0.3" />

<!-- EFCore.Jet.FunctionalTests -->
<PackageReference Update="xunit.core" Version="2.9.3"/>
<PackageReference Update="xunit.assert" Version="2.9.3" />
<PackageReference Update="xunit.runner.visualstudio" Version="3.0.2" />
<PackageReference Update="xunit.runner.visualstudio" Version="3.1.1" />
<PackageReference Update="xunit.runner.console" Version="2.9.3" />
<PackageReference Update="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MSLibVersion)" />
<PackageReference Update="NetTopologySuite" Version="2.5.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Jet.Data/AdoxSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ public override void RenameColumn(string tableName, string oldColumnName, string
}
}

protected static string GetDataTypeString(DataTypeEnum dataType, bool isIdentity = false)
private static string GetDataTypeString(DataTypeEnum dataType, bool isIdentity = false)
{
switch (dataType)
{
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Jet.Data/DaoSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ public override void RenameColumn(string tableName, string oldColumnName, string
}
}

protected static string GetDataTypeString(DataTypeEnum dataType, bool isIdentity = false)
private static string GetDataTypeString(DataTypeEnum dataType, bool isIdentity = false)
=> dataType switch
{
DataTypeEnum.dbBoolean => "bit",
Expand Down
6 changes: 3 additions & 3 deletions src/EFCore.Jet/Extensions/JetIndexExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public static void SetJetIncludeProperties(this IMutableIndex index, IReadOnlyLi
/// <param name="index"> The index. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
/// <param name="properties"> The value to set. </param>
public static void SetJetIncludeProperties(
public static IReadOnlyList<string>? SetJetIncludeProperties(
this IConventionIndex index, IReadOnlyList<string> properties, bool fromDataAnnotation = false)
=> index.SetOrRemoveAnnotation(
=> (IReadOnlyList<string>?)index.SetOrRemoveAnnotation(
JetAnnotationNames.Include,
properties,
fromDataAnnotation);
fromDataAnnotation)?.Value;

/// <summary>
/// Returns the <see cref="ConfigurationSource" /> for the included property names.
Expand Down
18 changes: 9 additions & 9 deletions src/EFCore.Jet/Extensions/JetModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public static void SetJetIdentitySeed(this IMutableModel model, int? seed)
/// <param name="model"> The model. </param>
/// <param name="seed"> The value to set. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
public static void SetJetIdentitySeed(this IConventionModel model, int? seed, bool fromDataAnnotation = false)
=> model.SetOrRemoveAnnotation(
public static int? SetJetIdentitySeed(this IConventionModel model, int? seed, bool fromDataAnnotation = false)
=> (int?)model.SetOrRemoveAnnotation(
JetAnnotationNames.IdentitySeed,
seed,
fromDataAnnotation);
fromDataAnnotation)?.Value;

/// <summary>
/// Returns the <see cref="ConfigurationSource" /> for the default schema.
Expand Down Expand Up @@ -72,12 +72,12 @@ public static void SetJetIdentityIncrement(this IMutableModel model, int? increm
/// <param name="model"> The model. </param>
/// <param name="increment"> The value to set. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
public static void SetJetIdentityIncrement(
public static int? SetJetIdentityIncrement(
this IConventionModel model, int? increment, bool fromDataAnnotation = false)
=> model.SetOrRemoveAnnotation(
=> (int?) model.SetOrRemoveAnnotation(
JetAnnotationNames.IdentityIncrement,
increment,
fromDataAnnotation);
fromDataAnnotation)?.Value;

/// <summary>
/// Returns the <see cref="ConfigurationSource" /> for the default identity increment.
Expand Down Expand Up @@ -112,16 +112,16 @@ public static void SetValueGenerationStrategy(this IMutableModel model, JetValue
/// <param name="model"> The model. </param>
/// <param name="value"> The value to set. </param>
/// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param>
public static void SetValueGenerationStrategy(
public static JetValueGenerationStrategy? SetValueGenerationStrategy(
this IConventionModel model, JetValueGenerationStrategy? value, bool fromDataAnnotation = false)
=> model.SetOrRemoveAnnotation(JetAnnotationNames.ValueGenerationStrategy, value, fromDataAnnotation);
=> (JetValueGenerationStrategy?)model.SetOrRemoveAnnotation(JetAnnotationNames.ValueGenerationStrategy, value, fromDataAnnotation)?.Value;

/// <summary>
/// Returns the <see cref="ConfigurationSource" /> for the default <see cref="JetValueGenerationStrategy" />.
/// </summary>
/// <param name="model"> The model. </param>
/// <returns> The <see cref="ConfigurationSource" /> for the default <see cref="JetValueGenerationStrategy" />. </returns>
public static ConfigurationSource? GetJetValueGenerationStrategyConfigurationSource(this IConventionModel model)
public static ConfigurationSource? GetValueGenerationStrategyConfigurationSource(this IConventionModel model)
=> model.FindAnnotation(JetAnnotationNames.ValueGenerationStrategy)?.GetConfigurationSource();
}
}
2 changes: 1 addition & 1 deletion src/EFCore.Jet/Extensions/JetPropertyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public static void SetValueGenerationStrategy(
/// </summary>
/// <param name="property"> The property. </param>
/// <returns> The <see cref="ConfigurationSource" /> for the <see cref="JetValueGenerationStrategy" />. </returns>
public static ConfigurationSource? GetJetValueGenerationStrategyConfigurationSource(
public static ConfigurationSource? GetValueGenerationStrategyConfigurationSource(
this IConventionProperty property)
=> property.FindAnnotation(JetAnnotationNames.ValueGenerationStrategy)?.GetConfigurationSource();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ private static readonly Dictionary<string, string> DatePartMapping
[false],
returnType),

nameof(DateTime.Date) => DateTimeNullChecked(
nameof(DateTime.Date) => _sqlExpressionFactory.DateTimeNullChecked(
instance!,
_sqlExpressionFactory.Function(
"DATEVALUE",
[instance!],
false,
[false],
returnType)),
nameof(DateTime.TimeOfDay) => TimeSpanNullChecked(
nameof(DateTime.TimeOfDay) => _sqlExpressionFactory.TimeSpanNullChecked(
instance!,
_sqlExpressionFactory.Function(
"TIMEVALUE",
Expand All @@ -109,31 +109,5 @@ private static readonly Dictionary<string, string> DatePartMapping
}
return null;
}

public CaseExpression DateTimeNullChecked(
SqlExpression checkSqlExpression,
SqlExpression notNullSqlExpression)
=> (CaseExpression)_sqlExpressionFactory.Case(
[
new CaseWhenClause(
_sqlExpressionFactory.IsNull(checkSqlExpression),
_sqlExpressionFactory.Constant(
null,typeof(DateTime),
notNullSqlExpression.TypeMapping))
],
notNullSqlExpression);

public CaseExpression TimeSpanNullChecked(
SqlExpression checkSqlExpression,
SqlExpression notNullSqlExpression)
=> (CaseExpression)_sqlExpressionFactory.Case(
[
new CaseWhenClause(
_sqlExpressionFactory.IsNull(checkSqlExpression),
_sqlExpressionFactory.Constant(
null,typeof(TimeSpan),
notNullSqlExpression.TypeMapping))
],
notNullSqlExpression);
}
}
29 changes: 27 additions & 2 deletions src/EFCore.Jet/Query/JetSqlExpressionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class JetSqlExpressionFactory(SqlExpressionFactoryDependencies dependenci

#region Expression factory methods

public SqlBinaryExpression? NullChecked(
public virtual SqlBinaryExpression? NullChecked(
SqlExpression sqlExpression,
RelationalTypeMapping? typeMapping = null)
=> (SqlBinaryExpression?)MakeBinary(
Expand All @@ -18,7 +18,7 @@ public class JetSqlExpressionFactory(SqlExpressionFactoryDependencies dependenci
RelationalTypeMapping.NullMapping),
typeMapping);

public CaseExpression NullChecked(
public virtual CaseExpression NullChecked(
SqlExpression checkSqlExpression,
SqlExpression notNullSqlExpression)
=> (CaseExpression)Case(
Expand All @@ -31,6 +31,31 @@ public CaseExpression NullChecked(
],
notNullSqlExpression);

public virtual CaseExpression DateTimeNullChecked(
SqlExpression checkSqlExpression,
SqlExpression notNullSqlExpression)
=> (CaseExpression)Case(
[
new CaseWhenClause(
IsNull(checkSqlExpression),
Constant(
null,typeof(DateTime),
notNullSqlExpression.TypeMapping))
],
notNullSqlExpression);

public virtual CaseExpression TimeSpanNullChecked(
SqlExpression checkSqlExpression,
SqlExpression notNullSqlExpression)
=> (CaseExpression)Case(
[
new CaseWhenClause(
IsNull(checkSqlExpression),
Constant(
null,typeof(TimeSpan),
notNullSqlExpression.TypeMapping))
],
notNullSqlExpression);
#endregion Expression factory methods
}
}
2 changes: 1 addition & 1 deletion src/EFCore.Jet/Query/Sql/Internal/JetQuerySqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ protected override Expression VisitSqlUnary(SqlUnaryExpression sqlUnaryExpressio
}


protected Expression VisitJetConvertExpression(SqlUnaryExpression convertExpression)
private Expression VisitJetConvertExpression(SqlUnaryExpression convertExpression)
{
var typeMapping = convertExpression.TypeMapping ?? throw new InvalidOperationException(
RelationalStrings.UnsupportedType(convertExpression.Type.ShortDisplayName()));
Expand Down
28 changes: 14 additions & 14 deletions src/EFCore.Jet/Scaffolding/Internal/JetDatabaseModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,20 +457,7 @@ private void GetIndexes(DbConnection connection, IReadOnlyList<DatabaseTable> ta
{
var isUnique = indexType == "UNIQUE";

if (isUnique)
{
var uniqueConstraint = new DatabaseUniqueConstraint
{
Table = table,
Name = indexName,
};

_logger.UniqueConstraintFound(indexName!, tableName!);

table.UniqueConstraints.Add(uniqueConstraint);
indexOrKey = uniqueConstraint;
}
else
if (!isUnique || (indexName?.StartsWith("ix_", StringComparison.CurrentCultureIgnoreCase) ?? false))
{
// In contrast to SQL Standard, MS Access will implicitly create an index for every FK
// constraint.
Expand Down Expand Up @@ -507,6 +494,19 @@ private void GetIndexes(DbConnection connection, IReadOnlyList<DatabaseTable> ta
table.Indexes.Add(index);
indexOrKey = index;
}
else
{
var uniqueConstraint = new DatabaseUniqueConstraint
{
Table = table,
Name = indexName,
};

_logger.UniqueConstraintFound(indexName!, tableName!);

table.UniqueConstraints.Add(uniqueConstraint);
indexOrKey = uniqueConstraint;
}
}

foreach (var indexColumn in indexColumns)
Expand Down
3 changes: 0 additions & 3 deletions src/EFCore.Jet/Storage/Internal/JetStringTypeMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ protected JetStringTypeMapping(RelationalTypeMappingParameters parameters, bool
protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
=> new JetStringTypeMapping(parameters, _keepLineBreakCharacters);

public RelationalTypeMapping Clone(bool keepLineBreakCharacters)
=> new JetStringTypeMapping(Parameters, keepLineBreakCharacters);

private static string GetStoreName(bool fixedLength)
=> fixedLength
? "char"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="17.14.8" />
<PackageReference Include="MSTest.TestFramework" />
<PackageReference Include="xunit.core" />
<PackageReference Include="xunit.assert" />
Expand Down Expand Up @@ -69,9 +70,6 @@
<None Include="..\xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="GraphUpdates\GraphUpdatesJetTest.cs" />
<None Include="GraphUpdates\ProxyGraphUpdatesJetTest.cs" />
<None Include="JetApiConsistencyTest.cs" />
<None Remove="TestResults\**" />
</ItemGroup>

Expand Down Expand Up @@ -101,9 +99,6 @@
</ItemGroup>

<ItemGroup>
<Compile Remove="GraphUpdates\GraphUpdatesJetTest.cs" />
<Compile Remove="GraphUpdates\ProxyGraphUpdatesJetTest.cs" />
<Compile Remove="JetApiConsistencyTest.cs" />
<Compile Remove="PropertyEntryJetTest.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
using System.Linq;

namespace EntityFrameworkCore.Jet.FunctionalTests;

#nullable disable

public class GraphUpdatesJetClientCascadeTest(GraphUpdatesJetClientCascadeTest.JetFixture fixture)
: GraphUpdatesJetTestBase<
GraphUpdatesJetClientCascadeTest.JetFixture>(fixture)
{
protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction)
=> facade.UseTransaction(transaction.GetDbTransaction());

public class JetFixture : GraphUpdatesJetFixtureBase
{
public override bool NoStoreCascades
=> true;

protected override string StoreName
=> "GraphClientCascadeUpdatesTest";

protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)
{
base.OnModelCreating(modelBuilder, context);

foreach (var foreignKey in modelBuilder.Model
.GetEntityTypes()
.SelectMany(e => e.GetDeclaredForeignKeys())
.Where(e => e.DeleteBehavior == DeleteBehavior.Cascade))
{
foreignKey.DeleteBehavior = DeleteBehavior.ClientCascade;
}
}
}
}
Loading