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

[automated] Merge branch 'release/8.0' => 'main' #31575

Merged
5 commits merged into from
Aug 28, 2023
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
52 changes: 26 additions & 26 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Configuration" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.Extensions.Configuration" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="Microsoft.Extensions.Logging" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.Extensions.Logging" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="System.Text.Json" Version="8.0.0-rc.1.23421.3">
<Dependency Name="System.Text.Json" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.NETCore.App.Runtime.win-x64" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
<!-- NB: Using BrowserDebugHost to represent the nonshipping version of Microsoft.NETCore.App -->
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="8.0.0-rc.1.23421.3">
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="8.0.0-rc.2.23426.4">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>f8c110b8003d68cc635add4ca791d6cf2e645561</Sha>
<Sha>4122c63a13cfe40e97ac1f9ef01d8110a66943f4</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
26 changes: 13 additions & 13 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
<UsingToolXliff>False</UsingToolXliff>
</PropertyGroup>
<PropertyGroup Label="Dependencies from dotnet/runtime">
<MicrosoftExtensionsCachingMemoryVersion>8.0.0-rc.1.23421.3</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsConfigurationVersion>8.0.0-rc.1.23421.3</MicrosoftExtensionsConfigurationVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>8.0.0-rc.1.23421.3</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>8.0.0-rc.1.23421.3</MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>
<MicrosoftExtensionsConfigurationJsonVersion>8.0.0-rc.1.23421.3</MicrosoftExtensionsConfigurationJsonVersion>
<MicrosoftExtensionsDependencyInjectionVersion>8.0.0-rc.1.23421.3</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsDependencyModelVersion>8.0.0-rc.1.23421.3</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftExtensionsHostFactoryResolverSourcesVersion>8.0.0-rc.1.23421.3</MicrosoftExtensionsHostFactoryResolverSourcesVersion>
<MicrosoftExtensionsLoggingVersion>8.0.0-rc.1.23421.3</MicrosoftExtensionsLoggingVersion>
<SystemTextJsonVersion>8.0.0-rc.1.23421.3</SystemTextJsonVersion>
<MicrosoftNETCoreAppRefVersion>8.0.0-rc.1.23421.3</MicrosoftNETCoreAppRefVersion>
<MicrosoftNETCoreAppRuntimewinx64Version>8.0.0-rc.1.23421.3</MicrosoftNETCoreAppRuntimewinx64Version>
<MicrosoftNETCoreBrowserDebugHostTransportVersion>8.0.0-rc.1.23421.3</MicrosoftNETCoreBrowserDebugHostTransportVersion>
<MicrosoftExtensionsCachingMemoryVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsCachingMemoryVersion>
<MicrosoftExtensionsConfigurationVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationEnvironmentVariablesVersion>
<MicrosoftExtensionsConfigurationJsonVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsConfigurationJsonVersion>
<MicrosoftExtensionsDependencyInjectionVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsDependencyModelVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsDependencyModelVersion>
<MicrosoftExtensionsHostFactoryResolverSourcesVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsHostFactoryResolverSourcesVersion>
<MicrosoftExtensionsLoggingVersion>8.0.0-rc.2.23426.4</MicrosoftExtensionsLoggingVersion>
<SystemTextJsonVersion>8.0.0-rc.2.23426.4</SystemTextJsonVersion>
<MicrosoftNETCoreAppRefVersion>8.0.0-rc.2.23426.4</MicrosoftNETCoreAppRefVersion>
<MicrosoftNETCoreAppRuntimewinx64Version>8.0.0-rc.2.23426.4</MicrosoftNETCoreAppRuntimewinx64Version>
<MicrosoftNETCoreBrowserDebugHostTransportVersion>8.0.0-rc.2.23426.4</MicrosoftNETCoreBrowserDebugHostTransportVersion>
</PropertyGroup>
<PropertyGroup Label="Dependencies from dotnet/arcade">
<MicrosoftDotNetBuildTasksTemplatingVersion>8.0.0-beta.23425.2</MicrosoftDotNetBuildTasksTemplatingVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,33 @@ public static bool Glob(this DbFunctions _, string matchExpression, string patte
public static string Hex(this DbFunctions _, byte[] bytes)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Hex)));

/// <summary>
/// Maps to the SQLite <c>unhex</c> function which returns a BLOB representing decoding of the hexadecimal string.
/// </summary>
/// <remarks>
/// See <see href="https://aka.ms/efcore-docs-database-functions">Database functions</see>, and
/// <see href="https://aka.ms/efcore-docs-sqlite">Accessing SQLite databases with EF Core</see> for more information and examples.
/// </remarks>
/// <param name="_">The <see cref="DbFunctions" /> instance.</param>
/// <param name="value">The hexadecimal string.</param>
/// <returns>Decoded hexadecimal string as binary value.</returns>
public static byte[] Unhex(this DbFunctions _, string value)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Unhex)));

/// <summary>
/// Maps to the SQLite <c>unhex</c> function which returns a BLOB representing decoding of the hexadecimal string.
/// </summary>
/// <remarks>
/// See <see href="https://aka.ms/efcore-docs-database-functions">Database functions</see>, and
/// <see href="https://aka.ms/efcore-docs-sqlite">Accessing SQLite databases with EF Core</see> for more information and examples.
/// </remarks>
/// <param name="_">The <see cref="DbFunctions" /> instance.</param>
/// <param name="value">The hexadecimal string.</param>
/// <param name="ignoreChars">Characters that are ignored in <paramref name="value"/>.</param>
/// <returns>Decoded hexadecimal string as binary value.</returns>
public static byte[] Unhex(this DbFunctions _, string value, string ignoreChars)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Unhex)));

/// <summary>
/// Maps to the SQLite <c>substr</c> function which returns a subarray of the specified value. The subarray starts
/// at <paramref name="startIndex" /> and continues to the end of the value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal;
/// </summary>
public class SqliteHexMethodTranslator : IMethodCallTranslator
{
private static readonly MethodInfo MethodInfo = typeof(SqliteDbFunctionsExtensions)
private static readonly MethodInfo HexMethodInfo = typeof(SqliteDbFunctionsExtensions)
.GetMethod(nameof(SqliteDbFunctionsExtensions.Hex), new[] { typeof(DbFunctions), typeof(byte[]) })!;

private static readonly MethodInfo UnhexMethodInfo = typeof(SqliteDbFunctionsExtensions)
.GetMethod(nameof(SqliteDbFunctionsExtensions.Unhex), new[] { typeof(DbFunctions), typeof(string) })!;

private static readonly MethodInfo UnhexWithIgnoreCharsMethodInfo = typeof(SqliteDbFunctionsExtensions)
.GetMethod(nameof(SqliteDbFunctionsExtensions.Unhex), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!;

private readonly ISqlExpressionFactory _sqlExpressionFactory;

/// <summary>
Expand All @@ -41,7 +47,7 @@ public SqliteHexMethodTranslator(ISqlExpressionFactory sqlExpressionFactory)
IReadOnlyList<SqlExpression> arguments,
IDiagnosticsLogger<DbLoggerCategory.Query> logger)
{
if (method.Equals(MethodInfo))
if (method.Equals(HexMethodInfo))
{
return _sqlExpressionFactory.Function(
"hex",
Expand All @@ -51,6 +57,17 @@ public SqliteHexMethodTranslator(ISqlExpressionFactory sqlExpressionFactory)
typeof(string));
}

if (method.Equals(UnhexMethodInfo)
|| method.Equals(UnhexWithIgnoreCharsMethodInfo))
{
return _sqlExpressionFactory.Function(
"unhex",
arguments.Skip(1),
nullable: true,
arguments.Skip(1).Select(_ => true).ToArray(),
typeof(byte[]));
}

return null;
}
}
40 changes: 40 additions & 0 deletions test/EFCore.Sqlite.FunctionalTests/BuiltInDataTypesSqliteTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,46 @@ SELECT hex("o"."Bytes")
Assert.Equal(expectedResults, results);
}

[ConditionalFact]
public virtual void Can_query_using_unhex_function()
{
using var context = CreateContext();

var results = context.Set<ObjectBackedDataTypes>()
.Select(e => EF.Functions.Unhex(EF.Functions.Hex(e.Bytes))).ToList();

AssertSql(
"""
SELECT unhex(hex("o"."Bytes"))
FROM "ObjectBackedDataTypes" AS "o"
""");

var expectedResults = context.Set<ObjectBackedDataTypes>().AsEnumerable()
.Select(e => e.Bytes).ToList();

Assert.Equal(expectedResults, results);
}

[ConditionalFact]
public virtual void Can_query_using_unhex_function_with_ignore_chars()
{
using var context = CreateContext();

var results = context.Set<ObjectBackedDataTypes>()
.Select(e => EF.Functions.Unhex(EF.Functions.Hex(e.Bytes) + "!?", "!?")).ToList();

AssertSql(
"""
SELECT unhex(COALESCE(hex("o"."Bytes"), '') || '!?', '!?')
FROM "ObjectBackedDataTypes" AS "o"
""");

var expectedResults = context.Set<ObjectBackedDataTypes>().AsEnumerable()
.Select(e => e.Bytes).ToList();

Assert.Equal(expectedResults, results);
}

[ConditionalFact]
public virtual void Can_query_using_substr_function()
{
Expand Down
Loading