diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41606ee86..0ed64c86b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,15 +29,12 @@ jobs: fail-fast: false matrix: dbVersion: - - 8.4.3-mysql - - 8.0.40-mysql - - 11.6.2-mariadb - - 11.5.2-mariadb - - 11.4.4-mariadb - - 11.3.2-mariadb - - 10.11.10-mariadb - - 10.6.20-mariadb - - 10.5.27-mariadb + - 8.4.7-mysql + - 8.0.44-mysql + - 11.8.5-mariadb + - 11.4.9-mariadb + - 10.11.15-mariadb + - 10.6.24-mariadb os: - ubuntu-latest - windows-latest diff --git a/Directory.Build.props b/Directory.Build.props index 1f44703b7..924a2f1cd 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -26,11 +26,11 @@ - net8.0 - net9.0 - net8.0 - net9.0 - net8.0 + net10.0 + net10.0 + net10.0 + net10.0 + net10.0 net8.0 diff --git a/Directory.Packages.props b/Directory.Packages.props index c4e17801f..48cc88d1e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,9 +1,9 @@ - - [9.0.0,9.0.999] + [10.0.0,10.0.999] @@ -12,49 +12,48 @@ - - + + - - + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - + - + - - - - + + + + - - - - - - + + + + + + \ No newline at end of file diff --git a/Version.props b/Version.props index 90e3fc0d5..3307575e4 100644 --- a/Version.props +++ b/Version.props @@ -10,8 +10,8 @@ We also used alpha/beta/silver release types in the past, but they mix poorly with the ones above when orderend according to SemVer2 rules. --> - 9.0.1 - servicing + 10.0.0 + preview 1 - + 10.0.0 diff --git a/dotnet-tools.json b/dotnet-tools.json index 305bdb11d..530896d9c 100644 --- a/dotnet-tools.json +++ b/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-ef": { - "version": "9.0.0", + "version": "10.0.0", "commands": [ "dotnet-ef" ] diff --git a/global.json b/global.json index db8627a23..7ca72cbbf 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "9.0.100", + "version": "10.0.100", "allowPrerelease": false, "rollForward": "latestFeature" } diff --git a/src/EFCore.MySql.Json.Microsoft/EFCore.MySql.Json.Microsoft.csproj b/src/EFCore.MySql.Json.Microsoft/EFCore.MySql.Json.Microsoft.csproj index 7ff6b5cc0..c602f5d3d 100644 --- a/src/EFCore.MySql.Json.Microsoft/EFCore.MySql.Json.Microsoft.csproj +++ b/src/EFCore.MySql.Json.Microsoft/EFCore.MySql.Json.Microsoft.csproj @@ -69,9 +69,7 @@ - - diff --git a/src/EFCore.MySql.Json.Newtonsoft/EFCore.MySql.Json.Newtonsoft.csproj b/src/EFCore.MySql.Json.Newtonsoft/EFCore.MySql.Json.Newtonsoft.csproj index cb6b6bdb9..68b7fe1e6 100644 --- a/src/EFCore.MySql.Json.Newtonsoft/EFCore.MySql.Json.Newtonsoft.csproj +++ b/src/EFCore.MySql.Json.Newtonsoft/EFCore.MySql.Json.Newtonsoft.csproj @@ -74,9 +74,7 @@ - - diff --git a/src/EFCore.MySql.NTS/EFCore.MySql.NTS.csproj b/src/EFCore.MySql.NTS/EFCore.MySql.NTS.csproj index 40ebaaa79..547a6c882 100644 --- a/src/EFCore.MySql.NTS/EFCore.MySql.NTS.csproj +++ b/src/EFCore.MySql.NTS/EFCore.MySql.NTS.csproj @@ -74,9 +74,7 @@ - - diff --git a/src/EFCore.MySql/EFCore.MySql.csproj b/src/EFCore.MySql/EFCore.MySql.csproj index cd3a740da..42ce7f185 100644 --- a/src/EFCore.MySql/EFCore.MySql.csproj +++ b/src/EFCore.MySql/EFCore.MySql.csproj @@ -48,9 +48,7 @@ - - diff --git a/src/EFCore.MySql/Extensions/MySqlDbContextOptionsBuilderExtensions.cs b/src/EFCore.MySql/Extensions/MySqlDbContextOptionsBuilderExtensions.cs index d19312176..b98a41202 100644 --- a/src/EFCore.MySql/Extensions/MySqlDbContextOptionsBuilderExtensions.cs +++ b/src/EFCore.MySql/Extensions/MySqlDbContextOptionsBuilderExtensions.cs @@ -62,7 +62,7 @@ public static DbContextOptionsBuilder UseMySql( ConfigureWarnings(optionsBuilder); var mySqlDbContextOptionsBuilder = new MySqlDbContextOptionsBuilder(optionsBuilder) - .TranslateParameterizedCollectionsToConstants(); + .UseParameterizedCollectionMode(ParameterTranslationMode.Constant); mySqlOptionsAction?.Invoke(mySqlDbContextOptionsBuilder); @@ -108,7 +108,7 @@ public static DbContextOptionsBuilder UseMySql( ConfigureWarnings(optionsBuilder); var mySqlDbContextOptionsBuilder = new MySqlDbContextOptionsBuilder(optionsBuilder) - .TranslateParameterizedCollectionsToConstants(); + .UseParameterizedCollectionMode(ParameterTranslationMode.Constant); mySqlOptionsAction?.Invoke(mySqlDbContextOptionsBuilder); @@ -158,7 +158,7 @@ public static DbContextOptionsBuilder UseMySql( ConfigureWarnings(optionsBuilder); var mySqlDbContextOptionsBuilder = new MySqlDbContextOptionsBuilder(optionsBuilder) - .TranslateParameterizedCollectionsToConstants(); + .UseParameterizedCollectionMode(ParameterTranslationMode.Constant); mySqlOptionsAction?.Invoke(mySqlDbContextOptionsBuilder); @@ -205,7 +205,7 @@ public static DbContextOptionsBuilder UseMySql( ConfigureWarnings(optionsBuilder); var mySqlDbContextOptionsBuilder = new MySqlDbContextOptionsBuilder(optionsBuilder) - .TranslateParameterizedCollectionsToConstants(); + .UseParameterizedCollectionMode(ParameterTranslationMode.Constant); mySqlOptionsAction?.Invoke(mySqlDbContextOptionsBuilder); diff --git a/src/EFCore.MySql/Query/ExpressionTranslators/Internal/MySqlStringComparisonMethodTranslator.cs b/src/EFCore.MySql/Query/ExpressionTranslators/Internal/MySqlStringComparisonMethodTranslator.cs index 346a7f5f0..ef2d14b58 100644 --- a/src/EFCore.MySql/Query/ExpressionTranslators/Internal/MySqlStringComparisonMethodTranslator.cs +++ b/src/EFCore.MySql/Query/ExpressionTranslators/Internal/MySqlStringComparisonMethodTranslator.cs @@ -524,8 +524,7 @@ protected virtual SqlExpression GetLikeExpressionUsingParameter( RelationalTypeMapping stringTypeMapping, StartsEndsWithContains methodType) { - if (pattern is SqlParameterExpression patternParameter && - patternParameter.Name.StartsWith(QueryCompilationContext.QueryParameterPrefix, StringComparison.Ordinal)) + if (pattern is SqlParameterExpression patternParameter) { // The pattern is a parameter, register a runtime parameter that will contain the rewritten LIKE pattern, where // all special characters have been escaped. @@ -718,7 +717,7 @@ private static string ConstructLikePatternParameter( QueryContext queryContext, string baseParameterName, StartsEndsWithContains methodType) - => queryContext.ParameterValues[baseParameterName] switch + => queryContext.Parameters[baseParameterName] switch { null => null, diff --git a/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlBoolOptimizingExpressionVisitor.cs b/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlBoolOptimizingExpressionVisitor.cs index d3a08bd9e..71e643208 100644 --- a/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlBoolOptimizingExpressionVisitor.cs +++ b/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlBoolOptimizingExpressionVisitor.cs @@ -541,6 +541,20 @@ protected override Expression VisitLeftJoin(LeftJoinExpression leftJoinExpressio return leftJoinExpression.Update(table, joinPredicate); } + protected override Expression VisitRightJoin(RightJoinExpression rightJoinExpression) + { + Check.NotNull(rightJoinExpression, nameof(rightJoinExpression)); + + var parentOptimize = _optimize; + _optimize = false; + var table = (TableExpressionBase)Visit(rightJoinExpression.Table); + _optimize = true; + var joinPredicate = (SqlExpression)Visit(rightJoinExpression.JoinPredicate); + _optimize = parentOptimize; + + return rightJoinExpression.Update(table, joinPredicate); + } + protected override Expression VisitRowValue(RowValueExpression rowValueExpression) { var parentOptimize = _optimize; diff --git a/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlNonWorkingHavingExpressionVisitor.cs b/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlNonWorkingHavingExpressionVisitor.cs index de79b96c9..a342cbe9c 100644 --- a/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlNonWorkingHavingExpressionVisitor.cs +++ b/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlNonWorkingHavingExpressionVisitor.cs @@ -1,6 +1,7 @@ // Copyright (c) Pomelo Foundation. All rights reserved. // Licensed under the MIT. See LICENSE in the project root for license information. +using System; using System.Linq; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; @@ -138,7 +139,7 @@ havingExpression is not SqlConstantExpression && if (!_containsAggregateFunctionExpressionVisitor.ProcessUntilSelect(havingExpression)) { var subquery = selectExpression.Clone(); - subquery.ReplaceProjection([]); + subquery.ReplaceProjection(Array.Empty()); var alias = "having"; var havingProjectionExpression = new ProjectionExpression(havingExpression, alias); diff --git a/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlParameterInliningExpressionVisitor.cs b/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlParameterInliningExpressionVisitor.cs index da9be518d..a22a6802d 100644 --- a/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlParameterInliningExpressionVisitor.cs +++ b/src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlParameterInliningExpressionVisitor.cs @@ -2,7 +2,6 @@ // Licensed under the MIT. See LICENSE in the project root for license information. using System; -using System.Collections.Generic; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; @@ -23,8 +22,7 @@ public class MySqlParameterInliningExpressionVisitor : ExpressionVisitor private readonly ISqlExpressionFactory _sqlExpressionFactory; private readonly IMySqlOptions _options; - private IReadOnlyDictionary _parametersValues; - private bool _canCache; + private ParametersCacheDecorator _parametersDecorator; private bool _shouldInlineParameters; @@ -38,19 +36,14 @@ public MySqlParameterInliningExpressionVisitor( _options = options; } - public virtual Expression Process(Expression expression, IReadOnlyDictionary parametersValues, out bool canCache) + public virtual Expression Process(Expression expression, ParametersCacheDecorator parametersDecorator) { Check.NotNull(expression, nameof(expression)); - _parametersValues = parametersValues; - _canCache = true; + _parametersDecorator = parametersDecorator; _shouldInlineParameters = false; - var result = Visit(expression); - - canCache = _canCache; - - return result; + return Visit(expression); } protected override Expression VisitExtension(Expression extensionExpression) @@ -103,12 +96,12 @@ protected virtual Expression VisitSqlParameter(SqlParameterExpression sqlParamet return sqlParameterExpression; } - _canCache = false; + var parametersValues = _parametersDecorator.GetAndDisableCaching(); return new MySqlInlinedParameterExpression( sqlParameterExpression, (SqlConstantExpression)_sqlExpressionFactory.Constant( - _parametersValues[sqlParameterExpression.Name], + parametersValues[sqlParameterExpression.Name], sqlParameterExpression.TypeMapping)); } diff --git a/src/EFCore.MySql/Query/Internal/MySqlParameterBasedSqlProcessor.cs b/src/EFCore.MySql/Query/Internal/MySqlParameterBasedSqlProcessor.cs index 4111be0d1..966f9d3e4 100644 --- a/src/EFCore.MySql/Query/Internal/MySqlParameterBasedSqlProcessor.cs +++ b/src/EFCore.MySql/Query/Internal/MySqlParameterBasedSqlProcessor.cs @@ -3,7 +3,6 @@ #nullable enable -using System.Collections.Generic; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Utilities; @@ -25,19 +24,14 @@ public MySqlParameterBasedSqlProcessor( _options = options; } - public override Expression Optimize( - Expression queryExpression, - IReadOnlyDictionary parametersValues, - out bool canCache) + public override Expression Process(Expression queryExpression, ParametersCacheDecorator parametersDecorator) { - queryExpression = base.Optimize(queryExpression, parametersValues, out canCache); + queryExpression = base.Process(queryExpression, parametersDecorator); if (_options.ServerVersion.Supports.MySqlBugLimit0Offset0ExistsWorkaround) { queryExpression = new SkipTakeCollapsingExpressionVisitor(Dependencies.SqlExpressionFactory) - .Process(queryExpression, parametersValues, out var canCache2); - - canCache &= canCache2; + .Process(queryExpression, parametersDecorator); } if (_options.IndexOptimizedBooleanColumns) @@ -49,9 +43,7 @@ public override Expression Optimize( queryExpression = new MySqlParameterInliningExpressionVisitor( Dependencies.TypeMappingSource, Dependencies.SqlExpressionFactory, - _options).Process(queryExpression, parametersValues, out var canCache3); - - canCache &= canCache3; + _options).Process(queryExpression, parametersDecorator); // Run the compatibility checks as late in the query pipeline (before the actual SQL translation happens) as reasonable. queryExpression = new MySqlCompatibilityExpressionVisitor(_options).Visit(queryExpression); @@ -62,14 +54,13 @@ public override Expression Optimize( /// protected override Expression ProcessSqlNullability( Expression queryExpression, - IReadOnlyDictionary parametersValues, - out bool canCache) + ParametersCacheDecorator parametersDecorator) { Check.NotNull(queryExpression, nameof(queryExpression)); - Check.NotNull(parametersValues, nameof(parametersValues)); + Check.NotNull(parametersDecorator, nameof(parametersDecorator)); queryExpression = new MySqlSqlNullabilityProcessor(Dependencies, Parameters) - .Process(queryExpression, parametersValues, out canCache); + .Process(queryExpression, parametersDecorator); return queryExpression; } diff --git a/src/EFCore.MySql/Query/Internal/MySqlQueryCompilationContext.cs b/src/EFCore.MySql/Query/Internal/MySqlQueryCompilationContext.cs index f22945f5a..bddb98525 100644 --- a/src/EFCore.MySql/Query/Internal/MySqlQueryCompilationContext.cs +++ b/src/EFCore.MySql/Query/Internal/MySqlQueryCompilationContext.cs @@ -21,9 +21,8 @@ public MySqlQueryCompilationContext( [NotNull] QueryCompilationContextDependencies dependencies, [NotNull] RelationalQueryCompilationContextDependencies relationalDependencies, bool async, - bool precompiling, - IReadOnlySet nonNullableReferenceTypeParameters) - : base(dependencies, relationalDependencies, async, precompiling, nonNullableReferenceTypeParameters) + bool precompiling) + : base(dependencies, relationalDependencies, async, precompiling) { } diff --git a/src/EFCore.MySql/Query/Internal/MySqlQueryCompilationContextFactory.cs b/src/EFCore.MySql/Query/Internal/MySqlQueryCompilationContextFactory.cs index 1b61b17f7..81f1c7b79 100644 --- a/src/EFCore.MySql/Query/Internal/MySqlQueryCompilationContextFactory.cs +++ b/src/EFCore.MySql/Query/Internal/MySqlQueryCompilationContextFactory.cs @@ -27,8 +27,8 @@ public MySqlQueryCompilationContextFactory( public virtual QueryCompilationContext Create(bool async) => new MySqlQueryCompilationContext(_dependencies, _relationalDependencies, async); - public virtual QueryCompilationContext CreatePrecompiled(bool async, IReadOnlySet nonNullableReferenceTypeParameters) + public virtual QueryCompilationContext CreatePrecompiled(bool async) => new MySqlQueryCompilationContext( - _dependencies, _relationalDependencies, async, precompiling: true, nonNullableReferenceTypeParameters); + _dependencies, _relationalDependencies, async, precompiling: true); } } diff --git a/src/EFCore.MySql/Query/Internal/MySqlQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.MySql/Query/Internal/MySqlQueryableMethodTranslatingExpressionVisitor.cs index 789df5247..15c409d30 100644 --- a/src/EFCore.MySql/Query/Internal/MySqlQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.MySql/Query/Internal/MySqlQueryableMethodTranslatingExpressionVisitor.cs @@ -80,39 +80,17 @@ bool IsJsonEachKeyColumn(SelectExpression selectExpression, ColumnExpression ord && IsJsonEachKeyColumn(subquery, projectedColumn))); } - protected override bool IsValidSelectExpressionForExecuteDelete( - SelectExpression selectExpression, - StructuralTypeShaperExpression shaper, - [NotNullWhen(true)] out TableExpression tableExpression) - { - if (selectExpression.Offset == null - && selectExpression.GroupBy.Count == 0 - && selectExpression.Having == null - && (selectExpression.Tables.Count == 1 || selectExpression.Orderings.Count == 0)) - { - TableExpressionBase table; - if (selectExpression.Tables.Count == 1) - { - table = selectExpression.Tables[0]; - } - else - { - var projectionBindingExpression = (ProjectionBindingExpression)shaper.ValueBufferExpression; - var entityProjectionExpression = (StructuralTypeProjectionExpression)selectExpression.GetProjection(projectionBindingExpression); - var column = entityProjectionExpression.BindProperty(shaper.StructuralType.GetProperties().First()); - table = selectExpression.GetTable(column).UnwrapJoin(); - } - - if (table is TableExpression te) - { - tableExpression = te; - return true; - } - } - - tableExpression = null; - return false; - } + protected override bool IsValidSelectExpressionForExecuteDelete(SelectExpression selectExpression) + => selectExpression is + { + Orderings: [], + Offset: null, + Limit: null, + GroupBy: [], + Having: null + } && + selectExpression.Tables[0] is TableExpression && + selectExpression.Tables.Skip(1).All(t => t is InnerJoinExpression); protected override bool IsValidSelectExpressionForExecuteUpdate( SelectExpression selectExpression, diff --git a/src/EFCore.MySql/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs b/src/EFCore.MySql/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs index 4ec971bb3..7bca50546 100644 --- a/src/EFCore.MySql/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs +++ b/src/EFCore.MySql/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs @@ -15,33 +15,26 @@ public class SkipTakeCollapsingExpressionVisitor : ExpressionVisitor { private readonly ISqlExpressionFactory _sqlExpressionFactory; - private IReadOnlyDictionary _parameterValues; - private bool _canCache; + private ParametersCacheDecorator _parametersDecorator; public SkipTakeCollapsingExpressionVisitor(ISqlExpressionFactory sqlExpressionFactory) { Check.NotNull(sqlExpressionFactory, nameof(sqlExpressionFactory)); _sqlExpressionFactory = sqlExpressionFactory; - _parameterValues = null!; + _parametersDecorator = null!; } public virtual Expression Process( Expression selectExpression, - IReadOnlyDictionary parametersValues, - out bool canCache) + ParametersCacheDecorator parametersDecorator) { Check.NotNull(selectExpression, nameof(selectExpression)); - Check.NotNull(parametersValues, nameof(parametersValues)); + Check.NotNull(parametersDecorator, nameof(parametersDecorator)); - _parameterValues = parametersValues; - _canCache = true; + _parametersDecorator = parametersDecorator; - var result = Visit(selectExpression); - - canCache = _canCache; - - return result; + return Visit(selectExpression); } protected override Expression VisitExtension(Expression extensionExpression) @@ -74,8 +67,8 @@ bool IsZero(SqlExpression? sqlExpression) when constant.Value is int intValue: return intValue == 0; case SqlParameterExpression parameter: - _canCache = false; - return _parameterValues[parameter.Name] is int value && value == 0; + var parameterValues = _parametersDecorator.GetAndDisableCaching(); + return parameterValues[parameter.Name] is int value && value == 0; default: return false; diff --git a/src/Shared/Check.cs b/src/Shared/Check.cs index 9e460f141..f50eb586d 100644 --- a/src/Shared/Check.cs +++ b/src/Shared/Check.cs @@ -1,149 +1,171 @@ // Copyright (c) Pomelo Foundation. All rights reserved. // Licensed under the MIT. See LICENSE in the project root for license information. +#nullable enable + using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; -using CA = System.Diagnostics.CodeAnalysis; -namespace Microsoft.EntityFrameworkCore.Utilities +namespace Microsoft.EntityFrameworkCore.Utilities; + +[DebuggerStepThrough] +internal static class Check { - [DebuggerStepThrough] - internal static class Check + [ContractAnnotation("value:null => halt")] + [return: System.Diagnostics.CodeAnalysis.NotNull] + public static T NotNull( + [NoEnumeration, AllowNull, System.Diagnostics.CodeAnalysis.NotNull] T value, + [InvokerParameterName, CallerArgumentExpression(nameof(value))] string parameterName = "") { - [ContractAnnotation("value:null => halt")] - public static T NotNull([NoEnumeration] T value, [InvokerParameterName] [NotNull] string parameterName) + if (value is null) { -#pragma warning disable IDE0041 // Use 'is null' check - if (ReferenceEquals(value, null)) -#pragma warning restore IDE0041 // Use 'is null' check - { - NotEmpty(parameterName, nameof(parameterName)); + ThrowArgumentNull(parameterName); + } - throw new ArgumentNullException(parameterName); - } + return value; + } - return value; - } + [ContractAnnotation("value:null => halt")] + public static IReadOnlyList NotEmpty( + [System.Diagnostics.CodeAnalysis.NotNull] IReadOnlyList? value, + [InvokerParameterName, CallerArgumentExpression(nameof(value))] string parameterName = "") + { + NotNull(value, parameterName); - [ContractAnnotation("value:null => halt")] - public static IReadOnlyList NotEmpty(IReadOnlyList value, [InvokerParameterName] [NotNull] string parameterName) + if (value.Count == 0) { - NotNull(value, parameterName); + ThrowNotEmpty(parameterName); + } - if (value.Count == 0) - { - NotEmpty(parameterName, nameof(parameterName)); + return value; + } - throw new ArgumentException(AbstractionsStrings.CollectionArgumentIsEmpty(parameterName)); - } + [ContractAnnotation("value:null => halt")] + public static string NotEmpty( + [System.Diagnostics.CodeAnalysis.NotNull] string? value, + [InvokerParameterName, CallerArgumentExpression(nameof(value))] string parameterName = "") + { + NotNull(value, parameterName); - return value; + if (value.AsSpan().Trim().Length == 0) + { + ThrowStringArgumentEmpty(parameterName); } - [ContractAnnotation("value:null => halt")] - public static string NotEmpty(string value, [InvokerParameterName] [NotNull] string parameterName) - { - Exception e = null; - if (value is null) - { - e = new ArgumentNullException(parameterName); - } - else if (value.Trim().Length == 0) - { - e = new ArgumentException(AbstractionsStrings.ArgumentIsEmpty(parameterName)); - } + return value; + } - if (e != null) - { - NotEmpty(parameterName, nameof(parameterName)); + public static string? NullButNotEmpty( + string? value, + [InvokerParameterName, CallerArgumentExpression(nameof(value))] string parameterName = "") + { + if (value is not null && value.Length == 0) + { + ThrowStringArgumentEmpty(parameterName); + } - throw e; - } + return value; + } - return value; - } + public static IReadOnlyList HasNoNulls( + [System.Diagnostics.CodeAnalysis.NotNull] IReadOnlyList? value, + [InvokerParameterName, CallerArgumentExpression(nameof(value))] string parameterName = "") + where T : class + { + NotNull(value, parameterName); - public static string NullButNotEmpty(string value, [InvokerParameterName] [NotNull] string parameterName) + // ReSharper disable once ForCanBeConvertedToForeach + for (var i = 0; i < value.Count; i++) { - if (!(value is null) - && value.Length == 0) + if (value[i] is null) { - NotEmpty(parameterName, nameof(parameterName)); - - throw new ArgumentException(AbstractionsStrings.ArgumentIsEmpty(parameterName)); + ThrowArgumentException(parameterName, parameterName); } - - return value; } - public static IReadOnlyList HasNoNulls(IReadOnlyList value, [InvokerParameterName] [NotNull] string parameterName) - where T : class - { - NotNull(value, parameterName); - - if (value.Any(e => e == null)) - { - NotEmpty(parameterName, nameof(parameterName)); - - throw new ArgumentException(parameterName); - } + return value; + } - return value; - } + public static IReadOnlyList HasNoEmptyElements( + [System.Diagnostics.CodeAnalysis.NotNull] IReadOnlyList? value, + [InvokerParameterName, CallerArgumentExpression(nameof(value))] string parameterName = "") + { + NotNull(value, parameterName); - public static IReadOnlyList HasNoEmptyElements( - IReadOnlyList value, - [InvokerParameterName] [NotNull] string parameterName) + for (var i = 0; i < value.Count; i++) { - NotNull(value, parameterName); - - if (value.Any(s => string.IsNullOrWhiteSpace(s))) + if (string.IsNullOrWhiteSpace(value[i])) { - NotEmpty(parameterName, nameof(parameterName)); - - throw new ArgumentException(AbstractionsStrings.CollectionArgumentHasEmptyElements(parameterName)); + ThrowCollectionHasEmptyElements(parameterName); } - - return value; } - public static TEnum? EnumValue( - TEnum? value, - [InvokerParameterName] [NotNull] string parameterName) - where TEnum : struct - { - NotNull(value, parameterName); + return value; + } - return NullOrEnumValue(value, parameterName); - } + public static TEnum? EnumValue( + TEnum? value, + [InvokerParameterName] string parameterName) + where TEnum : struct + { + NotNull(value, parameterName); - public static TEnum? NullOrEnumValue( - TEnum? value, - [InvokerParameterName] [NotNull] string parameterName) - where TEnum : struct + return NullOrEnumValue(value, parameterName); + } + + public static TEnum? NullOrEnumValue( + TEnum? value, + [InvokerParameterName] string parameterName) + where TEnum : struct + { + if (value is not null) { - if (value is not null) + if (!Enum.IsDefined(typeof(TEnum), value)) { - if (!Enum.IsDefined(typeof(TEnum), value)) - { - throw new ArgumentOutOfRangeException(parameterName, value, null); - } + throw new ArgumentOutOfRangeException(parameterName, value, null); } - - return value; } - [Conditional("DEBUG")] - public static void DebugAssert([CA.DoesNotReturnIfAttribute(false)] bool condition, string message) + return value; + } + + [Conditional("DEBUG")] + public static void DebugAssert( + [DoesNotReturnIf(false)] bool condition, + [CallerArgumentExpression(nameof(condition))] string message = "") + { + if (!condition) { - if (!condition) - { - throw new Exception($"Check.DebugAssert failed: {message}"); - } + throw new UnreachableException($"Check.DebugAssert failed: {message}"); } } + + [Conditional("DEBUG"), DoesNotReturn] + public static void DebugFail(string message) + => throw new UnreachableException($"Check.DebugFail failed: {message}"); + + [DoesNotReturn] + private static void ThrowArgumentNull(string parameterName) + => throw new ArgumentNullException(parameterName); + + [DoesNotReturn] + private static void ThrowNotEmpty(string parameterName) + => throw new ArgumentException(AbstractionsStrings.CollectionArgumentIsEmpty, parameterName); + + [DoesNotReturn] + private static void ThrowStringArgumentEmpty(string parameterName) + => throw new ArgumentException(AbstractionsStrings.ArgumentIsEmpty, parameterName); + + [DoesNotReturn] + private static void ThrowCollectionHasEmptyElements(string parameterName) + => throw new ArgumentException(AbstractionsStrings.CollectionArgumentHasEmptyElements, parameterName); + + [DoesNotReturn] + private static void ThrowArgumentException(string message, string parameterName) + => throw new ArgumentException(message, parameterName); } diff --git a/test/EFCore.MySql.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesMySqlTest.cs deleted file mode 100644 index b399cb473..000000000 --- a/test/EFCore.MySql.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesMySqlTest.cs +++ /dev/null @@ -1,330 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.BulkUpdates; -using Microsoft.EntityFrameworkCore.TestUtilities; -using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; -using Xunit; -using Xunit.Abstractions; - -namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.BulkUpdates; - -public class ComplexTypeBulkUpdatesMySqlTest : ComplexTypeBulkUpdatesRelationalTestBase< - ComplexTypeBulkUpdatesMySqlTest.ComplexTypeBulkUpdatesMySqlFixture> -{ - public ComplexTypeBulkUpdatesMySqlTest(ComplexTypeBulkUpdatesMySqlFixture fixture, ITestOutputHelper testOutputHelper) - : base(fixture, testOutputHelper) - { - } - - public override async Task Delete_entity_type_with_complex_type(bool async) - { - await base.Delete_entity_type_with_complex_type(async); - - AssertSql( -""" -DELETE `c` -FROM `Customer` AS `c` -WHERE `c`.`Name` = 'Monty Elias' -"""); - } - - public override async Task Delete_complex_type(bool async) - { - await base.Delete_complex_type(async); - - AssertSql(); - } - - public override async Task Update_property_inside_complex_type(bool async) - { - await base.Update_property_inside_complex_type(async); - - AssertExecuteUpdateSql( -""" -UPDATE `Customer` AS `c` -SET `c`.`ShippingAddress_ZipCode` = 12345 -WHERE `c`.`ShippingAddress_ZipCode` = 7728 -"""); - } - - public override async Task Update_property_inside_nested_complex_type(bool async) - { - await base.Update_property_inside_nested_complex_type(async); - - AssertExecuteUpdateSql( -""" -UPDATE `Customer` AS `c` -SET `c`.`ShippingAddress_Country_FullName` = 'United States Modified' -WHERE `c`.`ShippingAddress_Country_Code` = 'US' -"""); - } - - public override async Task Update_multiple_properties_inside_multiple_complex_types_and_on_entity_type(bool async) - { - await base.Update_multiple_properties_inside_multiple_complex_types_and_on_entity_type(async); - - AssertExecuteUpdateSql( -""" -UPDATE `Customer` AS `c` -SET `c`.`BillingAddress_ZipCode` = 54321, - `c`.`ShippingAddress_ZipCode` = `c`.`BillingAddress_ZipCode`, - `c`.`Name` = CONCAT(`c`.`Name`, 'Modified') -WHERE `c`.`ShippingAddress_ZipCode` = 7728 -"""); - } - - public override async Task Update_projected_complex_type(bool async) - { - await base.Update_projected_complex_type(async); - - AssertExecuteUpdateSql( -""" -UPDATE `Customer` AS `c` -SET `c`.`ShippingAddress_ZipCode` = 12345 -"""); - } - - public override async Task Update_multiple_projected_complex_types_via_anonymous_type(bool async) - { - await base.Update_multiple_projected_complex_types_via_anonymous_type(async); - - AssertExecuteUpdateSql( -""" -UPDATE `Customer` AS `c` -SET `c`.`BillingAddress_ZipCode` = 54321, - `c`.`ShippingAddress_ZipCode` = `c`.`BillingAddress_ZipCode` -"""); - } - - public override async Task Update_projected_complex_type_via_OrderBy_Skip(bool async) - { - await base.Update_projected_complex_type_via_OrderBy_Skip(async); - - AssertExecuteUpdateSql(); - } - - public override async Task Update_complex_type_to_parameter(bool async) - { - await base.Update_complex_type_to_parameter(async); - - AssertSql( -""" -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -""", - // - """ -@__complex_type_newAddress_0_AddressLine1='New AddressLine1' (Size = 4000) -@__complex_type_newAddress_0_AddressLine2='New AddressLine2' (Size = 4000) -@__complex_type_newAddress_0_Tags='["new_tag1","new_tag2"]' (Size = 4000) -@__complex_type_newAddress_0_ZipCode='99999' (Nullable = true) -@__complex_type_newAddress_0_Code='FR' (Size = 4000) -@__complex_type_newAddress_0_FullName='France' (Size = 4000) - -UPDATE `Customer` AS `c` -SET `c`.`ShippingAddress_AddressLine1` = @__complex_type_newAddress_0_AddressLine1, - `c`.`ShippingAddress_AddressLine2` = @__complex_type_newAddress_0_AddressLine2, - `c`.`ShippingAddress_Tags` = @__complex_type_newAddress_0_Tags, - `c`.`ShippingAddress_ZipCode` = @__complex_type_newAddress_0_ZipCode, - `c`.`ShippingAddress_Country_Code` = @__complex_type_newAddress_0_Code, - `c`.`ShippingAddress_Country_FullName` = @__complex_type_newAddress_0_FullName -""", - // - """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -"""); - } - - public override async Task Update_nested_complex_type_to_parameter(bool async) - { - await base.Update_nested_complex_type_to_parameter(async); - - AssertSql( -""" -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -""", - // - """ -@__complex_type_newCountry_0_Code='FR' (Size = 4000) -@__complex_type_newCountry_0_FullName='France' (Size = 4000) - -UPDATE `Customer` AS `c` -SET `c`.`ShippingAddress_Country_Code` = @__complex_type_newCountry_0_Code, - `c`.`ShippingAddress_Country_FullName` = @__complex_type_newCountry_0_FullName -""", - // - """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -"""); - } - - public override async Task Update_complex_type_to_another_database_complex_type(bool async) - { - await base.Update_complex_type_to_another_database_complex_type(async); - - AssertSql( -""" -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -""", - // - """ -UPDATE `Customer` AS `c` -SET `c`.`ShippingAddress_AddressLine1` = `c`.`BillingAddress_AddressLine1`, - `c`.`ShippingAddress_AddressLine2` = `c`.`BillingAddress_AddressLine2`, - `c`.`ShippingAddress_Tags` = `c`.`BillingAddress_Tags`, - `c`.`ShippingAddress_ZipCode` = `c`.`BillingAddress_ZipCode`, - `c`.`ShippingAddress_Country_Code` = `c`.`ShippingAddress_Country_Code`, - `c`.`ShippingAddress_Country_FullName` = `c`.`ShippingAddress_Country_FullName` -""", - // - """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -"""); - } - - public override async Task Update_complex_type_to_inline_without_lambda(bool async) - { - await base.Update_complex_type_to_inline_without_lambda(async); - - AssertSql( -""" -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -""", - // - """ -UPDATE `Customer` AS `c` -SET `c`.`ShippingAddress_AddressLine1` = 'New AddressLine1', - `c`.`ShippingAddress_AddressLine2` = 'New AddressLine2', - `c`.`ShippingAddress_Tags` = '["new_tag1","new_tag2"]', - `c`.`ShippingAddress_ZipCode` = 99999, - `c`.`ShippingAddress_Country_Code` = 'FR', - `c`.`ShippingAddress_Country_FullName` = 'France' -""", - // - """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -"""); - } - - public override async Task Update_complex_type_to_inline_with_lambda(bool async) - { - await base.Update_complex_type_to_inline_with_lambda(async); - - AssertSql( -""" -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -""", - // - """ -UPDATE `Customer` AS `c` -SET `c`.`ShippingAddress_AddressLine1` = 'New AddressLine1', - `c`.`ShippingAddress_AddressLine2` = 'New AddressLine2', - `c`.`ShippingAddress_Tags` = '["new_tag1","new_tag2"]', - `c`.`ShippingAddress_ZipCode` = 99999, - `c`.`ShippingAddress_Country_Code` = 'FR', - `c`.`ShippingAddress_Country_FullName` = 'France' -""", - // - """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -"""); - } - - public override async Task Update_complex_type_to_another_database_complex_type_with_subquery(bool async) - { - await base.Update_complex_type_to_another_database_complex_type_with_subquery(async); - - AssertSql( -""" -@__p_0='1' - -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -ORDER BY `c`.`Id` -LIMIT 18446744073709551610 OFFSET @__p_0 -""", - // - """ -@__p_0='1' - -UPDATE `Customer` AS `c0` -INNER JOIN ( - SELECT `c`.`Id`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` - FROM `Customer` AS `c` - ORDER BY `c`.`Id` - LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `c1` ON `c0`.`Id` = `c1`.`Id` -SET `c0`.`ShippingAddress_AddressLine1` = `c1`.`BillingAddress_AddressLine1`, - `c0`.`ShippingAddress_AddressLine2` = `c1`.`BillingAddress_AddressLine2`, - `c0`.`ShippingAddress_Tags` = `c1`.`BillingAddress_Tags`, - `c0`.`ShippingAddress_ZipCode` = `c1`.`BillingAddress_ZipCode`, - `c0`.`ShippingAddress_Country_Code` = `c1`.`ShippingAddress_Country_Code`, - `c0`.`ShippingAddress_Country_FullName` = `c1`.`ShippingAddress_Country_FullName` -""", - // - """ -@__p_0='1' - -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -ORDER BY `c`.`Id` -LIMIT 18446744073709551610 OFFSET @__p_0 -"""); - } - - public override async Task Update_collection_inside_complex_type(bool async) - { - await base.Update_collection_inside_complex_type(async); - - AssertSql( -""" -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -""", - // - """ -UPDATE `Customer` AS `c` -SET `c`.`ShippingAddress_Tags` = '["new_tag1","new_tag2"]' -""", - // - """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -"""); - } - - [ConditionalFact] - public virtual void Check_all_tests_overridden() - { - MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); - } - - private void AssertExecuteUpdateSql(params string[] expected) - { - Fixture.TestSqlLoggerFactory.AssertBaseline(expected, forUpdate: true); - } - - private void AssertSql(params string[] expected) - { - Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - } - - protected void ClearLog() - { - Fixture.TestSqlLoggerFactory.Clear(); - } - - public class ComplexTypeBulkUpdatesMySqlFixture : ComplexTypeBulkUpdatesRelationalFixtureBase - { - protected override ITestStoreFactory TestStoreFactory - => MySqlTestStoreFactory.Instance; - } -} diff --git a/test/EFCore.MySql.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesMySqlTest.cs index d11cd5bf4..771b3b41e 100644 --- a/test/EFCore.MySql.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesMySqlTest.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.BulkUpdates; using Microsoft.EntityFrameworkCore.TestUtilities; using MySqlConnector; @@ -9,6 +10,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.BulkUpdates; public class NonSharedModelBulkUpdatesMySqlTest : NonSharedModelBulkUpdatesRelationalTestBase { + public NonSharedModelBulkUpdatesMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; @@ -64,8 +70,10 @@ public override async Task Update_non_owned_property_on_entity_with_owned(bool a AssertSql( """ +@p='SomeValue' (Size = 4000) + UPDATE `Owner` AS `o` -SET `o`.`Title` = 'SomeValue' +SET `o`.`Title` = @p """); } @@ -87,8 +95,8 @@ public override async Task Update_owned_and_non_owned_properties_with_table_shar AssertSql( """ UPDATE `Owner` AS `o` -SET `o`.`OwnedReference_Number` = CHAR_LENGTH(`o`.`Title`), - `o`.`Title` = COALESCE(CAST(`o`.`OwnedReference_Number` AS char), '') +SET `o`.`Title` = COALESCE(CAST(`o`.`OwnedReference_Number` AS char), ''), + `o`.`OwnedReference_Number` = CHAR_LENGTH(`o`.`Title`) """); } @@ -111,8 +119,8 @@ public override async Task Update_non_main_table_in_entity_with_entity_splitting """ UPDATE `Blogs` AS `b` INNER JOIN `BlogsPart1` AS `b0` ON `b`.`Id` = `b0`.`Id` -SET `b0`.`Rating` = CHAR_LENGTH(`b0`.`Title`), - `b0`.`Title` = CAST(`b0`.`Rating` AS char) +SET `b0`.`Title` = CAST(`b0`.`Rating` AS char), + `b0`.`Rating` = CHAR_LENGTH(`b0`.`Title`) """); } @@ -152,9 +160,11 @@ public override async Task Update_non_owned_property_on_entity_with_owned_in_joi AssertSql( """ +@p='NewValue' (Size = 4000) + UPDATE `Owner` AS `o` INNER JOIN `Owner` AS `o0` ON `o`.`Id` = `o0`.`Id` -SET `o`.`Title` = 'NewValue' +SET `o`.`Title` = @p """); } @@ -164,9 +174,11 @@ public override async Task Replace_ColumnExpression_in_column_setter(bool async) AssertSql( """ +@p='SomeValue' (Size = 4000) + UPDATE `Owner` AS `o` INNER JOIN `OwnedCollection` AS `o0` ON `o`.`Id` = `o0`.`OwnerId` -SET `o0`.`Value` = 'SomeValue' +SET `o0`.`Value` = @p """); } diff --git a/test/EFCore.MySql.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesMySqlTest.cs index 6dbd2725f..18ad49cda 100644 --- a/test/EFCore.MySql.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesMySqlTest.cs @@ -60,11 +60,11 @@ public override async Task Delete_Where_parameter(bool async) AssertSql( """ -@__quantity_0='1' (Nullable = true) (DbType = Int16) +@quantity='1' (Nullable = true) (DbType = Int16) DELETE `o` FROM `Order Details` AS `o` -WHERE `o`.`Quantity` = @__quantity_0 +WHERE `o`.`Quantity` = @quantity """, // """ @@ -93,7 +93,7 @@ public override async Task Delete_Where_OrderBy_Skip(bool async) AssertSql( """ -@__p_0='100' +@p='100' DELETE `o` FROM `Order Details` AS `o` @@ -104,7 +104,7 @@ SELECT 1 FROM `Order Details` AS `o0` WHERE `o0`.`OrderID` < 10300 ORDER BY `o0`.`OrderID` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `o1` WHERE (`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`)) """); @@ -116,13 +116,20 @@ public override async Task Delete_Where_OrderBy_Take(bool async) AssertSql( """ -@__p_0='100' +@p='100' -DELETE -FROM `Order Details` -WHERE `OrderID` < 10300 -ORDER BY `OrderID` -LIMIT @__p_0 +DELETE `o` +FROM `Order Details` AS `o` +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT `o0`.`OrderID`, `o0`.`ProductID` + FROM `Order Details` AS `o0` + WHERE `o0`.`OrderID` < 10300 + ORDER BY `o0`.`OrderID` + LIMIT @p + ) AS `o1` + WHERE (`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`)) """); } @@ -132,7 +139,7 @@ public override async Task Delete_Where_OrderBy_Skip_Take(bool async) AssertSql( """ -@__p_0='100' +@p='100' DELETE `o` FROM `Order Details` AS `o` @@ -143,7 +150,7 @@ SELECT 1 FROM `Order Details` AS `o0` WHERE `o0`.`OrderID` < 10300 ORDER BY `o0`.`OrderID` - LIMIT @__p_0 OFFSET @__p_0 + LIMIT @p OFFSET @p ) AS `o1` WHERE (`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`)) """); @@ -155,7 +162,7 @@ public override async Task Delete_Where_Skip(bool async) AssertSql( """ -@__p_0='100' +@p='100' DELETE `o` FROM `Order Details` AS `o` @@ -165,7 +172,7 @@ SELECT 1 SELECT `o0`.`OrderID`, `o0`.`ProductID` FROM `Order Details` AS `o0` WHERE `o0`.`OrderID` < 10300 - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `o1` WHERE (`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`)) """); @@ -177,12 +184,19 @@ public override async Task Delete_Where_Take(bool async) AssertSql( """ -@__p_0='100' +@p='100' -DELETE -FROM `Order Details` -WHERE `OrderID` < 10300 -LIMIT @__p_0 +DELETE `o` +FROM `Order Details` AS `o` +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT `o0`.`OrderID`, `o0`.`ProductID` + FROM `Order Details` AS `o0` + WHERE `o0`.`OrderID` < 10300 + LIMIT @p + ) AS `o1` + WHERE (`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`)) """); } @@ -192,7 +206,7 @@ public override async Task Delete_Where_Skip_Take(bool async) AssertSql( """ -@__p_0='100' +@p='100' DELETE `o` FROM `Order Details` AS `o` @@ -202,7 +216,7 @@ SELECT 1 SELECT `o0`.`OrderID`, `o0`.`ProductID` FROM `Order Details` AS `o0` WHERE `o0`.`OrderID` < 10300 - LIMIT @__p_0 OFFSET @__p_0 + LIMIT @p OFFSET @p ) AS `o1` WHERE (`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`)) """); @@ -271,9 +285,9 @@ public override async Task Delete_Where_Skip_Take_Skip_Take_causing_subquery(boo AssertSql( """ -@__p_0='100' -@__p_2='5' -@__p_1='20' +@p='100' +@p2='5' +@p1='20' DELETE `o` FROM `Order Details` AS `o` @@ -285,9 +299,9 @@ SELECT 1 SELECT `o1`.`OrderID`, `o1`.`ProductID` FROM `Order Details` AS `o1` WHERE `o1`.`OrderID` < 10300 - LIMIT @__p_0 OFFSET @__p_0 + LIMIT @p OFFSET @p ) AS `o0` - LIMIT @__p_2 OFFSET @__p_1 + LIMIT @p2 OFFSET @p1 ) AS `o2` WHERE (`o2`.`OrderID` = `o`.`OrderID`) AND (`o2`.`ProductID` = `o`.`ProductID`)) """); @@ -515,8 +529,8 @@ public override async Task Delete_with_join(bool async) AssertSql( """ -@__p_1='100' -@__p_0='0' +@p0='100' +@p='0' DELETE `o` FROM `Order Details` AS `o` @@ -525,14 +539,14 @@ INNER JOIN ( FROM `Orders` AS `o0` WHERE `o0`.`OrderID` < 10300 ORDER BY `o0`.`OrderID` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `o1` ON `o`.`OrderID` = `o1`.`OrderID` """); } - public override async Task Delete_with_left_join(bool async) + public override async Task Delete_with_LeftJoin(bool async) { - await base.Delete_with_left_join(async); + await base.Delete_with_LeftJoin(async); AssertSql( """ @@ -615,10 +629,12 @@ public override async Task Update_Where_set_constant_TagWith(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + -- MyUpdate UPDATE `Customers` AS `c` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -629,8 +645,10 @@ public override async Task Update_Where_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -640,19 +658,20 @@ public override async Task Update_Where_parameter_set_constant(bool async) await base.Update_Where_parameter_set_constant(async); AssertExecuteUpdateSql( """ -@__customer_0='ALFKI' (Size = 5) (DbType = StringFixedLength) +@p='Updated' (Size = 30) +@customer='ALFKI' (Size = 5) (DbType = StringFixedLength) UPDATE `Customers` AS `c` -SET `c`.`ContactName` = 'Updated' -WHERE `c`.`CustomerID` = @__customer_0 +SET `c`.`ContactName` = @p +WHERE `c`.`CustomerID` = @customer """, // """ -@__customer_0='ALFKI' (Size = 5) (DbType = StringFixedLength) +@customer='ALFKI' (Size = 5) (DbType = StringFixedLength) SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = @__customer_0 +WHERE `c`.`CustomerID` = @customer """, // """ @@ -662,8 +681,10 @@ WHERE FALSE """, // """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE FALSE """); } @@ -673,10 +694,10 @@ public override async Task Update_Where_set_parameter(bool async) await base.Update_Where_set_parameter(async); AssertExecuteUpdateSql( """ -@__value_0='Abc' (Size = 30) +@p='Abc' (Size = 30) UPDATE `Customers` AS `c` -SET `c`.`ContactName` = @__value_0 +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -686,10 +707,10 @@ public override async Task Update_Where_set_parameter_from_closure_array(bool as await base.Update_Where_set_parameter_from_closure_array(async); AssertExecuteUpdateSql( """ -@__p_0='Abc' (Size = 30) +@p='Abc' (Size = 30) UPDATE `Customers` AS `c` -SET `c`.`ContactName` = @__p_0 +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -700,8 +721,10 @@ public override async Task Update_Where_set_parameter_from_inline_list(bool asyn AssertExecuteUpdateSql( """ +@p='Abc' (Size = 30) + UPDATE `Customers` AS `c` -SET `c`.`ContactName` = 'Abc' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -711,10 +734,10 @@ public override async Task Update_Where_set_parameter_from_multilevel_property_a await base.Update_Where_set_parameter_from_multilevel_property_access(async); AssertExecuteUpdateSql( """ -@__container_Containee_Property_0='Abc' (Size = 30) +@p='Abc' (Size = 30) UPDATE `Customers` AS `c` -SET `c`.`ContactName` = @__container_Containee_Property_0 +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -725,16 +748,17 @@ public override async Task Update_Where_Skip_set_constant(bool async) AssertExecuteUpdateSql( """ -@__p_0='4' +@p='4' +@p0='Updated' (Size = 30) UPDATE `Customers` AS `c0` INNER JOIN ( SELECT `c`.`CustomerID` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'F%' - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` -SET `c0`.`ContactName` = 'Updated' +SET `c0`.`ContactName` = @p0 """); } @@ -750,12 +774,13 @@ await AssertUpdate( AssertExecuteUpdateSql( """ -@__p_0='4' +@p0='Updated' (Size = 30) +@p='4' UPDATE `Customers` AS `c` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p0 WHERE `c`.`CustomerID` LIKE 'F%' -LIMIT @__p_0 +LIMIT @p """); } @@ -766,17 +791,18 @@ public override async Task Update_Where_Skip_Take_set_constant(bool async) AssertExecuteUpdateSql( """ -@__p_1='4' -@__p_0='2' +@p0='4' +@p='2' +@p1='Updated' (Size = 30) UPDATE `Customers` AS `c0` INNER JOIN ( SELECT `c`.`CustomerID` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'F%' - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` -SET `c0`.`ContactName` = 'Updated' +SET `c0`.`ContactName` = @p1 """); } @@ -786,13 +812,15 @@ public override async Task Update_Where_OrderBy_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c0` INNER JOIN ( SELECT `c`.`CustomerID` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'F%' ) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` -SET `c0`.`ContactName` = 'Updated' +SET `c0`.`ContactName` = @p """); } @@ -802,7 +830,8 @@ public override async Task Update_Where_OrderBy_Skip_set_constant(bool async) AssertExecuteUpdateSql( """ -@__p_0='4' +@p='4' +@p0='Updated' (Size = 30) UPDATE `Customers` AS `c0` INNER JOIN ( @@ -810,9 +839,9 @@ INNER JOIN ( FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'F%' ORDER BY `c`.`City` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` -SET `c0`.`ContactName` = 'Updated' +SET `c0`.`ContactName` = @p0 """); } @@ -822,7 +851,8 @@ public override async Task Update_Where_OrderBy_Take_set_constant(bool async) AssertExecuteUpdateSql( """ -@__p_0='4' +@p='4' +@p0='Updated' (Size = 30) UPDATE `Customers` AS `c0` INNER JOIN ( @@ -830,9 +860,9 @@ INNER JOIN ( FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'F%' ORDER BY `c`.`City` - LIMIT @__p_0 + LIMIT @p ) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` -SET `c0`.`ContactName` = 'Updated' +SET `c0`.`ContactName` = @p0 """); } @@ -842,8 +872,9 @@ public override async Task Update_Where_OrderBy_Skip_Take_set_constant(bool asyn AssertExecuteUpdateSql( """ -@__p_1='4' -@__p_0='2' +@p0='4' +@p='2' +@p1='Updated' (Size = 30) UPDATE `Customers` AS `c0` INNER JOIN ( @@ -851,9 +882,9 @@ INNER JOIN ( FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'F%' ORDER BY `c`.`City` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` -SET `c0`.`ContactName` = 'Updated' +SET `c0`.`ContactName` = @p1 """); } @@ -863,8 +894,9 @@ public override async Task Update_Where_OrderBy_Skip_Take_Skip_Take_set_constant AssertExecuteUpdateSql( """ -@__p_1='6' -@__p_0='2' +@p0='6' +@p='2' +@p3='Updated' (Size = 30) UPDATE `Customers` AS `c1` INNER JOIN ( @@ -874,12 +906,12 @@ INNER JOIN ( FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'F%' ORDER BY `c`.`City` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `c0` ORDER BY `c0`.`City` - LIMIT @__p_0 OFFSET @__p_0 + LIMIT @p OFFSET @p ) AS `c2` ON `c1`.`CustomerID` = `c2`.`CustomerID` -SET `c1`.`ContactName` = 'Updated' +SET `c1`.`ContactName` = @p3 """); } @@ -889,8 +921,10 @@ public override async Task Update_Where_GroupBy_aggregate_set_constant(bool asyn AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` = ( SELECT `o`.`CustomerID` FROM `Orders` AS `o` @@ -906,8 +940,10 @@ public override async Task Update_Where_GroupBy_First_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` = ( SELECT ( SELECT `o0`.`CustomerID` @@ -967,13 +1003,15 @@ public override async Task Update_Where_Distinct_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c0` INNER JOIN ( SELECT DISTINCT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'F%' ) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` -SET `c0`.`ContactName` = 'Updated' +SET `c0`.`ContactName` = @p """); } @@ -996,10 +1034,12 @@ public override async Task Update_Where_using_navigation_2_set_constant(bool asy AssertExecuteUpdateSql( """ +@p='1' + UPDATE `Order Details` AS `o` INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` LEFT JOIN `Customers` AS `c` ON `o0`.`CustomerID` = `c`.`CustomerID` -SET `o`.`Quantity` = CAST(1 AS signed) +SET `o`.`Quantity` = CAST(@p AS signed) WHERE `c`.`City` = 'Seattle' """); } @@ -1035,10 +1075,10 @@ public override async Task Update_Where_set_property_plus_parameter(bool async) AssertExecuteUpdateSql( """ -@__value_0='Abc' (Size = 4000) +@value='Abc' (Size = 4000) UPDATE `Customers` AS `c` -SET `c`.`ContactName` = CONCAT(COALESCE(`c`.`ContactName`, ''), @__value_0) +SET `c`.`ContactName` = CONCAT(COALESCE(`c`.`ContactName`, ''), @value) WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -1061,8 +1101,10 @@ public override async Task Update_Where_set_constant_using_ef_property(bool asyn AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -1086,24 +1128,18 @@ public override async Task Update_without_property_to_set_throws(bool async) AssertExecuteUpdateSql(); } - public override async Task Update_with_invalid_lambda_throws(bool async) - { - await base.Update_with_invalid_lambda_throws(async); - - AssertExecuteUpdateSql(); - } - public override async Task Update_Where_multiple_set(bool async) { await base.Update_Where_multiple_set(async); AssertExecuteUpdateSql( """ -@__value_0='Abc' (Size = 30) +@value='Abc' (Size = 30) +@p='Seattle' (Size = 15) UPDATE `Customers` AS `c` -SET `c`.`City` = 'Seattle', - `c`.`ContactName` = @__value_0 +SET `c`.`ContactName` = @value, + `c`.`City` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -1128,6 +1164,8 @@ public override async Task Update_Union_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c1` INNER JOIN ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` @@ -1138,7 +1176,7 @@ INNER JOIN ( FROM `Customers` AS `c0` WHERE `c0`.`CustomerID` LIKE 'A%' ) AS `u` ON `c1`.`CustomerID` = `u`.`CustomerID` -SET `c1`.`ContactName` = 'Updated' +SET `c1`.`ContactName` = @p """); } @@ -1148,6 +1186,8 @@ public override async Task Update_Concat_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c1` INNER JOIN ( SELECT `c`.`CustomerID` @@ -1158,7 +1198,7 @@ UNION ALL FROM `Customers` AS `c0` WHERE `c0`.`CustomerID` LIKE 'A%' ) AS `u` ON `c1`.`CustomerID` = `u`.`CustomerID` -SET `c1`.`ContactName` = 'Updated' +SET `c1`.`ContactName` = @p """); } @@ -1168,6 +1208,8 @@ public override async Task Update_Except_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c1` INNER JOIN ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` @@ -1178,7 +1220,7 @@ INNER JOIN ( FROM `Customers` AS `c0` WHERE `c0`.`CustomerID` LIKE 'A%' ) AS `e` ON `c1`.`CustomerID` = `e`.`CustomerID` -SET `c1`.`ContactName` = 'Updated' +SET `c1`.`ContactName` = @p """); } @@ -1188,6 +1230,8 @@ public override async Task Update_Intersect_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c1` INNER JOIN ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` @@ -1198,7 +1242,7 @@ INNER JOIN ( FROM `Customers` AS `c0` WHERE `c0`.`CustomerID` LIKE 'A%' ) AS `i` ON `c1`.`CustomerID` = `i`.`CustomerID` -SET `c1`.`ContactName` = 'Updated' +SET `c1`.`ContactName` = @p """); } @@ -1208,30 +1252,34 @@ public override async Task Update_with_join_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` INNER JOIN ( SELECT `o`.`CustomerID` FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 ) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } - public override async Task Update_with_left_join_set_constant(bool async) + public override async Task Update_with_LeftJoin(bool async) { - await base.Update_with_left_join_set_constant(async); + await base.Update_with_LeftJoin(async); AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` LEFT JOIN ( SELECT `o`.`CustomerID` FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 ) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -1242,13 +1290,15 @@ public override async Task Update_with_cross_join_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` CROSS JOIN ( SELECT 1 FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 ) AS `o0` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -1259,13 +1309,15 @@ public override async Task Update_with_cross_apply_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` JOIN LATERAL ( SELECT 1 FROM `Orders` AS `o` WHERE (`o`.`OrderID` < 10300) AND (EXTRACT(year FROM `o`.`OrderDate`) < CHAR_LENGTH(`c`.`ContactName`)) ) AS `o0` ON TRUE -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -1276,13 +1328,15 @@ public override async Task Update_with_outer_apply_set_constant(bool async) AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` LEFT JOIN LATERAL ( SELECT 1 FROM `Orders` AS `o` WHERE (`o`.`OrderID` < 10300) AND (EXTRACT(year FROM `o`.`OrderDate`) < CHAR_LENGTH(`c`.`ContactName`)) ) AS `o0` ON TRUE -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -1293,6 +1347,8 @@ public override async Task Update_with_cross_join_left_join_set_constant(bool as AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` CROSS JOIN ( SELECT 1 @@ -1304,7 +1360,7 @@ LEFT JOIN ( FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 ) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -1315,6 +1371,8 @@ public override async Task Update_with_cross_join_cross_apply_set_constant(bool AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` CROSS JOIN ( SELECT 1 @@ -1326,7 +1384,7 @@ SELECT 1 FROM `Orders` AS `o` WHERE (`o`.`OrderID` < 10300) AND (EXTRACT(year FROM `o`.`OrderDate`) < CHAR_LENGTH(`c`.`ContactName`)) ) AS `o0` ON TRUE -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -1337,6 +1395,8 @@ public override async Task Update_with_cross_join_outer_apply_set_constant(bool AssertExecuteUpdateSql( """ +@p='Updated' (Size = 30) + UPDATE `Customers` AS `c` CROSS JOIN ( SELECT 1 @@ -1348,7 +1408,7 @@ SELECT 1 FROM `Orders` AS `o` WHERE (`o`.`OrderID` < 10300) AND (EXTRACT(year FROM `o`.`OrderDate`) < CHAR_LENGTH(`c`.`ContactName`)) ) AS `o0` ON TRUE -SET `c`.`ContactName` = 'Updated' +SET `c`.`ContactName` = @p WHERE `c`.`CustomerID` LIKE 'F%' """); } @@ -1459,10 +1519,12 @@ public override async Task Update_with_two_inner_joins(bool async) """, // """ +@p='1' + UPDATE `Order Details` AS `o` INNER JOIN `Products` AS `p` ON `o`.`ProductID` = `p`.`ProductID` INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` -SET `o`.`Quantity` = CAST(1 AS signed) +SET `o`.`Quantity` = CAST(@p AS signed) WHERE `p`.`Discontinued` AND (`o0`.`OrderDate` > TIMESTAMP '1990-01-01 00:00:00') """, // diff --git a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesMySqlTest.cs index 656a32ce5..47578a0d2 100644 --- a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesMySqlTest.cs @@ -128,8 +128,10 @@ public override async Task Update_where_using_hierarchy(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM ( @@ -149,8 +151,10 @@ public override async Task Update_where_using_hierarchy_derived(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM ( @@ -213,8 +217,10 @@ public override async Task Update_base_property_on_derived_type(bool async) """, // """ +@p='SomeOtherKiwi' (Size = 4000) + UPDATE `Kiwi` AS `k` -SET `k`.`Name` = 'SomeOtherKiwi' +SET `k`.`Name` = @p WHERE `k`.`CountryId` = 1 """, // @@ -237,8 +243,10 @@ public override async Task Update_derived_property_on_derived_type(bool async) """, // """ +@p='0' + UPDATE `Kiwi` AS `k` -SET `k`.`FoundOn` = 0 +SET `k`.`FoundOn` = @p WHERE `k`.`CountryId` = 1 """, // @@ -261,9 +269,12 @@ public override async Task Update_base_and_derived_types(bool async) """, // """ +@p='Kiwi' (Size = 4000) +@p0='0' + UPDATE `Kiwi` AS `k` -SET `k`.`FoundOn` = 0, - `k`.`Name` = 'Kiwi' +SET `k`.`Name` = @p, + `k`.`FoundOn` = @p0 WHERE `k`.`CountryId` = 1 """, // diff --git a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesMySqlTest.cs index 8ea90d35c..43c5cafca 100644 --- a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesMySqlTest.cs @@ -127,8 +127,10 @@ public override async Task Update_where_using_hierarchy(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM ( @@ -148,8 +150,10 @@ public override async Task Update_where_using_hierarchy_derived(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM ( @@ -207,8 +211,10 @@ public override async Task Update_base_property_on_derived_type(bool async) """, // """ +@p='SomeOtherKiwi' (Size = 4000) + UPDATE `Kiwi` AS `k` -SET `k`.`Name` = 'SomeOtherKiwi' +SET `k`.`Name` = @p """, // """ @@ -228,8 +234,10 @@ public override async Task Update_derived_property_on_derived_type(bool async) """, // """ +@p='0' + UPDATE `Kiwi` AS `k` -SET `k`.`FoundOn` = 0 +SET `k`.`FoundOn` = @p """, // """ @@ -249,9 +257,12 @@ public override async Task Update_base_and_derived_types(bool async) """, // """ +@p='Kiwi' (Size = 4000) +@p0='0' + UPDATE `Kiwi` AS `k` -SET `k`.`FoundOn` = 0, - `k`.`Name` = 'Kiwi' +SET `k`.`Name` = @p, + `k`.`FoundOn` = @p0 """, // """ @@ -271,8 +282,10 @@ public override async Task Update_with_interface_in_property_expression(bool asy """, // """ +@p='0' + UPDATE `Coke` AS `c` -SET `c`.`SugarGrams` = 0 +SET `c`.`SugarGrams` = @p """, // """ @@ -292,8 +305,10 @@ public override async Task Update_with_interface_in_EF_Property_in_property_expr """, // """ +@p='0' + UPDATE `Coke` AS `c` -SET `c`.`SugarGrams` = 0 +SET `c`.`SugarGrams` = @p """, // """ diff --git a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPHFiltersInheritanceBulkUpdatesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPHFiltersInheritanceBulkUpdatesMySqlTest.cs index 9fb819758..14597daf7 100644 --- a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPHFiltersInheritanceBulkUpdatesMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPHFiltersInheritanceBulkUpdatesMySqlTest.cs @@ -138,8 +138,10 @@ public override async Task Update_where_using_hierarchy(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` @@ -153,8 +155,10 @@ public override async Task Update_where_using_hierarchy_derived(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` @@ -168,8 +172,10 @@ public override async Task Update_base_type(bool async) AssertExecuteUpdateSql( """ +@p='Animal' (Size = 4000) + UPDATE `Animals` AS `a` -SET `a`.`Name` = 'Animal' +SET `a`.`Name` = @p WHERE (`a`.`CountryId` = 1) AND (`a`.`Name` = 'Great spotted kiwi') """); } @@ -180,8 +186,10 @@ public override async Task Update_base_type_with_OfType(bool async) AssertExecuteUpdateSql( """ +@p='NewBird' (Size = 4000) + UPDATE `Animals` AS `a` -SET `a`.`Name` = 'NewBird' +SET `a`.`Name` = @p WHERE (`a`.`CountryId` = 1) AND (`a`.`Discriminator` = 'Kiwi') """); } @@ -192,8 +200,10 @@ public override async Task Update_base_property_on_derived_type(bool async) AssertExecuteUpdateSql( """ +@p='SomeOtherKiwi' (Size = 4000) + UPDATE `Animals` AS `a` -SET `a`.`Name` = 'SomeOtherKiwi' +SET `a`.`Name` = @p WHERE (`a`.`Discriminator` = 'Kiwi') AND (`a`.`CountryId` = 1) """); } @@ -204,8 +214,10 @@ public override async Task Update_derived_property_on_derived_type(bool async) AssertExecuteUpdateSql( """ +@p='0' + UPDATE `Animals` AS `a` -SET `a`.`FoundOn` = 0 +SET `a`.`FoundOn` = @p WHERE (`a`.`Discriminator` = 'Kiwi') AND (`a`.`CountryId` = 1) """); } @@ -216,9 +228,12 @@ public override async Task Update_base_and_derived_types(bool async) AssertExecuteUpdateSql( """ +@p='Kiwi' (Size = 4000) +@p0='0' + UPDATE `Animals` AS `a` -SET `a`.`FoundOn` = 0, - `a`.`Name` = 'Kiwi' +SET `a`.`Name` = @p, + `a`.`FoundOn` = @p0 WHERE (`a`.`Discriminator` = 'Kiwi') AND (`a`.`CountryId` = 1) """); } diff --git a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPHInheritanceBulkUpdatesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPHInheritanceBulkUpdatesMySqlTest.cs index 47723adc7..f9b99c652 100644 --- a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPHInheritanceBulkUpdatesMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPHInheritanceBulkUpdatesMySqlTest.cs @@ -161,8 +161,10 @@ public override async Task Update_where_using_hierarchy(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` @@ -176,8 +178,10 @@ public override async Task Update_where_using_hierarchy_derived(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` @@ -198,8 +202,10 @@ public override async Task Update_base_type(bool async) AssertExecuteUpdateSql( """ +@p='Animal' (Size = 4000) + UPDATE `Animals` AS `a` -SET `a`.`Name` = 'Animal' +SET `a`.`Name` = @p WHERE `a`.`Name` = 'Great spotted kiwi' """); } @@ -210,8 +216,10 @@ public override async Task Update_base_type_with_OfType(bool async) AssertExecuteUpdateSql( """ +@p='NewBird' (Size = 4000) + UPDATE `Animals` AS `a` -SET `a`.`Name` = 'NewBird' +SET `a`.`Name` = @p WHERE `a`.`Discriminator` = 'Kiwi' """); } @@ -222,8 +230,10 @@ public override async Task Update_base_property_on_derived_type(bool async) AssertExecuteUpdateSql( """ +@p='SomeOtherKiwi' (Size = 4000) + UPDATE `Animals` AS `a` -SET `a`.`Name` = 'SomeOtherKiwi' +SET `a`.`Name` = @p WHERE `a`.`Discriminator` = 'Kiwi' """); } @@ -234,8 +244,10 @@ public override async Task Update_derived_property_on_derived_type(bool async) AssertExecuteUpdateSql( """ +@p='0' + UPDATE `Animals` AS `a` -SET `a`.`FoundOn` = 0 +SET `a`.`FoundOn` = @p WHERE `a`.`Discriminator` = 'Kiwi' """); } @@ -246,9 +258,12 @@ public override async Task Update_base_and_derived_types(bool async) AssertExecuteUpdateSql( """ +@p='Kiwi' (Size = 4000) +@p0='0' + UPDATE `Animals` AS `a` -SET `a`.`FoundOn` = 0, - `a`.`Name` = 'Kiwi' +SET `a`.`Name` = @p, + `a`.`FoundOn` = @p0 WHERE `a`.`Discriminator` = 'Kiwi' """); } @@ -259,8 +274,10 @@ public override async Task Update_with_interface_in_property_expression(bool asy AssertExecuteUpdateSql( """ +@p='0' + UPDATE `Drinks` AS `d` -SET `d`.`SugarGrams` = 0 +SET `d`.`SugarGrams` = @p WHERE `d`.`Discriminator` = 1 """); } @@ -271,8 +288,10 @@ public override async Task Update_with_interface_in_EF_Property_in_property_expr AssertExecuteUpdateSql( """ +@p='0' + UPDATE `Drinks` AS `d` -SET `d`.`SugarGrams` = 0 +SET `d`.`SugarGrams` = @p WHERE `d`.`Discriminator` = 1 """); } diff --git a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesMySqlTest.cs index 519dfcd30..33afce96a 100644 --- a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesMySqlTest.cs @@ -115,8 +115,10 @@ public override async Task Update_where_using_hierarchy(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` @@ -130,8 +132,10 @@ public override async Task Update_where_using_hierarchy_derived(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` @@ -160,8 +164,10 @@ public override async Task Update_base_type(bool async) AssertExecuteUpdateSql( """ +@p='Animal' (Size = 4000) + UPDATE `Animals` AS `a` -SET `a`.`Name` = 'Animal' +SET `a`.`Name` = @p WHERE (`a`.`CountryId` = 1) AND (`a`.`Name` = 'Great spotted kiwi') """); } @@ -172,9 +178,11 @@ public override async Task Update_base_type_with_OfType(bool async) AssertExecuteUpdateSql( """ +@p='NewBird' (Size = 4000) + UPDATE `Animals` AS `a` LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` -SET `a`.`Name` = 'NewBird' +SET `a`.`Name` = @p WHERE (`a`.`CountryId` = 1) AND `k`.`Id` IS NOT NULL """); } @@ -185,10 +193,12 @@ public override async Task Update_base_property_on_derived_type(bool async) AssertExecuteUpdateSql( """ +@p='SomeOtherKiwi' (Size = 4000) + UPDATE `Animals` AS `a` INNER JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id` INNER JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` -SET `a`.`Name` = 'SomeOtherKiwi' +SET `a`.`Name` = @p WHERE `a`.`CountryId` = 1 """); } @@ -199,10 +209,12 @@ public override async Task Update_derived_property_on_derived_type(bool async) AssertExecuteUpdateSql( """ +@p='0' + UPDATE `Animals` AS `a` INNER JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id` INNER JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` -SET `k`.`FoundOn` = 0 +SET `k`.`FoundOn` = @p WHERE `a`.`CountryId` = 1 """); } diff --git a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesMySqlTest.cs index 77bcc946d..6d9e871fa 100644 --- a/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesMySqlTest.cs @@ -97,8 +97,10 @@ public override async Task Update_where_using_hierarchy(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` @@ -112,8 +114,10 @@ public override async Task Update_where_using_hierarchy_derived(bool async) AssertExecuteUpdateSql( """ +@p='Monovia' (Size = 4000) + UPDATE `Countries` AS `c` -SET `c`.`Name` = 'Monovia' +SET `c`.`Name` = @p WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` @@ -142,8 +146,10 @@ public override async Task Update_base_type(bool async) AssertExecuteUpdateSql( """ +@p='Animal' (Size = 4000) + UPDATE `Animals` AS `a` -SET `a`.`Name` = 'Animal' +SET `a`.`Name` = @p WHERE `a`.`Name` = 'Great spotted kiwi' """); } @@ -154,9 +160,11 @@ public override async Task Update_base_type_with_OfType(bool async) AssertExecuteUpdateSql( """ +@p='NewBird' (Size = 4000) + UPDATE `Animals` AS `a` LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` -SET `a`.`Name` = 'NewBird' +SET `a`.`Name` = @p WHERE `k`.`Id` IS NOT NULL """); } @@ -167,10 +175,12 @@ public override async Task Update_base_property_on_derived_type(bool async) AssertExecuteUpdateSql( """ +@p='SomeOtherKiwi' (Size = 4000) + UPDATE `Animals` AS `a` INNER JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id` INNER JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` -SET `a`.`Name` = 'SomeOtherKiwi' +SET `a`.`Name` = @p """); } @@ -180,10 +190,12 @@ public override async Task Update_derived_property_on_derived_type(bool async) AssertExecuteUpdateSql( """ +@p='0' + UPDATE `Animals` AS `a` INNER JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id` INNER JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` -SET `k`.`FoundOn` = 0 +SET `k`.`FoundOn` = @p """); } @@ -193,9 +205,11 @@ public override async Task Update_with_interface_in_property_expression(bool asy AssertExecuteUpdateSql( """ +@p='0' + UPDATE `Drinks` AS `d` INNER JOIN `Coke` AS `c` ON `d`.`Id` = `c`.`Id` -SET `c`.`SugarGrams` = 0 +SET `c`.`SugarGrams` = @p """); } @@ -205,9 +219,11 @@ public override async Task Update_with_interface_in_EF_Property_in_property_expr AssertExecuteUpdateSql( """ +@p='0' + UPDATE `Drinks` AS `d` INNER JOIN `Coke` AS `c` ON `d`.`Id` = `c`.`Id` -SET `c`.`SugarGrams` = 0 +SET `c`.`SugarGrams` = @p """); } diff --git a/test/EFCore.MySql.FunctionalTests/ConnectionSettingsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/ConnectionSettingsMySqlTest.cs index d19449c47..4fcbed09b 100644 --- a/test/EFCore.MySql.FunctionalTests/ConnectionSettingsMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/ConnectionSettingsMySqlTest.cs @@ -41,7 +41,9 @@ public virtual void Insert_and_read_Guid_value(MySqlGuidFormat guidFormat, strin .ToList(); var sqlResult = context.SimpleGuidEntities +#pragma warning disable EF1003 .FromSqlRaw("select * from `SimpleGuidEntities` where `GuidValue` = " + sqlEquivalent) +#pragma warning restore EF1003 .ToList(); Assert.Single(result); diff --git a/test/EFCore.MySql.FunctionalTests/EFCore.MySql.FunctionalTests.csproj b/test/EFCore.MySql.FunctionalTests/EFCore.MySql.FunctionalTests.csproj index c5295a16f..d31822315 100644 --- a/test/EFCore.MySql.FunctionalTests/EFCore.MySql.FunctionalTests.csproj +++ b/test/EFCore.MySql.FunctionalTests/EFCore.MySql.FunctionalTests.csproj @@ -32,7 +32,6 @@ - @@ -40,6 +39,7 @@ + @@ -80,8 +80,6 @@ - - diff --git a/test/EFCore.MySql.FunctionalTests/EntitySplittingMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/EntitySplittingMySqlTest.cs index 0a499690a..2fecb5f14 100644 --- a/test/EFCore.MySql.FunctionalTests/EntitySplittingMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/EntitySplittingMySqlTest.cs @@ -7,8 +7,8 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests; public class EntitySplittingMySqlTest : EntitySplittingTestBase { - public EntitySplittingMySqlTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) + public EntitySplittingMySqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture, testOutputHelper) { } diff --git a/test/EFCore.MySql.FunctionalTests/MaterializationInterceptionMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/MaterializationInterceptionMySqlTest.cs index 7b0d95e58..686ebed35 100644 --- a/test/EFCore.MySql.FunctionalTests/MaterializationInterceptionMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/MaterializationInterceptionMySqlTest.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore; +using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; @@ -6,6 +7,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests; public class MaterializationInterceptionMySqlTest : MaterializationInterceptionTestBase { + public MaterializationInterceptionMySqlTest([NotNull] NonSharedFixture fixture) + : base(fixture) + { + } + public class MySqlLibraryContext : LibraryContext { public MySqlLibraryContext(DbContextOptions options) diff --git a/test/EFCore.MySql.FunctionalTests/MigrationsInfrastructureMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/MigrationsInfrastructureMySqlTest.cs index 2dbdc139d..3ba3f9cd9 100644 --- a/test/EFCore.MySql.FunctionalTests/MigrationsInfrastructureMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/MigrationsInfrastructureMySqlTest.cs @@ -20,9 +20,9 @@ public MigrationsInfrastructureMySqlTest(MigrationsInfrastructureMySqlFixture fi { } - public override void Can_generate_migration_from_initial_database_to_initial() + public override async Task Can_generate_migration_from_initial_database_to_initial() { - base.Can_generate_migration_from_initial_database_to_initial(); + await base.Can_generate_migration_from_initial_database_to_initial(); Assert.Equal( @"CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( @@ -36,9 +36,9 @@ public override void Can_generate_migration_from_initial_database_to_initial() ignoreLineEndingDifferences: true); } - public override void Can_generate_no_migration_script() + public override async Task Can_generate_no_migration_script() { - base.Can_generate_no_migration_script(); + await base.Can_generate_no_migration_script(); Assert.Equal( @"CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( diff --git a/test/EFCore.MySql.FunctionalTests/Query/AdHocAdvancedMappingsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/AdHocAdvancedMappingsQueryMySqlTest.cs index 5b413d4b7..d1b1dca79 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/AdHocAdvancedMappingsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/AdHocAdvancedMappingsQueryMySqlTest.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; @@ -10,6 +11,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class AdHocAdvancedMappingsQueryMySqlTest : AdHocAdvancedMappingsQueryRelationalTestBase { + public AdHocAdvancedMappingsQueryMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + [SkippableTheory] public override async Task Query_generates_correct_datetime2_parameter_definition(int? fractionalSeconds, string postfix) { diff --git a/test/EFCore.MySql.FunctionalTests/Query/AdHocJsonQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/AdHocJsonQueryMySqlTest.cs index a9a14d8af..69fcb4ee2 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/AdHocJsonQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/AdHocJsonQueryMySqlTest.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics.Internal; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -15,30 +13,136 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; // Disabled via internal access. The EF Core 7.0 JSON support isn't currently implemented. -internal class AdHocJsonQueryMySqlTest : AdHocJsonQueryTestBase +internal class AdHocJsonQueryMySqlTest : AdHocJsonQueryRelationalTestBase { + public AdHocJsonQueryMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; + protected override async Task SeedBadJsonProperties(ContextBadJsonProperties ctx) + { + await ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO Entities (Id, Scenario, OptionalReference, RequiredReference, Collection) +VALUES( +1, +'baseline', +'{"NestedOptional": { "Text":"or no" }, "NestedRequired": { "Text":"or nr" }, "NestedCollection": [ { "Text":"or nc 1" }, { "Text":"or nc 2" } ] }', +'{"NestedOptional": { "Text":"rr no" }, "NestedRequired": { "Text":"rr nr" }, "NestedCollection": [ { "Text":"rr nc 1" }, { "Text":"rr nc 2" } ] }', +'[ +{"NestedOptional": { "Text":"c 1 no" }, "NestedRequired": { "Text":"c 1 nr" }, "NestedCollection": [ { "Text":"c 1 nc 1" }, { "Text":"c 1 nc 2" } ] }, +{"NestedOptional": { "Text":"c 2 no" }, "NestedRequired": { "Text":"c 2 nr" }, "NestedCollection": [ { "Text":"c 2 nc 1" }, { "Text":"c 2 nc 2" } ] } +]') +"""); + + await ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO Entities (Id, Scenario, OptionalReference, RequiredReference, Collection) +VALUES( +2, +'duplicated navigations', +'{"NestedOptional": { "Text":"or no" }, "NestedOptional": { "Text":"or no dupnav" }, "NestedRequired": { "Text":"or nr" }, "NestedCollection": [ { "Text":"or nc 1" }, { "Text":"or nc 2" } ], "NestedCollection": [ { "Text":"or nc 1 dupnav" }, { "Text":"or nc 2 dupnav" } ], "NestedRequired": { "Text":"or nr dupnav" } }', +'{"NestedOptional": { "Text":"rr no" }, "NestedOptional": { "Text":"rr no dupnav" }, "NestedRequired": { "Text":"rr nr" }, "NestedCollection": [ { "Text":"rr nc 1" }, { "Text":"rr nc 2" } ], "NestedCollection": [ { "Text":"rr nc 1 dupnav" }, { "Text":"rr nc 2 dupnav" } ], "NestedRequired": { "Text":"rr nr dupnav" } }', +'[ +{"NestedOptional": { "Text":"c 1 no" }, "NestedOptional": { "Text":"c 1 no dupnav" }, "NestedRequired": { "Text":"c 1 nr" }, "NestedCollection": [ { "Text":"c 1 nc 1" }, { "Text":"c 1 nc 2" } ], "NestedCollection": [ { "Text":"c 1 nc 1 dupnav" }, { "Text":"c 1 nc 2 dupnav" } ], "NestedRequired": { "Text":"c 1 nr dupnav" } }, +{"NestedOptional": { "Text":"c 2 no" }, "NestedOptional": { "Text":"c 2 no dupnav" }, "NestedRequired": { "Text":"c 2 nr" }, "NestedCollection": [ { "Text":"c 2 nc 1" }, { "Text":"c 2 nc 2" } ], "NestedCollection": [ { "Text":"c 2 nc 1 dupnav" }, { "Text":"c 2 nc 2 dupnav" } ], "NestedRequired": { "Text":"c 2 nr dupnav" } } +]') +"""); + + await ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO Entities (Id, Scenario, OptionalReference, RequiredReference, Collection) +VALUES( +3, +'duplicated scalars', +'{"NestedOptional": { "Text":"or no", "Text":"or no dupprop" }, "NestedRequired": { "Text":"or nr", "Text":"or nr dupprop" }, "NestedCollection": [ { "Text":"or nc 1", "Text":"or nc 1 dupprop" }, { "Text":"or nc 2", "Text":"or nc 2 dupprop" } ] }', +'{"NestedOptional": { "Text":"rr no", "Text":"rr no dupprop" }, "NestedRequired": { "Text":"rr nr", "Text":"rr nr dupprop" }, "NestedCollection": [ { "Text":"rr nc 1", "Text":"rr nc 1 dupprop" }, { "Text":"rr nc 2", "Text":"rr nc 2 dupprop" } ] }', +'[ +{"NestedOptional": { "Text":"c 1 no", "Text":"c 1 no dupprop" }, "NestedRequired": { "Text":"c 1 nr", "Text":"c 1 nr dupprop" }, "NestedCollection": [ { "Text":"c 1 nc 1", "Text":"c 1 nc 1 dupprop" }, { "Text":"c 1 nc 2", "Text":"c 1 nc 2 dupprop" } ] }, +{"NestedOptional": { "Text":"c 2 no", "Text":"c 2 no dupprop" }, "NestedRequired": { "Text":"c 2 nr", "Text":"c 2 nr dupprop" }, "NestedCollection": [ { "Text":"c 2 nc 1", "Text":"c 2 nc 1 dupprop" }, { "Text":"c 2 nc 2", "Text":"c 2 nc 2 dupprop" } ] } +]') +"""); + + await ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO Entities (Id, Scenario, OptionalReference, RequiredReference, Collection) +VALUES( +4, +'empty navigation property names', +'{"": { "Text":"or no" }, "": { "Text":"or nr" }, "": [ { "Text":"or nc 1" }, { "Text":"or nc 2" } ] }', +'{"": { "Text":"rr no" }, "": { "Text":"rr nr" }, "": [ { "Text":"rr nc 1" }, { "Text":"rr nc 2" } ] }', +'[ +{"": { "Text":"c 1 no" }, "": { "Text":"c 1 nr" }, "": [ { "Text":"c 1 nc 1" }, { "Text":"c 1 nc 2" } ] }, +{"": { "Text":"c 2 no" }, "": { "Text":"c 2 nr" }, "": [ { "Text":"c 2 nc 1" }, { "Text":"c 2 nc 2" } ] } +]') +"""); + + await ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO Entities (Id, Scenario, OptionalReference, RequiredReference, Collection) +VALUES( +5, +'empty scalar property names', +'{"NestedOptional": { "":"or no" }, "NestedRequired": { "":"or nr" }, "NestedCollection": [ { "":"or nc 1" }, { "":"or nc 2" } ] }', +'{"NestedOptional": { "":"rr no" }, "NestedRequired": { "":"rr nr" }, "NestedCollection": [ { "":"rr nc 1" }, { "":"rr nc 2" } ] }', +'[ +{"NestedOptional": { "":"c 1 no" }, "NestedRequired": { "":"c 1 nr" }, "NestedCollection": [ { "":"c 1 nc 1" }, { "":"c 1 nc 2" } ] }, +{"NestedOptional": { "":"c 2 no" }, "NestedRequired": { "":"c 2 nr" }, "NestedCollection": [ { "":"c 2 nc 1" }, { "":"c 2 nc 2" } ] } +]') +"""); + + await ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO Entities (Id, Scenario, OptionalReference, RequiredReference, Collection) +VALUES( +10, +'null navigation property names', +'{null: { "Text":"or no" }, null: { "Text":"or nr" }, null: [ { "Text":"or nc 1" }, { "Text":"or nc 2" } ] }', +'{null: { "Text":"rr no" }, null: { "Text":"rr nr" }, null: [ { "Text":"rr nc 1" }, { "Text":"rr nc 2" } ] }', +'[ +{null: { "Text":"c 1 no" }, null: { "Text":"c 1 nr" }, null: [ { "Text":"c 1 nc 1" }, { "Text":"c 1 nc 2" } ] }, +{null: { "Text":"c 2 no" }, null: { "Text":"c 2 nr" }, null: [ { "Text":"c 2 nc 1" }, { "Text":"c 2 nc 2" } ] } +]') +"""); + + await ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO Entities (Id, Scenario, OptionalReference, RequiredReference, Collection) +VALUES( +11, +'null scalar property names', +'{"NestedOptional": { null:"or no", "Text":"or no nonnull" }, "NestedRequired": { null:"or nr", "Text":"or nr nonnull" }, "NestedCollection": [ { null:"or nc 1", "Text":"or nc 1 nonnull" }, { null:"or nc 2", "Text":"or nc 2 nonnull" } ] }', +'{"NestedOptional": { null:"rr no", "Text":"rr no nonnull" }, "NestedRequired": { null:"rr nr", "Text":"rr nr nonnull" }, "NestedCollection": [ { null:"rr nc 1", "Text":"rr nc 1 nonnull" }, { null:"rr nc 2", "Text":"rr nc 2 nonnull" } ] }', +'[ +{"NestedOptional": { null:"c 1 no", "Text":"c 1 no nonnull" }, "NestedRequired": { null:"c 1 nr", "Text":"c 1 nr nonnull" }, "NestedCollection": [ { null:"c 1 nc 1", "Text":"c 1 nc 1 nonnull" }, { null:"c 1 nc 2", "Text":"c 1 nc 2 nonnull" } ] }, +{"NestedOptional": { null:"c 2 no", "Text":"c 2 no nonnull" }, "NestedRequired": { null:"c 2 nr", "Text":"c 2 nr nonnull" }, "NestedCollection": [ { null:"c 2 nc 1", "Text":"c 2 nc 1 nonnull" }, { null:"c 2 nc 2", "Text":"c 2 nc 2 nonnull" } ] } +]') +"""); + } + protected override async Task Seed29219(DbContext ctx) { - var entity1 = new MyEntity29219 + var entity1 = new Context29219.MyEntity { Id = 1, - Reference = new MyJsonEntity29219 { NonNullableScalar = 10, NullableScalar = 11 }, + Reference = new Context29219.MyJsonEntity { NonNullableScalar = 10, NullableScalar = 11 }, Collection = [ - new MyJsonEntity29219 { NonNullableScalar = 100, NullableScalar = 101 }, - new MyJsonEntity29219 { NonNullableScalar = 200, NullableScalar = 201 }, - new MyJsonEntity29219 { NonNullableScalar = 300, NullableScalar = null } + new Context29219.MyJsonEntity { NonNullableScalar = 100, NullableScalar = 101 }, + new Context29219.MyJsonEntity { NonNullableScalar = 200, NullableScalar = 201 }, + new Context29219.MyJsonEntity { NonNullableScalar = 300, NullableScalar = null } ] }; - var entity2 = new MyEntity29219 + var entity2 = new Context29219.MyEntity { Id = 2, - Reference = new MyJsonEntity29219 { NonNullableScalar = 20, NullableScalar = null }, - Collection = [new MyJsonEntity29219 { NonNullableScalar = 1001, NullableScalar = null }] + Reference = new Context29219.MyJsonEntity { NonNullableScalar = 20, NullableScalar = null }, + Collection = [new Context29219.MyJsonEntity { NonNullableScalar = 1001, NullableScalar = null }] }; ctx.AddRange(entity1, entity2); @@ -97,52 +201,6 @@ protected override Task Seed33046(DbContext ctx) VALUES(N'[{"RoundNumber":11,"SubRounds":[{"SubRoundNumber":111},{"SubRoundNumber":112}]}]', 1) """); - protected override Task SeedArrayOfPrimitives(DbContext ctx) - { - var entity1 = new MyEntityArrayOfPrimitives - { - Id = 1, - Reference = new MyJsonEntityArrayOfPrimitives - { - IntArray = [1, 2, 3], - ListOfString = - [ - "Foo", - "Bar", - "Baz" - ] - }, - Collection = - [ - new MyJsonEntityArrayOfPrimitives { IntArray = [111, 112, 113], ListOfString = ["Foo11", "Bar11"] }, - new MyJsonEntityArrayOfPrimitives { IntArray = [211, 212, 213], ListOfString = ["Foo12", "Bar12"] } - ] - }; - - var entity2 = new MyEntityArrayOfPrimitives - { - Id = 2, - Reference = new MyJsonEntityArrayOfPrimitives - { - IntArray = [10, 20, 30], - ListOfString = - [ - "A", - "B", - "C" - ] - }, - Collection = - [ - new MyJsonEntityArrayOfPrimitives { IntArray = [110, 120, 130], ListOfString = ["A1", "Z1"] }, - new MyJsonEntityArrayOfPrimitives { IntArray = [210, 220, 230], ListOfString = ["A2", "Z2"] } - ] - }; - - ctx.AddRange(entity1, entity2); - return ctx.SaveChangesAsync(); - } - protected override Task SeedJunkInJson(DbContext ctx) => ctx.Database.ExecuteSqlAsync( $$$$""" diff --git a/test/EFCore.MySql.FunctionalTests/Query/AdHocManyToManyQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/AdHocManyToManyQueryMySqlTest.cs index 552076859..3c182db06 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/AdHocManyToManyQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/AdHocManyToManyQueryMySqlTest.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; @@ -6,6 +7,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class AdHocManyToManyQueryMySqlTest : AdHocManyToManyQueryRelationalTestBase { + public AdHocManyToManyQueryMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; } diff --git a/test/EFCore.MySql.FunctionalTests/Query/AdHocMiscellaneousQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/AdHocMiscellaneousQueryMySqlTest.cs index 0a1781252..13d0d6fff 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/AdHocMiscellaneousQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/AdHocMiscellaneousQueryMySqlTest.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using NameSpace1; @@ -10,9 +11,21 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class AdHocMiscellaneousQueryMySqlTest : AdHocMiscellaneousQueryRelationalTestBase { + public AdHocMiscellaneousQueryMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; + protected override DbContextOptionsBuilder SetParameterizedCollectionMode(DbContextOptionsBuilder optionsBuilder, ParameterTranslationMode parameterizedCollectionMode) + { + new MySqlDbContextOptionsBuilder(optionsBuilder).UseParameterizedCollectionMode(parameterizedCollectionMode); + + return optionsBuilder; + } + protected override Task Seed2951(Context2951 context) => context.Database.ExecuteSqlRawAsync( """ diff --git a/test/EFCore.MySql.FunctionalTests/Query/AdHocNavigationsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/AdHocNavigationsQueryMySqlTest.cs index 734163c9b..eba8603fb 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/AdHocNavigationsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/AdHocNavigationsQueryMySqlTest.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; @@ -6,6 +7,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class AdHocNavigationsQueryMySqlTest : AdHocNavigationsQueryRelationalTestBase { + public AdHocNavigationsQueryMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; } diff --git a/test/EFCore.MySql.FunctionalTests/Query/AdHocQueryFiltersQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/AdHocQueryFiltersQueryMySqlTest.cs index 02a014cee..dca50e3c9 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/AdHocQueryFiltersQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/AdHocQueryFiltersQueryMySqlTest.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using MySqlConnector; @@ -11,6 +12,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class AdHocQueryFiltersQueryMySqlTest : AdHocQueryFiltersQueryRelationalTestBase { + public AdHocQueryFiltersQueryMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + public override async Task Group_by_multiple_aggregate_joining_different_tables(bool async) { if (!AppConfig.ServerVersion.Supports.OuterReferenceInMultiLevelSubquery) diff --git a/test/EFCore.MySql.FunctionalTests/Query/AdHocQuerySplittingQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/AdHocQuerySplittingQueryMySqlTest.cs index a3eebe24c..6740a54e1 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/AdHocQuerySplittingQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/AdHocQuerySplittingQueryMySqlTest.cs @@ -10,6 +10,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class AdHocQuerySplittingQueryMySqlTest : AdHocQuerySplittingQueryTestBase { + public AdHocQuerySplittingQueryMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + protected override DbContextOptionsBuilder SetQuerySplittingBehavior( DbContextOptionsBuilder optionsBuilder, QuerySplittingBehavior splittingBehavior) diff --git a/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsQueryMySqlTest.cs index abe689442..5f9fda9ab 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsQueryMySqlTest.cs @@ -197,15 +197,15 @@ public override async Task Complex_multi_include_with_order_by_and_paging(bool a AssertSql( """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Required_Id` LEFT JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`OneToMany_Optional_Inverse3Id` @@ -220,15 +220,15 @@ public override async Task Complex_multi_include_with_order_by_and_paging_joins_ AssertSql( """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l2`.`Id`, `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l4`.`Id`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN `LevelTwo` AS `l2` ON `l1`.`Id` = `l2`.`Level1_Required_Id` @@ -244,15 +244,15 @@ public override async Task Complex_multi_include_with_order_by_and_paging_joins_ AssertSql( """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `l3`.`Id`, `l3`.`Level3_Optional_Id`, `l3`.`Level3_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse4Id`, `l3`.`OneToMany_Optional_Self_Inverse4Id`, `l3`.`OneToMany_Required_Inverse4Id`, `l3`.`OneToMany_Required_Self_Inverse4Id`, `l3`.`OneToOne_Optional_PK_Inverse4Id`, `l3`.`OneToOne_Optional_Self4Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`Level2_Required_Id` @@ -821,13 +821,13 @@ public override async Task Lift_projection_mapping_when_pushing_down_subquery(bo AssertSql( """ -@__p_0='25' +@p='25' SELECT `l2`.`Id`, `l4`.`Id`, `l1`.`Id`, `l4`.`c` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` - LIMIT @__p_0 + LIMIT @p ) AS `l2` LEFT JOIN ( SELECT `l3`.`Id`, `l3`.`c`, `l3`.`OneToMany_Required_Inverse2Id` @@ -884,6 +884,9 @@ FROM JSON_TABLE('["L1 01","L1 02"]', '$[*]' COLUMNS ( { AssertSql( """ +@validIds1='L1 01' (Size = 4000) +@validIds2='L1 02' (Size = 4000) + SELECT CASE WHEN `l0`.`Id` IS NULL THEN 0 ELSE `l0`.`Id` @@ -891,7 +894,7 @@ SELECT CASE FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Required_Id` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Required_Inverse3Id` -WHERE `l`.`Name` IN ('L1 01', 'L1 02') +WHERE `l`.`Name` IN (@validIds1, @validIds2) ORDER BY `l`.`Id`, `l0`.`Id` """); } @@ -1412,7 +1415,7 @@ public override async Task Filtered_include_variable_used_inside_filter(bool asy AssertSql( """ -@__prm_0='Foo' (Size = 4000) +@prm='Foo' (Size = 4000) SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` @@ -1421,7 +1424,7 @@ LEFT JOIN ( FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` - WHERE (`l0`.`Name` <> @__prm_0) OR `l0`.`Name` IS NULL + WHERE (`l0`.`Name` <> @prm) OR `l0`.`Name` IS NULL ) AS `l1` WHERE `l1`.`row` <= 3 ) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` @@ -1440,7 +1443,7 @@ SELECT COUNT(*) """, // """ -@__p_0='True' +@p='True' SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` @@ -1449,7 +1452,7 @@ LEFT JOIN ( FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` - WHERE @__p_0 + WHERE @p ) AS `l1` WHERE `l1`.`row` <= 3 ) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` @@ -1581,14 +1584,14 @@ public override async Task Take_Select_collection_Take(bool async) AssertSql( """ -@__p_0='1' +@p='1' SELECT `l3`.`Id`, `l3`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `l3` LEFT JOIN LATERAL ( SELECT `l2`.`Id`, `l2`.`Name`, `l2`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `l2`.`Level1_Required_Id` AS `Level2Id`, `l1`.`Id` AS `Id0`, `l1`.`Date`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id` @@ -1611,14 +1614,14 @@ public override async Task Skip_Take_Select_collection_Skip_Take(bool async) AssertSql( """ -@__p_0='1' +@p='1' SELECT `l3`.`Id`, `l3`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` - LIMIT @__p_0 OFFSET @__p_0 + LIMIT @p OFFSET @p ) AS `l3` LEFT JOIN LATERAL ( SELECT `l2`.`Id`, `l2`.`Name`, `l2`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `l2`.`Level1_Required_Id` AS `Level2Id`, `l1`.`Id` AS `Id0`, `l1`.`Date`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id` @@ -1659,14 +1662,14 @@ public override async Task Filtered_include_Take_with_another_Take_on_top_level( AssertSql( """ -@__p_0='5' +@p='5' SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l3`.`OneToMany_Optional_Self_Inverse1Id`, `l3`.`OneToMany_Required_Self_Inverse1Id`, `l3`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `l3` LEFT JOIN LATERAL ( SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` @@ -1689,15 +1692,15 @@ public override async Task Filtered_include_Skip_Take_with_another_Skip_Take_on_ AssertSql( """ -@__p_1='5' -@__p_0='1' +@p0='5' +@p='1' SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l3`.`OneToMany_Optional_Self_Inverse1Id`, `l3`.`OneToMany_Required_Self_Inverse1Id`, `l3`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` DESC - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l3` LEFT JOIN LATERAL ( SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` diff --git a/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQueryMySqlTest.cs index 40bfe3971..65b23df33 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQueryMySqlTest.cs @@ -69,14 +69,14 @@ public override async Task Take_Select_collection_Take(bool async) AssertSql( """ -@__p_0='1' +@p='1' SELECT `l3`.`Id`, `l3`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`Id1` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `Level1` AS `l` ORDER BY `l`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `l3` LEFT JOIN LATERAL ( SELECT CASE @@ -105,14 +105,14 @@ public override async Task Skip_Take_Select_collection_Skip_Take(bool async) AssertSql( """ -@__p_0='1' +@p='1' SELECT `l3`.`Id`, `l3`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`Id1` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `Level1` AS `l` ORDER BY `l`.`Id` - LIMIT @__p_0 OFFSET @__p_0 + LIMIT @p OFFSET @p ) AS `l3` LEFT JOIN LATERAL ( SELECT CASE diff --git a/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQueryMySqlTest.cs index 6d0841297..6230d7429 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQueryMySqlTest.cs @@ -1152,13 +1152,13 @@ public override async Task Lift_projection_mapping_when_pushing_down_subquery(bo AssertSql( """ -@__p_0='25' +@p='25' SELECT `l1`.`Id`, `l3`.`Id`, `l3`.`c` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` - LIMIT @__p_0 + LIMIT @p ) AS `l1` LEFT JOIN ( SELECT `l2`.`Id`, `l2`.`c`, `l2`.`OneToMany_Required_Inverse2Id` @@ -1172,13 +1172,13 @@ ORDER BY `l1`.`Id` """, // """ -@__p_0='25' +@p='25' SELECT `l4`.`Id`, `l5`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` - LIMIT @__p_0 + LIMIT @p ) AS `l5` INNER JOIN `LevelTwo` AS `l4` ON `l5`.`Id` = `l4`.`OneToMany_Required_Inverse2Id` ORDER BY `l5`.`Id` @@ -1425,23 +1425,23 @@ public override async Task Take_Select_collection_Take(bool async) AssertSql( """ -@__p_0='1' +@p='1' SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` -LIMIT @__p_0 +LIMIT @p """, // """ -@__p_0='1' +@p='1' SELECT `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id`, `l9`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `l9` JOIN LATERAL ( SELECT `l8`.`Id`, `l8`.`Name`, `l8`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `l8`.`Level1_Required_Id` AS `Level2Id`, `l7`.`Id` AS `Id0`, `l7`.`Date`, `l7`.`Name` AS `Name0`, `l7`.`OneToMany_Optional_Self_Inverse1Id`, `l7`.`OneToMany_Required_Self_Inverse1Id`, `l7`.`OneToOne_Optional_Self1Id` @@ -1464,23 +1464,23 @@ public override async Task Skip_Take_Select_collection_Skip_Take(bool async) AssertSql( """ -@__p_0='1' +@p='1' SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` -LIMIT @__p_0 OFFSET @__p_0 +LIMIT @p OFFSET @p """, // """ -@__p_0='1' +@p='1' SELECT `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id`, `l9`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` - LIMIT @__p_0 OFFSET @__p_0 + LIMIT @p OFFSET @p ) AS `l9` JOIN LATERAL ( SELECT `l8`.`Id`, `l8`.`Name`, `l8`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `l8`.`Level1_Required_Id` AS `Level2Id`, `l7`.`Id` AS `Id0`, `l7`.`Date`, `l7`.`Name` AS `Name0`, `l7`.`OneToMany_Optional_Self_Inverse1Id`, `l7`.`OneToMany_Required_Self_Inverse1Id`, `l7`.`OneToOne_Optional_Self1Id` @@ -1776,30 +1776,30 @@ public override async Task Complex_multi_include_with_order_by_and_paging(bool a AssertSql( """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Required_Id` ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id` """, // """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `l1`.`Id`, `l0`.`Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Required_Id` INNER JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`OneToMany_Optional_Inverse3Id` @@ -1807,15 +1807,15 @@ LIMIT @__p_1 OFFSET @__p_0 """, // """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l1`.`Id`, `l0`.`Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Required_Id` INNER JOIN `LevelThree` AS `l3` ON `l0`.`Id` = `l3`.`OneToMany_Required_Inverse3Id` @@ -1829,15 +1829,15 @@ public override async Task Complex_multi_include_with_order_by_and_paging_joins_ AssertSql( """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN `LevelTwo` AS `l2` ON `l1`.`Id` = `l2`.`Level1_Required_Id` @@ -1845,15 +1845,15 @@ LIMIT @__p_1 OFFSET @__p_0 """, // """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN `LevelTwo` AS `l2` ON `l1`.`Id` = `l2`.`Level1_Required_Id` @@ -1862,15 +1862,15 @@ LIMIT @__p_1 OFFSET @__p_0 """, // """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l4`.`Id`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN `LevelTwo` AS `l2` ON `l1`.`Id` = `l2`.`Level1_Required_Id` @@ -1885,15 +1885,15 @@ public override async Task Complex_multi_include_with_order_by_and_paging_joins_ AssertSql( """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`Level2_Required_Id` @@ -1901,15 +1901,15 @@ LIMIT @__p_1 OFFSET @__p_0 """, // """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `l3`.`Id`, `l3`.`Level3_Optional_Id`, `l3`.`Level3_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse4Id`, `l3`.`OneToMany_Optional_Self_Inverse4Id`, `l3`.`OneToMany_Required_Inverse4Id`, `l3`.`OneToMany_Required_Self_Inverse4Id`, `l3`.`OneToOne_Optional_PK_Inverse4Id`, `l3`.`OneToOne_Optional_Self4Id`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l1` LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`Level2_Required_Id` @@ -2584,22 +2584,28 @@ FROM JSON_TABLE('["L1 01","L1 02"]', '$[*]' COLUMNS ( { AssertSql( """ +@validIds1='L1 01' (Size = 4000) +@validIds2='L1 02' (Size = 4000) + SELECT CASE WHEN `l0`.`Id` IS NULL THEN 0 ELSE `l0`.`Id` END, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Required_Id` -WHERE `l`.`Name` IN ('L1 01', 'L1 02') +WHERE `l`.`Name` IN (@validIds1, @validIds2) ORDER BY `l`.`Id`, `l0`.`Id` """, // """ +@validIds3='L1 01' (Size = 4000) +@validIds4='L1 02' (Size = 4000) + SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Required_Id` INNER JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Required_Inverse3Id` -WHERE `l`.`Name` IN ('L1 01', 'L1 02') +WHERE `l`.`Name` IN (@validIds3, @validIds4) ORDER BY `l`.`Id`, `l0`.`Id` """); } @@ -2671,23 +2677,23 @@ public override async Task Filtered_include_Take_with_another_Take_on_top_level( AssertSql( """ -@__p_0='5' +@p='5' SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` -LIMIT @__p_0 +LIMIT @p """, // """ -@__p_0='5' +@p='5' SELECT `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `l3`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `l3` JOIN LATERAL ( SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` @@ -2710,25 +2716,25 @@ public override async Task Filtered_include_Skip_Take_with_another_Skip_Take_on_ AssertSql( """ -@__p_1='5' -@__p_0='1' +@p0='5' +@p='1' SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` DESC -LIMIT @__p_1 OFFSET @__p_0 +LIMIT @p0 OFFSET @p """, // """ -@__p_1='5' -@__p_0='1' +@p0='5' +@p='1' SELECT `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `l3`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` DESC - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `l3` JOIN LATERAL ( SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` @@ -2875,6 +2881,7 @@ LIMIT 1 SELECT `l`.`Id` FROM `LevelOne` AS `l` WHERE `l`.`Id` = 1 + ORDER BY `l`.`Id` LIMIT 1 ) AS `l3` INNER JOIN `LevelTwo` AS `l2` ON `l3`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` diff --git a/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsQueryMySqlTest.cs index 6699e4446..d049aba20 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsQueryMySqlTest.cs @@ -41,13 +41,15 @@ await AssertQuery( .Take(1)); AssertSql( - @"@__p_0='1' +""" +@p='1' SELECT `l0`.`Name` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name` -LIMIT @__p_0"); +LIMIT @p +"""); } public override async Task GroupJoin_client_method_in_OrderBy(bool async) diff --git a/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryMySqlTest.cs index f8af953af..526d7e8ea 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryMySqlTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Diagnostics; @@ -48,7 +48,7 @@ await AssertQuery( AssertSql( """ -@__p_0='1' +@p='1' SELECT `l1`.`Name` FROM `Level1` AS `l` @@ -58,7 +58,7 @@ INNER JOIN ( WHERE (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL ) AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` ORDER BY `l1`.`Name` -LIMIT @__p_0 +LIMIT @p """); } @@ -104,14 +104,14 @@ await AssertQuery( AssertSql( """ -@__p_0='2' +@p='2' SELECT `l6`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Result`, `s`.`Id2`, `s`.`Id3`, `s`.`Id4` FROM ( SELECT `l`.`Id` FROM `Level1` AS `l` ORDER BY `l`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `l6` LEFT JOIN ( SELECT CASE diff --git a/test/EFCore.MySql.FunctionalTests/Query/ComplexTypeQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/ComplexTypeQueryMySqlTest.cs index 5be666351..75660c486 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/ComplexTypeQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/ComplexTypeQueryMySqlTest.cs @@ -19,44 +19,20 @@ public ComplexTypeQueryMySqlTest(ComplexTypeQueryMySqlFixture fixture, ITestOutp Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - public override async Task Filter_on_property_inside_complex_type(bool async) - { - await base.Filter_on_property_inside_complex_type(async); - - AssertSql( -""" -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -WHERE `c`.`ShippingAddress_ZipCode` = 7728 -"""); - } - - public override async Task Filter_on_property_inside_nested_complex_type(bool async) - { - await base.Filter_on_property_inside_nested_complex_type(async); - - AssertSql( -""" -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` -FROM `Customer` AS `c` -WHERE `c`.`ShippingAddress_Country_Code` = 'DE' -"""); - } - public override async Task Filter_on_property_inside_complex_type_after_subquery(bool async) { await base.Filter_on_property_inside_complex_type_after_subquery(async); AssertSql( """ -@__p_0='1' +@p='1' -SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`OptionalAddress_AddressLine1`, `c0`.`OptionalAddress_AddressLine2`, `c0`.`OptionalAddress_Tags`, `c0`.`OptionalAddress_ZipCode`, `c0`.`OptionalAddress_Country_Code`, `c0`.`OptionalAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` ORDER BY `c`.`Id` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `c0` WHERE `c0`.`ShippingAddress_ZipCode` = 7728 """); @@ -68,14 +44,14 @@ public override async Task Filter_on_property_inside_nested_complex_type_after_s AssertSql( """ -@__p_0='1' +@p='1' -SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`OptionalAddress_AddressLine1`, `c0`.`OptionalAddress_AddressLine2`, `c0`.`OptionalAddress_Tags`, `c0`.`OptionalAddress_ZipCode`, `c0`.`OptionalAddress_Country_Code`, `c0`.`OptionalAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` ORDER BY `c`.`Id` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `c0` WHERE `c0`.`ShippingAddress_Country_Code` = 'DE' """); @@ -87,7 +63,7 @@ public override async Task Filter_on_required_property_inside_required_complex_t AssertSql( """ -SELECT `c`.`Id`, `c`.`OptionalCustomerId`, `c`.`RequiredCustomerId`, `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`OptionalCustomerId`, `c`.`RequiredCustomerId`, `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`OptionalAddress_AddressLine1`, `c0`.`OptionalAddress_AddressLine2`, `c0`.`OptionalAddress_Tags`, `c0`.`OptionalAddress_ZipCode`, `c0`.`OptionalAddress_Country_Code`, `c0`.`OptionalAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`OptionalAddress_AddressLine1`, `c1`.`OptionalAddress_AddressLine2`, `c1`.`OptionalAddress_Tags`, `c1`.`OptionalAddress_ZipCode`, `c1`.`OptionalAddress_Country_Code`, `c1`.`OptionalAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName` FROM `CustomerGroup` AS `c` LEFT JOIN `Customer` AS `c0` ON `c`.`OptionalCustomerId` = `c0`.`Id` INNER JOIN `Customer` AS `c1` ON `c`.`RequiredCustomerId` = `c1`.`Id` @@ -101,7 +77,7 @@ public override async Task Filter_on_required_property_inside_required_complex_t AssertSql( """ -SELECT `c`.`Id`, `c`.`OptionalCustomerId`, `c`.`RequiredCustomerId`, `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`OptionalCustomerId`, `c`.`RequiredCustomerId`, `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`OptionalAddress_AddressLine1`, `c1`.`OptionalAddress_AddressLine2`, `c1`.`OptionalAddress_Tags`, `c1`.`OptionalAddress_ZipCode`, `c1`.`OptionalAddress_Country_Code`, `c1`.`OptionalAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`OptionalAddress_AddressLine1`, `c0`.`OptionalAddress_AddressLine2`, `c0`.`OptionalAddress_Tags`, `c0`.`OptionalAddress_ZipCode`, `c0`.`OptionalAddress_Country_Code`, `c0`.`OptionalAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM `CustomerGroup` AS `c` INNER JOIN `Customer` AS `c0` ON `c`.`RequiredCustomerId` = `c0`.`Id` LEFT JOIN `Customer` AS `c1` ON `c`.`OptionalCustomerId` = `c1`.`Id` @@ -109,14 +85,16 @@ public override async Task Filter_on_required_property_inside_required_complex_t """); } - // This test fails because when OptionalCustomer is null, we get all-null results because of the LEFT JOIN, and we materialize this - // as an empty ShippingAddress instead of null (see SQL). The proper solution here would be to project the Customer ID just for the - // purpose of knowing that it's there. public override async Task Project_complex_type_via_optional_navigation(bool async) { - var exception = await Assert.ThrowsAsync(() => base.Project_complex_type_via_optional_navigation(async)); + await base.Project_complex_type_via_optional_navigation(async); - Assert.Equal(RelationalStrings.CannotProjectNullableComplexType("Customer.ShippingAddress#Address"), exception.Message); + AssertSql( +""" +SELECT `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +FROM `CustomerGroup` AS `c` +LEFT JOIN `Customer` AS `c0` ON `c`.`OptionalCustomerId` = `c0`.`Id` +"""); } public override async Task Project_complex_type_via_required_navigation(bool async) @@ -137,14 +115,14 @@ public override async Task Load_complex_type_after_subquery_on_entity_type(bool AssertSql( """ -@__p_0='1' +@p='1' -SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`OptionalAddress_AddressLine1`, `c0`.`OptionalAddress_AddressLine2`, `c0`.`OptionalAddress_Tags`, `c0`.`OptionalAddress_ZipCode`, `c0`.`OptionalAddress_Country_Code`, `c0`.`OptionalAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` ORDER BY `c`.`Id` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `c0` """); } @@ -211,7 +189,7 @@ public override async Task Complex_type_equals_complex_type(bool async) AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE (((`c`.`ShippingAddress_AddressLine1` = `c`.`BillingAddress_AddressLine1`) AND ((`c`.`ShippingAddress_AddressLine2` = `c`.`BillingAddress_AddressLine2`) OR (`c`.`ShippingAddress_AddressLine2` IS NULL AND (`c`.`BillingAddress_AddressLine2` IS NULL)))) AND (`c`.`ShippingAddress_Tags` = `c`.`BillingAddress_Tags`)) AND (`c`.`ShippingAddress_ZipCode` = `c`.`BillingAddress_ZipCode`) """); @@ -223,7 +201,7 @@ public override async Task Complex_type_equals_constant(bool async) AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE (((((`c`.`ShippingAddress_AddressLine1` = '804 S. Lakeshore Road') AND `c`.`ShippingAddress_AddressLine2` IS NULL) AND (`c`.`ShippingAddress_Tags` = '["foo","bar"]')) AND (`c`.`ShippingAddress_ZipCode` = 38654)) AND (`c`.`ShippingAddress_Country_Code` = 'US')) AND (`c`.`ShippingAddress_Country_FullName` = 'United States') """); @@ -235,15 +213,15 @@ public override async Task Complex_type_equals_parameter(bool async) AssertSql( """ -@__entity_equality_address_0_AddressLine1='804 S. Lakeshore Road' (Size = 4000) -@__entity_equality_address_0_Tags='["foo","bar"]' (Size = 4000) -@__entity_equality_address_0_ZipCode='38654' (Nullable = true) -@__entity_equality_address_0_Country_Code='US' (Size = 4000) -@__entity_equality_address_0_Country_FullName='United States' (Size = 4000) +@entity_equality_address_AddressLine1='804 S. Lakeshore Road' (Size = 4000) +@entity_equality_address_Tags='["foo","bar"]' (Size = 4000) +@entity_equality_address_ZipCode='38654' (Nullable = true) +@entity_equality_address_Country_Code='US' (Size = 4000) +@entity_equality_address_Country_FullName='United States' (Size = 4000) -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` -WHERE (((((`c`.`ShippingAddress_AddressLine1` = @__entity_equality_address_0_AddressLine1) AND `c`.`ShippingAddress_AddressLine2` IS NULL) AND (`c`.`ShippingAddress_Tags` = @__entity_equality_address_0_Tags)) AND (`c`.`ShippingAddress_ZipCode` = @__entity_equality_address_0_ZipCode)) AND (`c`.`ShippingAddress_Country_Code` = @__entity_equality_address_0_Country_Code)) AND (`c`.`ShippingAddress_Country_FullName` = @__entity_equality_address_0_Country_FullName) +WHERE (((((`c`.`ShippingAddress_AddressLine1` = @entity_equality_address_AddressLine1) AND `c`.`ShippingAddress_AddressLine2` IS NULL) AND (`c`.`ShippingAddress_Tags` = @entity_equality_address_Tags)) AND (`c`.`ShippingAddress_ZipCode` = @entity_equality_address_ZipCode)) AND (`c`.`ShippingAddress_Country_Code` = @entity_equality_address_Country_Code)) AND (`c`.`ShippingAddress_Country_FullName` = @entity_equality_address_Country_FullName) """); } @@ -261,18 +239,18 @@ public override async Task Contains_over_complex_type(bool async) AssertSql( """ -@__entity_equality_address_0_AddressLine1='804 S. Lakeshore Road' (Size = 4000) -@__entity_equality_address_0_Tags='["foo","bar"]' (Size = 4000) -@__entity_equality_address_0_ZipCode='38654' (Nullable = true) -@__entity_equality_address_0_Country_Code='US' (Size = 4000) -@__entity_equality_address_0_Country_FullName='United States' (Size = 4000) +@entity_equality_address_AddressLine1='804 S. Lakeshore Road' (Size = 4000) +@entity_equality_address_Tags='["foo","bar"]' (Size = 4000) +@entity_equality_address_ZipCode='38654' (Nullable = true) +@entity_equality_address_Country_Code='US' (Size = 4000) +@entity_equality_address_Country_FullName='United States' (Size = 4000) -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE EXISTS ( SELECT 1 FROM `Customer` AS `c0` - WHERE (((((`c0`.`ShippingAddress_AddressLine1` = @__entity_equality_address_0_AddressLine1) AND `c0`.`ShippingAddress_AddressLine2` IS NULL) AND (`c0`.`ShippingAddress_Tags` = @__entity_equality_address_0_Tags)) AND (`c0`.`ShippingAddress_ZipCode` = @__entity_equality_address_0_ZipCode)) AND (`c0`.`ShippingAddress_Country_Code` = @__entity_equality_address_0_Country_Code)) AND (`c0`.`ShippingAddress_Country_FullName` = @__entity_equality_address_0_Country_FullName)) + WHERE (((((`c0`.`ShippingAddress_AddressLine1` = @entity_equality_address_AddressLine1) AND `c0`.`ShippingAddress_AddressLine2` IS NULL) AND (`c0`.`ShippingAddress_Tags` = @entity_equality_address_Tags)) AND (`c0`.`ShippingAddress_ZipCode` = @entity_equality_address_ZipCode)) AND (`c0`.`ShippingAddress_Country_Code` = @entity_equality_address_Country_Code)) AND (`c0`.`ShippingAddress_Country_FullName` = @entity_equality_address_Country_FullName)) """); } @@ -297,11 +275,11 @@ public override async Task Concat_entity_type_containing_complex_property(bool a AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE `c`.`Id` = 1 UNION ALL -SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`OptionalAddress_AddressLine1`, `c0`.`OptionalAddress_AddressLine2`, `c0`.`OptionalAddress_Tags`, `c0`.`OptionalAddress_ZipCode`, `c0`.`OptionalAddress_Country_Code`, `c0`.`OptionalAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c0` WHERE `c0`.`Id` = 2 """); @@ -313,11 +291,11 @@ public override async Task Union_entity_type_containing_complex_property(bool as AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE `c`.`Id` = 1 UNION -SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`OptionalAddress_AddressLine1`, `c0`.`OptionalAddress_AddressLine2`, `c0`.`OptionalAddress_Tags`, `c0`.`OptionalAddress_ZipCode`, `c0`.`OptionalAddress_Country_Code`, `c0`.`OptionalAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c0` WHERE `c0`.`Id` = 2 """); @@ -383,14 +361,6 @@ public override async Task Union_two_different_complex_type(bool async) ); } - public override async Task Complex_type_equals_null(bool async) - { - await base.Complex_type_equals_null(async); - - AssertSql( -); - } - public override async Task Subquery_over_struct_complex_type(bool async) { await base.Subquery_over_struct_complex_type(async); @@ -445,14 +415,14 @@ public override async Task Filter_on_property_inside_struct_complex_type_after_s AssertSql( """ -@__p_0='1' +@p='1' SELECT DISTINCT `v0`.`Id`, `v0`.`Name`, `v0`.`BillingAddress_AddressLine1`, `v0`.`BillingAddress_AddressLine2`, `v0`.`BillingAddress_ZipCode`, `v0`.`BillingAddress_Country_Code`, `v0`.`BillingAddress_Country_FullName`, `v0`.`ShippingAddress_AddressLine1`, `v0`.`ShippingAddress_AddressLine2`, `v0`.`ShippingAddress_ZipCode`, `v0`.`ShippingAddress_Country_Code`, `v0`.`ShippingAddress_Country_FullName` FROM ( SELECT `v`.`Id`, `v`.`Name`, `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName` FROM `ValuedCustomer` AS `v` ORDER BY `v`.`Id` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `v0` WHERE `v0`.`ShippingAddress_ZipCode` = 7728 """); @@ -464,14 +434,14 @@ public override async Task Filter_on_property_inside_nested_struct_complex_type_ AssertSql( """ -@__p_0='1' +@p='1' SELECT DISTINCT `v0`.`Id`, `v0`.`Name`, `v0`.`BillingAddress_AddressLine1`, `v0`.`BillingAddress_AddressLine2`, `v0`.`BillingAddress_ZipCode`, `v0`.`BillingAddress_Country_Code`, `v0`.`BillingAddress_Country_FullName`, `v0`.`ShippingAddress_AddressLine1`, `v0`.`ShippingAddress_AddressLine2`, `v0`.`ShippingAddress_ZipCode`, `v0`.`ShippingAddress_Country_Code`, `v0`.`ShippingAddress_Country_FullName` FROM ( SELECT `v`.`Id`, `v`.`Name`, `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName` FROM `ValuedCustomer` AS `v` ORDER BY `v`.`Id` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `v0` WHERE `v0`.`ShippingAddress_Country_Code` = 'DE' """); @@ -505,14 +475,16 @@ public override async Task Filter_on_required_property_inside_required_struct_co """); } - // This test fails because when OptionalCustomer is null, we get all-null results because of the LEFT JOIN, and we materialize this - // as an empty ShippingAddress instead of null (see SQL). The proper solution here would be to project the Customer ID just for the - // purpose of knowing that it's there. public override async Task Project_struct_complex_type_via_optional_navigation(bool async) { - var exception = await Assert.ThrowsAsync(() => base.Project_struct_complex_type_via_optional_navigation(async)); + await base.Project_struct_complex_type_via_optional_navigation(async); - Assert.Equal(RelationalStrings.CannotProjectNullableComplexType("ValuedCustomer.ShippingAddress#AddressStruct"), exception.Message); + AssertSql( +""" +SELECT `v0`.`ShippingAddress_AddressLine1`, `v0`.`ShippingAddress_AddressLine2`, `v0`.`ShippingAddress_ZipCode`, `v0`.`ShippingAddress_Country_Code`, `v0`.`ShippingAddress_Country_FullName` +FROM `ValuedCustomerGroup` AS `v` +LEFT JOIN `ValuedCustomer` AS `v0` ON `v`.`OptionalCustomerId` = `v0`.`Id` +"""); } public override async Task Project_struct_complex_type_via_required_navigation(bool async) @@ -532,14 +504,14 @@ public override async Task Load_struct_complex_type_after_subquery_on_entity_typ AssertSql( """ -@__p_0='1' +@p='1' SELECT DISTINCT `v0`.`Id`, `v0`.`Name`, `v0`.`BillingAddress_AddressLine1`, `v0`.`BillingAddress_AddressLine2`, `v0`.`BillingAddress_ZipCode`, `v0`.`BillingAddress_Country_Code`, `v0`.`BillingAddress_Country_FullName`, `v0`.`ShippingAddress_AddressLine1`, `v0`.`ShippingAddress_AddressLine2`, `v0`.`ShippingAddress_ZipCode`, `v0`.`ShippingAddress_Country_Code`, `v0`.`ShippingAddress_Country_FullName` FROM ( SELECT `v`.`Id`, `v`.`Name`, `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName` FROM `ValuedCustomer` AS `v` ORDER BY `v`.`Id` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `v0` """); } @@ -626,14 +598,14 @@ public override async Task Struct_complex_type_equals_parameter(bool async) AssertSql( """ -@__entity_equality_address_0_AddressLine1='804 S. Lakeshore Road' (Size = 4000) -@__entity_equality_address_0_ZipCode='38654' (Nullable = true) -@__entity_equality_address_0_Country_Code='US' (Size = 4000) -@__entity_equality_address_0_Country_FullName='United States' (Size = 4000) +@entity_equality_address_AddressLine1='804 S. Lakeshore Road' (Size = 4000) +@entity_equality_address_ZipCode='38654' (Nullable = true) +@entity_equality_address_Country_Code='US' (Size = 4000) +@entity_equality_address_Country_FullName='United States' (Size = 4000) SELECT `v`.`Id`, `v`.`Name`, `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName` FROM `ValuedCustomer` AS `v` -WHERE ((((`v`.`ShippingAddress_AddressLine1` = @__entity_equality_address_0_AddressLine1) AND `v`.`ShippingAddress_AddressLine2` IS NULL) AND (`v`.`ShippingAddress_ZipCode` = @__entity_equality_address_0_ZipCode)) AND (`v`.`ShippingAddress_Country_Code` = @__entity_equality_address_0_Country_Code)) AND (`v`.`ShippingAddress_Country_FullName` = @__entity_equality_address_0_Country_FullName) +WHERE ((((`v`.`ShippingAddress_AddressLine1` = @entity_equality_address_AddressLine1) AND `v`.`ShippingAddress_AddressLine2` IS NULL) AND (`v`.`ShippingAddress_ZipCode` = @entity_equality_address_ZipCode)) AND (`v`.`ShippingAddress_Country_Code` = @entity_equality_address_Country_Code)) AND (`v`.`ShippingAddress_Country_FullName` = @entity_equality_address_Country_FullName) """); } @@ -643,17 +615,17 @@ public override async Task Contains_over_struct_complex_type(bool async) AssertSql( """ -@__entity_equality_address_0_AddressLine1='804 S. Lakeshore Road' (Size = 4000) -@__entity_equality_address_0_ZipCode='38654' (Nullable = true) -@__entity_equality_address_0_Country_Code='US' (Size = 4000) -@__entity_equality_address_0_Country_FullName='United States' (Size = 4000) +@entity_equality_address_AddressLine1='804 S. Lakeshore Road' (Size = 4000) +@entity_equality_address_ZipCode='38654' (Nullable = true) +@entity_equality_address_Country_Code='US' (Size = 4000) +@entity_equality_address_Country_FullName='United States' (Size = 4000) SELECT `v`.`Id`, `v`.`Name`, `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName` FROM `ValuedCustomer` AS `v` WHERE EXISTS ( SELECT 1 FROM `ValuedCustomer` AS `v0` - WHERE ((((`v0`.`ShippingAddress_AddressLine1` = @__entity_equality_address_0_AddressLine1) AND `v0`.`ShippingAddress_AddressLine2` IS NULL) AND (`v0`.`ShippingAddress_ZipCode` = @__entity_equality_address_0_ZipCode)) AND (`v0`.`ShippingAddress_Country_Code` = @__entity_equality_address_0_Country_Code)) AND (`v0`.`ShippingAddress_Country_FullName` = @__entity_equality_address_0_Country_FullName)) + WHERE ((((`v0`.`ShippingAddress_AddressLine1` = @entity_equality_address_AddressLine1) AND `v0`.`ShippingAddress_AddressLine2` IS NULL) AND (`v0`.`ShippingAddress_ZipCode` = @entity_equality_address_ZipCode)) AND (`v0`.`ShippingAddress_Country_Code` = @entity_equality_address_Country_Code)) AND (`v0`.`ShippingAddress_Country_FullName` = @entity_equality_address_Country_FullName)) """); } @@ -769,9 +741,9 @@ public override async Task Project_same_entity_with_nested_complex_type_twice_wi AssertSql( """ -SELECT `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_Tags`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_Tags0`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0` +SELECT `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`OptionalAddress_AddressLine1`, `s`.`OptionalAddress_AddressLine2`, `s`.`OptionalAddress_Tags`, `s`.`OptionalAddress_ZipCode`, `s`.`OptionalAddress_Country_Code`, `s`.`OptionalAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_Tags`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`OptionalAddress_AddressLine10`, `s`.`OptionalAddress_AddressLine20`, `s`.`OptionalAddress_Tags0`, `s`.`OptionalAddress_ZipCode0`, `s`.`OptionalAddress_Country_Code0`, `s`.`OptionalAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_Tags0`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT DISTINCT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`OptionalAddress_AddressLine1` AS `OptionalAddress_AddressLine10`, `c0`.`OptionalAddress_AddressLine2` AS `OptionalAddress_AddressLine20`, `c0`.`OptionalAddress_Tags` AS `OptionalAddress_Tags0`, `c0`.`OptionalAddress_ZipCode` AS `OptionalAddress_ZipCode0`, `c0`.`OptionalAddress_Country_Code` AS `OptionalAddress_Country_Code0`, `c0`.`OptionalAddress_Country_FullName` AS `OptionalAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` ) AS `s` @@ -784,7 +756,7 @@ public override async Task Project_same_nested_complex_type_twice_with_double_pu AssertSql( """ -@__p_0='50' +@p='50' SELECT `s0`.`BillingAddress_AddressLine1`, `s0`.`BillingAddress_AddressLine2`, `s0`.`BillingAddress_Tags`, `s0`.`BillingAddress_ZipCode`, `s0`.`BillingAddress_Country_Code`, `s0`.`BillingAddress_Country_FullName`, `s0`.`BillingAddress_AddressLine10`, `s0`.`BillingAddress_AddressLine20`, `s0`.`BillingAddress_Tags0`, `s0`.`BillingAddress_ZipCode0`, `s0`.`BillingAddress_Country_Code0`, `s0`.`BillingAddress_Country_FullName0` FROM ( @@ -794,7 +766,7 @@ public override async Task Project_same_nested_complex_type_twice_with_double_pu FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` ORDER BY `c`.`Id`, `c0`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `s` ) AS `s0` """); @@ -806,17 +778,17 @@ public override async Task Project_same_entity_with_nested_complex_type_twice_wi AssertSql( """ -@__p_0='50' +@p='50' -SELECT `s0`.`Id`, `s0`.`Name`, `s0`.`BillingAddress_AddressLine1`, `s0`.`BillingAddress_AddressLine2`, `s0`.`BillingAddress_Tags`, `s0`.`BillingAddress_ZipCode`, `s0`.`BillingAddress_Country_Code`, `s0`.`BillingAddress_Country_FullName`, `s0`.`ShippingAddress_AddressLine1`, `s0`.`ShippingAddress_AddressLine2`, `s0`.`ShippingAddress_Tags`, `s0`.`ShippingAddress_ZipCode`, `s0`.`ShippingAddress_Country_Code`, `s0`.`ShippingAddress_Country_FullName`, `s0`.`Id0`, `s0`.`Name0`, `s0`.`BillingAddress_AddressLine10`, `s0`.`BillingAddress_AddressLine20`, `s0`.`BillingAddress_Tags0`, `s0`.`BillingAddress_ZipCode0`, `s0`.`BillingAddress_Country_Code0`, `s0`.`BillingAddress_Country_FullName0`, `s0`.`ShippingAddress_AddressLine10`, `s0`.`ShippingAddress_AddressLine20`, `s0`.`ShippingAddress_Tags0`, `s0`.`ShippingAddress_ZipCode0`, `s0`.`ShippingAddress_Country_Code0`, `s0`.`ShippingAddress_Country_FullName0` +SELECT `s0`.`Id`, `s0`.`Name`, `s0`.`BillingAddress_AddressLine1`, `s0`.`BillingAddress_AddressLine2`, `s0`.`BillingAddress_Tags`, `s0`.`BillingAddress_ZipCode`, `s0`.`BillingAddress_Country_Code`, `s0`.`BillingAddress_Country_FullName`, `s0`.`OptionalAddress_AddressLine1`, `s0`.`OptionalAddress_AddressLine2`, `s0`.`OptionalAddress_Tags`, `s0`.`OptionalAddress_ZipCode`, `s0`.`OptionalAddress_Country_Code`, `s0`.`OptionalAddress_Country_FullName`, `s0`.`ShippingAddress_AddressLine1`, `s0`.`ShippingAddress_AddressLine2`, `s0`.`ShippingAddress_Tags`, `s0`.`ShippingAddress_ZipCode`, `s0`.`ShippingAddress_Country_Code`, `s0`.`ShippingAddress_Country_FullName`, `s0`.`Id0`, `s0`.`Name0`, `s0`.`BillingAddress_AddressLine10`, `s0`.`BillingAddress_AddressLine20`, `s0`.`BillingAddress_Tags0`, `s0`.`BillingAddress_ZipCode0`, `s0`.`BillingAddress_Country_Code0`, `s0`.`BillingAddress_Country_FullName0`, `s0`.`OptionalAddress_AddressLine10`, `s0`.`OptionalAddress_AddressLine20`, `s0`.`OptionalAddress_Tags0`, `s0`.`OptionalAddress_ZipCode0`, `s0`.`OptionalAddress_Country_Code0`, `s0`.`OptionalAddress_Country_FullName0`, `s0`.`ShippingAddress_AddressLine10`, `s0`.`ShippingAddress_AddressLine20`, `s0`.`ShippingAddress_Tags0`, `s0`.`ShippingAddress_ZipCode0`, `s0`.`ShippingAddress_Country_Code0`, `s0`.`ShippingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_Tags`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_Tags0`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0` + SELECT DISTINCT `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`OptionalAddress_AddressLine1`, `s`.`OptionalAddress_AddressLine2`, `s`.`OptionalAddress_Tags`, `s`.`OptionalAddress_ZipCode`, `s`.`OptionalAddress_Country_Code`, `s`.`OptionalAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_Tags`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`OptionalAddress_AddressLine10`, `s`.`OptionalAddress_AddressLine20`, `s`.`OptionalAddress_Tags0`, `s`.`OptionalAddress_ZipCode0`, `s`.`OptionalAddress_Country_Code0`, `s`.`OptionalAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_Tags0`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`OptionalAddress_AddressLine1` AS `OptionalAddress_AddressLine10`, `c0`.`OptionalAddress_AddressLine2` AS `OptionalAddress_AddressLine20`, `c0`.`OptionalAddress_Tags` AS `OptionalAddress_Tags0`, `c0`.`OptionalAddress_ZipCode` AS `OptionalAddress_ZipCode0`, `c0`.`OptionalAddress_Country_Code` AS `OptionalAddress_Country_Code0`, `c0`.`OptionalAddress_Country_FullName` AS `OptionalAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` ORDER BY `c`.`Id`, `c0`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `s` ) AS `s0` """); @@ -858,7 +830,7 @@ public override async Task Project_same_struct_nested_complex_type_twice_with_do AssertSql( """ -@__p_0='50' +@p='50' SELECT `s0`.`BillingAddress_AddressLine1`, `s0`.`BillingAddress_AddressLine2`, `s0`.`BillingAddress_ZipCode`, `s0`.`BillingAddress_Country_Code`, `s0`.`BillingAddress_Country_FullName`, `s0`.`BillingAddress_AddressLine10`, `s0`.`BillingAddress_AddressLine20`, `s0`.`BillingAddress_ZipCode0`, `s0`.`BillingAddress_Country_Code0`, `s0`.`BillingAddress_Country_FullName0` FROM ( @@ -868,7 +840,7 @@ public override async Task Project_same_struct_nested_complex_type_twice_with_do FROM `ValuedCustomer` AS `v` CROSS JOIN `ValuedCustomer` AS `v0` ORDER BY `v`.`Id`, `v0`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `s` ) AS `s0` """); @@ -880,7 +852,7 @@ public override async Task Project_same_entity_with_struct_nested_complex_type_t AssertSql( """ -@__p_0='50' +@p='50' SELECT `s0`.`Id`, `s0`.`Name`, `s0`.`BillingAddress_AddressLine1`, `s0`.`BillingAddress_AddressLine2`, `s0`.`BillingAddress_ZipCode`, `s0`.`BillingAddress_Country_Code`, `s0`.`BillingAddress_Country_FullName`, `s0`.`ShippingAddress_AddressLine1`, `s0`.`ShippingAddress_AddressLine2`, `s0`.`ShippingAddress_ZipCode`, `s0`.`ShippingAddress_Country_Code`, `s0`.`ShippingAddress_Country_FullName`, `s0`.`Id0`, `s0`.`Name0`, `s0`.`BillingAddress_AddressLine10`, `s0`.`BillingAddress_AddressLine20`, `s0`.`BillingAddress_ZipCode0`, `s0`.`BillingAddress_Country_Code0`, `s0`.`BillingAddress_Country_FullName0`, `s0`.`ShippingAddress_AddressLine10`, `s0`.`ShippingAddress_AddressLine20`, `s0`.`ShippingAddress_ZipCode0`, `s0`.`ShippingAddress_Country_Code0`, `s0`.`ShippingAddress_Country_FullName0` FROM ( @@ -890,7 +862,7 @@ public override async Task Project_same_entity_with_struct_nested_complex_type_t FROM `ValuedCustomer` AS `v` CROSS JOIN `ValuedCustomer` AS `v0` ORDER BY `v`.`Id`, `v0`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `s` ) AS `s0` """); @@ -902,20 +874,20 @@ public override async Task Union_of_same_entity_with_nested_complex_type_project AssertSql( """ -@__p_0='50' +@p='50' -SELECT `u`.`Id`, `u`.`Name`, `u`.`BillingAddress_AddressLine1`, `u`.`BillingAddress_AddressLine2`, `u`.`BillingAddress_Tags`, `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_Country_Code`, `u`.`BillingAddress_Country_FullName`, `u`.`ShippingAddress_AddressLine1`, `u`.`ShippingAddress_AddressLine2`, `u`.`ShippingAddress_Tags`, `u`.`ShippingAddress_ZipCode`, `u`.`ShippingAddress_Country_Code`, `u`.`ShippingAddress_Country_FullName`, `u`.`Id0`, `u`.`Name0`, `u`.`BillingAddress_AddressLine10`, `u`.`BillingAddress_AddressLine20`, `u`.`BillingAddress_Tags0`, `u`.`BillingAddress_ZipCode0`, `u`.`BillingAddress_Country_Code0`, `u`.`BillingAddress_Country_FullName0`, `u`.`ShippingAddress_AddressLine10`, `u`.`ShippingAddress_AddressLine20`, `u`.`ShippingAddress_Tags0`, `u`.`ShippingAddress_ZipCode0`, `u`.`ShippingAddress_Country_Code0`, `u`.`ShippingAddress_Country_FullName0` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BillingAddress_AddressLine1`, `u`.`BillingAddress_AddressLine2`, `u`.`BillingAddress_Tags`, `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_Country_Code`, `u`.`BillingAddress_Country_FullName`, `u`.`OptionalAddress_AddressLine1`, `u`.`OptionalAddress_AddressLine2`, `u`.`OptionalAddress_Tags`, `u`.`OptionalAddress_ZipCode`, `u`.`OptionalAddress_Country_Code`, `u`.`OptionalAddress_Country_FullName`, `u`.`ShippingAddress_AddressLine1`, `u`.`ShippingAddress_AddressLine2`, `u`.`ShippingAddress_Tags`, `u`.`ShippingAddress_ZipCode`, `u`.`ShippingAddress_Country_Code`, `u`.`ShippingAddress_Country_FullName`, `u`.`Id0`, `u`.`Name0`, `u`.`BillingAddress_AddressLine10`, `u`.`BillingAddress_AddressLine20`, `u`.`BillingAddress_Tags0`, `u`.`BillingAddress_ZipCode0`, `u`.`BillingAddress_Country_Code0`, `u`.`BillingAddress_Country_FullName0`, `u`.`OptionalAddress_AddressLine10`, `u`.`OptionalAddress_AddressLine20`, `u`.`OptionalAddress_Tags0`, `u`.`OptionalAddress_ZipCode0`, `u`.`OptionalAddress_Country_Code0`, `u`.`OptionalAddress_Country_FullName0`, `u`.`ShippingAddress_AddressLine10`, `u`.`ShippingAddress_AddressLine20`, `u`.`ShippingAddress_Tags0`, `u`.`ShippingAddress_ZipCode0`, `u`.`ShippingAddress_Country_Code0`, `u`.`ShippingAddress_Country_FullName0` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`OptionalAddress_AddressLine1` AS `OptionalAddress_AddressLine10`, `c0`.`OptionalAddress_AddressLine2` AS `OptionalAddress_AddressLine20`, `c0`.`OptionalAddress_Tags` AS `OptionalAddress_Tags0`, `c0`.`OptionalAddress_ZipCode` AS `OptionalAddress_ZipCode0`, `c0`.`OptionalAddress_Country_Code` AS `OptionalAddress_Country_Code0`, `c0`.`OptionalAddress_Country_FullName` AS `OptionalAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` UNION - SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c2`.`Id` AS `Id0`, `c2`.`Name` AS `Name0`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c2`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c2`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c2`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c2`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c2`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c2`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`OptionalAddress_AddressLine1`, `c1`.`OptionalAddress_AddressLine2`, `c1`.`OptionalAddress_Tags`, `c1`.`OptionalAddress_ZipCode`, `c1`.`OptionalAddress_Country_Code`, `c1`.`OptionalAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c2`.`Id` AS `Id0`, `c2`.`Name` AS `Name0`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c2`.`OptionalAddress_AddressLine1` AS `OptionalAddress_AddressLine10`, `c2`.`OptionalAddress_AddressLine2` AS `OptionalAddress_AddressLine20`, `c2`.`OptionalAddress_Tags` AS `OptionalAddress_Tags0`, `c2`.`OptionalAddress_ZipCode` AS `OptionalAddress_ZipCode0`, `c2`.`OptionalAddress_Country_Code` AS `OptionalAddress_Country_Code0`, `c2`.`OptionalAddress_Country_FullName` AS `OptionalAddress_Country_FullName0`, `c2`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c2`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c2`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c2`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c2`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c2`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c1` CROSS JOIN `Customer` AS `c2` ) AS `u` ORDER BY `u`.`Id`, `u`.`Id0` -LIMIT @__p_0 +LIMIT @p """); } @@ -925,28 +897,28 @@ public override async Task Union_of_same_entity_with_nested_complex_type_project AssertSql( """ -@__p_0='50' +@p='50' -SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`BillingAddress_AddressLine1`, `u1`.`BillingAddress_AddressLine2`, `u1`.`BillingAddress_Tags`, `u1`.`BillingAddress_ZipCode`, `u1`.`BillingAddress_Country_Code`, `u1`.`BillingAddress_Country_FullName`, `u1`.`ShippingAddress_AddressLine1`, `u1`.`ShippingAddress_AddressLine2`, `u1`.`ShippingAddress_Tags`, `u1`.`ShippingAddress_ZipCode`, `u1`.`ShippingAddress_Country_Code`, `u1`.`ShippingAddress_Country_FullName`, `u1`.`Id0`, `u1`.`Name0`, `u1`.`BillingAddress_AddressLine10`, `u1`.`BillingAddress_AddressLine20`, `u1`.`BillingAddress_Tags0`, `u1`.`BillingAddress_ZipCode0`, `u1`.`BillingAddress_Country_Code0`, `u1`.`BillingAddress_Country_FullName0`, `u1`.`ShippingAddress_AddressLine10`, `u1`.`ShippingAddress_AddressLine20`, `u1`.`ShippingAddress_Tags0`, `u1`.`ShippingAddress_ZipCode0`, `u1`.`ShippingAddress_Country_Code0`, `u1`.`ShippingAddress_Country_FullName0` +SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`BillingAddress_AddressLine1`, `u1`.`BillingAddress_AddressLine2`, `u1`.`BillingAddress_Tags`, `u1`.`BillingAddress_ZipCode`, `u1`.`BillingAddress_Country_Code`, `u1`.`BillingAddress_Country_FullName`, `u1`.`OptionalAddress_AddressLine1`, `u1`.`OptionalAddress_AddressLine2`, `u1`.`OptionalAddress_Tags`, `u1`.`OptionalAddress_ZipCode`, `u1`.`OptionalAddress_Country_Code`, `u1`.`OptionalAddress_Country_FullName`, `u1`.`ShippingAddress_AddressLine1`, `u1`.`ShippingAddress_AddressLine2`, `u1`.`ShippingAddress_Tags`, `u1`.`ShippingAddress_ZipCode`, `u1`.`ShippingAddress_Country_Code`, `u1`.`ShippingAddress_Country_FullName`, `u1`.`Id0`, `u1`.`Name0`, `u1`.`BillingAddress_AddressLine10`, `u1`.`BillingAddress_AddressLine20`, `u1`.`BillingAddress_Tags0`, `u1`.`BillingAddress_ZipCode0`, `u1`.`BillingAddress_Country_Code0`, `u1`.`BillingAddress_Country_FullName0`, `u1`.`OptionalAddress_AddressLine10`, `u1`.`OptionalAddress_AddressLine20`, `u1`.`OptionalAddress_Tags0`, `u1`.`OptionalAddress_ZipCode0`, `u1`.`OptionalAddress_Country_Code0`, `u1`.`OptionalAddress_Country_FullName0`, `u1`.`ShippingAddress_AddressLine10`, `u1`.`ShippingAddress_AddressLine20`, `u1`.`ShippingAddress_Tags0`, `u1`.`ShippingAddress_ZipCode0`, `u1`.`ShippingAddress_Country_Code0`, `u1`.`ShippingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `u0`.`Id`, `u0`.`Name`, `u0`.`BillingAddress_AddressLine1`, `u0`.`BillingAddress_AddressLine2`, `u0`.`BillingAddress_Tags`, `u0`.`BillingAddress_ZipCode`, `u0`.`BillingAddress_Country_Code`, `u0`.`BillingAddress_Country_FullName`, `u0`.`ShippingAddress_AddressLine1`, `u0`.`ShippingAddress_AddressLine2`, `u0`.`ShippingAddress_Tags`, `u0`.`ShippingAddress_ZipCode`, `u0`.`ShippingAddress_Country_Code`, `u0`.`ShippingAddress_Country_FullName`, `u0`.`Id0`, `u0`.`Name0`, `u0`.`BillingAddress_AddressLine10`, `u0`.`BillingAddress_AddressLine20`, `u0`.`BillingAddress_Tags0`, `u0`.`BillingAddress_ZipCode0`, `u0`.`BillingAddress_Country_Code0`, `u0`.`BillingAddress_Country_FullName0`, `u0`.`ShippingAddress_AddressLine10`, `u0`.`ShippingAddress_AddressLine20`, `u0`.`ShippingAddress_Tags0`, `u0`.`ShippingAddress_ZipCode0`, `u0`.`ShippingAddress_Country_Code0`, `u0`.`ShippingAddress_Country_FullName0` + SELECT DISTINCT `u0`.`Id`, `u0`.`Name`, `u0`.`BillingAddress_AddressLine1`, `u0`.`BillingAddress_AddressLine2`, `u0`.`BillingAddress_Tags`, `u0`.`BillingAddress_ZipCode`, `u0`.`BillingAddress_Country_Code`, `u0`.`BillingAddress_Country_FullName`, `u0`.`OptionalAddress_AddressLine1`, `u0`.`OptionalAddress_AddressLine2`, `u0`.`OptionalAddress_Tags`, `u0`.`OptionalAddress_ZipCode`, `u0`.`OptionalAddress_Country_Code`, `u0`.`OptionalAddress_Country_FullName`, `u0`.`ShippingAddress_AddressLine1`, `u0`.`ShippingAddress_AddressLine2`, `u0`.`ShippingAddress_Tags`, `u0`.`ShippingAddress_ZipCode`, `u0`.`ShippingAddress_Country_Code`, `u0`.`ShippingAddress_Country_FullName`, `u0`.`Id0`, `u0`.`Name0`, `u0`.`BillingAddress_AddressLine10`, `u0`.`BillingAddress_AddressLine20`, `u0`.`BillingAddress_Tags0`, `u0`.`BillingAddress_ZipCode0`, `u0`.`BillingAddress_Country_Code0`, `u0`.`BillingAddress_Country_FullName0`, `u0`.`OptionalAddress_AddressLine10`, `u0`.`OptionalAddress_AddressLine20`, `u0`.`OptionalAddress_Tags0`, `u0`.`OptionalAddress_ZipCode0`, `u0`.`OptionalAddress_Country_Code0`, `u0`.`OptionalAddress_Country_FullName0`, `u0`.`ShippingAddress_AddressLine10`, `u0`.`ShippingAddress_AddressLine20`, `u0`.`ShippingAddress_Tags0`, `u0`.`ShippingAddress_ZipCode0`, `u0`.`ShippingAddress_Country_Code0`, `u0`.`ShippingAddress_Country_FullName0` FROM ( - SELECT `u`.`Id`, `u`.`Name`, `u`.`BillingAddress_AddressLine1`, `u`.`BillingAddress_AddressLine2`, `u`.`BillingAddress_Tags`, `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_Country_Code`, `u`.`BillingAddress_Country_FullName`, `u`.`ShippingAddress_AddressLine1`, `u`.`ShippingAddress_AddressLine2`, `u`.`ShippingAddress_Tags`, `u`.`ShippingAddress_ZipCode`, `u`.`ShippingAddress_Country_Code`, `u`.`ShippingAddress_Country_FullName`, `u`.`Id0`, `u`.`Name0`, `u`.`BillingAddress_AddressLine10`, `u`.`BillingAddress_AddressLine20`, `u`.`BillingAddress_Tags0`, `u`.`BillingAddress_ZipCode0`, `u`.`BillingAddress_Country_Code0`, `u`.`BillingAddress_Country_FullName0`, `u`.`ShippingAddress_AddressLine10`, `u`.`ShippingAddress_AddressLine20`, `u`.`ShippingAddress_Tags0`, `u`.`ShippingAddress_ZipCode0`, `u`.`ShippingAddress_Country_Code0`, `u`.`ShippingAddress_Country_FullName0` + SELECT `u`.`Id`, `u`.`Name`, `u`.`BillingAddress_AddressLine1`, `u`.`BillingAddress_AddressLine2`, `u`.`BillingAddress_Tags`, `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_Country_Code`, `u`.`BillingAddress_Country_FullName`, `u`.`OptionalAddress_AddressLine1`, `u`.`OptionalAddress_AddressLine2`, `u`.`OptionalAddress_Tags`, `u`.`OptionalAddress_ZipCode`, `u`.`OptionalAddress_Country_Code`, `u`.`OptionalAddress_Country_FullName`, `u`.`ShippingAddress_AddressLine1`, `u`.`ShippingAddress_AddressLine2`, `u`.`ShippingAddress_Tags`, `u`.`ShippingAddress_ZipCode`, `u`.`ShippingAddress_Country_Code`, `u`.`ShippingAddress_Country_FullName`, `u`.`Id0`, `u`.`Name0`, `u`.`BillingAddress_AddressLine10`, `u`.`BillingAddress_AddressLine20`, `u`.`BillingAddress_Tags0`, `u`.`BillingAddress_ZipCode0`, `u`.`BillingAddress_Country_Code0`, `u`.`BillingAddress_Country_FullName0`, `u`.`OptionalAddress_AddressLine10`, `u`.`OptionalAddress_AddressLine20`, `u`.`OptionalAddress_Tags0`, `u`.`OptionalAddress_ZipCode0`, `u`.`OptionalAddress_Country_Code0`, `u`.`OptionalAddress_Country_FullName0`, `u`.`ShippingAddress_AddressLine10`, `u`.`ShippingAddress_AddressLine20`, `u`.`ShippingAddress_Tags0`, `u`.`ShippingAddress_ZipCode0`, `u`.`ShippingAddress_Country_Code0`, `u`.`ShippingAddress_Country_FullName0` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`OptionalAddress_AddressLine1` AS `OptionalAddress_AddressLine10`, `c0`.`OptionalAddress_AddressLine2` AS `OptionalAddress_AddressLine20`, `c0`.`OptionalAddress_Tags` AS `OptionalAddress_Tags0`, `c0`.`OptionalAddress_ZipCode` AS `OptionalAddress_ZipCode0`, `c0`.`OptionalAddress_Country_Code` AS `OptionalAddress_Country_Code0`, `c0`.`OptionalAddress_Country_FullName` AS `OptionalAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` UNION - SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c2`.`Id` AS `Id0`, `c2`.`Name` AS `Name0`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c2`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c2`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c2`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c2`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c2`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c2`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`OptionalAddress_AddressLine1`, `c1`.`OptionalAddress_AddressLine2`, `c1`.`OptionalAddress_Tags`, `c1`.`OptionalAddress_ZipCode`, `c1`.`OptionalAddress_Country_Code`, `c1`.`OptionalAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c2`.`Id` AS `Id0`, `c2`.`Name` AS `Name0`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c2`.`OptionalAddress_AddressLine1` AS `OptionalAddress_AddressLine10`, `c2`.`OptionalAddress_AddressLine2` AS `OptionalAddress_AddressLine20`, `c2`.`OptionalAddress_Tags` AS `OptionalAddress_Tags0`, `c2`.`OptionalAddress_ZipCode` AS `OptionalAddress_ZipCode0`, `c2`.`OptionalAddress_Country_Code` AS `OptionalAddress_Country_Code0`, `c2`.`OptionalAddress_Country_FullName` AS `OptionalAddress_Country_FullName0`, `c2`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c2`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c2`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c2`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c2`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c2`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c1` CROSS JOIN `Customer` AS `c2` ) AS `u` ORDER BY `u`.`Id`, `u`.`Id0` - LIMIT @__p_0 + LIMIT @p ) AS `u0` ) AS `u1` ORDER BY `u1`.`Id`, `u1`.`Id0` -LIMIT @__p_0 +LIMIT @p """); } @@ -956,7 +928,7 @@ public override async Task Union_of_same_nested_complex_type_projected_twice_wit AssertSql( """ -@__p_0='50' +@p='50' SELECT `u`.`BillingAddress_AddressLine1`, `u`.`BillingAddress_AddressLine2`, `u`.`BillingAddress_Tags`, `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_Country_Code`, `u`.`BillingAddress_Country_FullName`, `u`.`BillingAddress_AddressLine10`, `u`.`BillingAddress_AddressLine20`, `u`.`BillingAddress_Tags0`, `u`.`BillingAddress_ZipCode0`, `u`.`BillingAddress_Country_Code0`, `u`.`BillingAddress_Country_FullName0` FROM ( @@ -969,7 +941,7 @@ CROSS JOIN `Customer` AS `c0` CROSS JOIN `Customer` AS `c2` ) AS `u` ORDER BY `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_ZipCode0` -LIMIT @__p_0 +LIMIT @p """); } @@ -979,7 +951,7 @@ public override async Task Union_of_same_nested_complex_type_projected_twice_wit AssertSql( """ -@__p_0='50' +@p='50' SELECT `u1`.`BillingAddress_AddressLine1`, `u1`.`BillingAddress_AddressLine2`, `u1`.`BillingAddress_Tags`, `u1`.`BillingAddress_ZipCode`, `u1`.`BillingAddress_Country_Code`, `u1`.`BillingAddress_Country_FullName`, `u1`.`BillingAddress_AddressLine10`, `u1`.`BillingAddress_AddressLine20`, `u1`.`BillingAddress_Tags0`, `u1`.`BillingAddress_ZipCode0`, `u1`.`BillingAddress_Country_Code0`, `u1`.`BillingAddress_Country_FullName0` FROM ( @@ -996,11 +968,11 @@ CROSS JOIN `Customer` AS `c0` CROSS JOIN `Customer` AS `c2` ) AS `u` ORDER BY `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_ZipCode0` - LIMIT @__p_0 + LIMIT @p ) AS `u0` ) AS `u1` ORDER BY `u1`.`BillingAddress_ZipCode`, `u1`.`BillingAddress_ZipCode0` -LIMIT @__p_0 +LIMIT @p """); } @@ -1010,10 +982,10 @@ public override async Task Same_entity_with_complex_type_projected_twice_with_pu AssertSql( """ -SELECT `c`.`Id`, `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_Tags`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_Tags0`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0`, `s`.`c` +SELECT `c`.`Id`, `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`OptionalAddress_AddressLine1`, `s`.`OptionalAddress_AddressLine2`, `s`.`OptionalAddress_Tags`, `s`.`OptionalAddress_ZipCode`, `s`.`OptionalAddress_Country_Code`, `s`.`OptionalAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_Tags`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`OptionalAddress_AddressLine10`, `s`.`OptionalAddress_AddressLine20`, `s`.`OptionalAddress_Tags0`, `s`.`OptionalAddress_ZipCode0`, `s`.`OptionalAddress_Country_Code0`, `s`.`OptionalAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_Tags0`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0`, `s`.`c` FROM `Customer` AS `c` LEFT JOIN LATERAL ( - SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, `c1`.`Id` AS `Id0`, `c1`.`Name` AS `Name0`, `c1`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c1`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c1`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c1`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c1`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c1`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c1`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c1`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c1`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c1`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c1`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c1`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0`, 1 AS `c` + SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`OptionalAddress_AddressLine1`, `c0`.`OptionalAddress_AddressLine2`, `c0`.`OptionalAddress_Tags`, `c0`.`OptionalAddress_ZipCode`, `c0`.`OptionalAddress_Country_Code`, `c0`.`OptionalAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, `c1`.`Id` AS `Id0`, `c1`.`Name` AS `Name0`, `c1`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c1`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c1`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c1`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c1`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c1`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c1`.`OptionalAddress_AddressLine1` AS `OptionalAddress_AddressLine10`, `c1`.`OptionalAddress_AddressLine2` AS `OptionalAddress_AddressLine20`, `c1`.`OptionalAddress_Tags` AS `OptionalAddress_Tags0`, `c1`.`OptionalAddress_ZipCode` AS `OptionalAddress_ZipCode0`, `c1`.`OptionalAddress_Country_Code` AS `OptionalAddress_Country_Code0`, `c1`.`OptionalAddress_Country_FullName` AS `OptionalAddress_Country_FullName0`, `c1`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c1`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c1`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c1`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c1`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c1`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0`, 1 AS `c` FROM `Customer` AS `c0` CROSS JOIN `Customer` AS `c1` ORDER BY `c0`.`Id`, `c1`.`Id` DESC @@ -1071,16 +1043,16 @@ public override async Task Entity_with_complex_type_with_group_by_and_first(bool AssertSql( """ -SELECT `c3`.`Id`, `c3`.`Name`, `c3`.`BillingAddress_AddressLine1`, `c3`.`BillingAddress_AddressLine2`, `c3`.`BillingAddress_Tags`, `c3`.`BillingAddress_ZipCode`, `c3`.`BillingAddress_Country_Code`, `c3`.`BillingAddress_Country_FullName`, `c3`.`ShippingAddress_AddressLine1`, `c3`.`ShippingAddress_AddressLine2`, `c3`.`ShippingAddress_Tags`, `c3`.`ShippingAddress_ZipCode`, `c3`.`ShippingAddress_Country_Code`, `c3`.`ShippingAddress_Country_FullName` +SELECT `c3`.`Id`, `c3`.`Name`, `c3`.`BillingAddress_AddressLine1`, `c3`.`BillingAddress_AddressLine2`, `c3`.`BillingAddress_Tags`, `c3`.`BillingAddress_ZipCode`, `c3`.`BillingAddress_Country_Code`, `c3`.`BillingAddress_Country_FullName`, `c3`.`OptionalAddress_AddressLine1`, `c3`.`OptionalAddress_AddressLine2`, `c3`.`OptionalAddress_Tags`, `c3`.`OptionalAddress_ZipCode`, `c3`.`OptionalAddress_Country_Code`, `c3`.`OptionalAddress_Country_FullName`, `c3`.`ShippingAddress_AddressLine1`, `c3`.`ShippingAddress_AddressLine2`, `c3`.`ShippingAddress_Tags`, `c3`.`ShippingAddress_ZipCode`, `c3`.`ShippingAddress_Country_Code`, `c3`.`ShippingAddress_Country_FullName` FROM ( SELECT `c`.`Id` FROM `Customer` AS `c` GROUP BY `c`.`Id` ) AS `c1` LEFT JOIN ( - SELECT `c2`.`Id`, `c2`.`Name`, `c2`.`BillingAddress_AddressLine1`, `c2`.`BillingAddress_AddressLine2`, `c2`.`BillingAddress_Tags`, `c2`.`BillingAddress_ZipCode`, `c2`.`BillingAddress_Country_Code`, `c2`.`BillingAddress_Country_FullName`, `c2`.`ShippingAddress_AddressLine1`, `c2`.`ShippingAddress_AddressLine2`, `c2`.`ShippingAddress_Tags`, `c2`.`ShippingAddress_ZipCode`, `c2`.`ShippingAddress_Country_Code`, `c2`.`ShippingAddress_Country_FullName` + SELECT `c2`.`Id`, `c2`.`Name`, `c2`.`BillingAddress_AddressLine1`, `c2`.`BillingAddress_AddressLine2`, `c2`.`BillingAddress_Tags`, `c2`.`BillingAddress_ZipCode`, `c2`.`BillingAddress_Country_Code`, `c2`.`BillingAddress_Country_FullName`, `c2`.`OptionalAddress_AddressLine1`, `c2`.`OptionalAddress_AddressLine2`, `c2`.`OptionalAddress_Tags`, `c2`.`OptionalAddress_ZipCode`, `c2`.`OptionalAddress_Country_Code`, `c2`.`OptionalAddress_Country_FullName`, `c2`.`ShippingAddress_AddressLine1`, `c2`.`ShippingAddress_AddressLine2`, `c2`.`ShippingAddress_Tags`, `c2`.`ShippingAddress_ZipCode`, `c2`.`ShippingAddress_Country_Code`, `c2`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, ROW_NUMBER() OVER(PARTITION BY `c0`.`Id` ORDER BY `c0`.`Id`) AS `row` + SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`OptionalAddress_AddressLine1`, `c0`.`OptionalAddress_AddressLine2`, `c0`.`OptionalAddress_Tags`, `c0`.`OptionalAddress_ZipCode`, `c0`.`OptionalAddress_Country_Code`, `c0`.`OptionalAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, ROW_NUMBER() OVER(PARTITION BY `c0`.`Id` ORDER BY `c0`.`Id`) AS `row` FROM `Customer` AS `c0` ) AS `c2` WHERE `c2`.`row` <= 1 @@ -1110,7 +1082,7 @@ public override async Task Projecting_complex_from_optional_navigation_using_con AssertSql( """ -@__p_0='20' +@p='20' SELECT `s0`.`ShippingAddress_ZipCode` FROM ( @@ -1120,7 +1092,7 @@ public override async Task Projecting_complex_from_optional_navigation_using_con FROM `CustomerGroup` AS `c` LEFT JOIN `Customer` AS `c0` ON `c`.`OptionalCustomerId` = `c0`.`Id` ORDER BY `c0`.`ShippingAddress_ZipCode` - LIMIT @__p_0 + LIMIT @p ) AS `s` ) AS `s0` """); @@ -1132,26 +1104,26 @@ public override async Task Project_entity_with_complex_type_pushdown_and_then_le AssertSql( """ -@__p_0='20' -@__p_1='30' +@p='20' +@p0='30' SELECT `c3`.`BillingAddress_ZipCode` AS `Zip1`, `c4`.`ShippingAddress_ZipCode` AS `Zip2` FROM ( - SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` + SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`OptionalAddress_AddressLine1`, `c0`.`OptionalAddress_AddressLine2`, `c0`.`OptionalAddress_Tags`, `c0`.`OptionalAddress_ZipCode`, `c0`.`OptionalAddress_Country_Code`, `c0`.`OptionalAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`OptionalAddress_AddressLine1`, `c`.`OptionalAddress_AddressLine2`, `c`.`OptionalAddress_Tags`, `c`.`OptionalAddress_ZipCode`, `c`.`OptionalAddress_Country_Code`, `c`.`OptionalAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` ORDER BY `c`.`Id` - LIMIT @__p_0 + LIMIT @p ) AS `c0` ) AS `c3` LEFT JOIN ( - SELECT DISTINCT `c2`.`Id`, `c2`.`Name`, `c2`.`BillingAddress_AddressLine1`, `c2`.`BillingAddress_AddressLine2`, `c2`.`BillingAddress_Tags`, `c2`.`BillingAddress_ZipCode`, `c2`.`BillingAddress_Country_Code`, `c2`.`BillingAddress_Country_FullName`, `c2`.`ShippingAddress_AddressLine1`, `c2`.`ShippingAddress_AddressLine2`, `c2`.`ShippingAddress_Tags`, `c2`.`ShippingAddress_ZipCode`, `c2`.`ShippingAddress_Country_Code`, `c2`.`ShippingAddress_Country_FullName` + SELECT DISTINCT `c2`.`Id`, `c2`.`Name`, `c2`.`BillingAddress_AddressLine1`, `c2`.`BillingAddress_AddressLine2`, `c2`.`BillingAddress_Tags`, `c2`.`BillingAddress_ZipCode`, `c2`.`BillingAddress_Country_Code`, `c2`.`BillingAddress_Country_FullName`, `c2`.`OptionalAddress_AddressLine1`, `c2`.`OptionalAddress_AddressLine2`, `c2`.`OptionalAddress_Tags`, `c2`.`OptionalAddress_ZipCode`, `c2`.`OptionalAddress_Country_Code`, `c2`.`OptionalAddress_Country_FullName`, `c2`.`ShippingAddress_AddressLine1`, `c2`.`ShippingAddress_AddressLine2`, `c2`.`ShippingAddress_Tags`, `c2`.`ShippingAddress_ZipCode`, `c2`.`ShippingAddress_Country_Code`, `c2`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName` + SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`OptionalAddress_AddressLine1`, `c1`.`OptionalAddress_AddressLine2`, `c1`.`OptionalAddress_Tags`, `c1`.`OptionalAddress_ZipCode`, `c1`.`OptionalAddress_Country_Code`, `c1`.`OptionalAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c1` ORDER BY `c1`.`Id` DESC - LIMIT @__p_1 + LIMIT @p0 ) AS `c2` ) AS `c4` ON `c3`.`Id` = `c4`.`Id` """); diff --git a/test/EFCore.MySql.FunctionalTests/Query/DateOnlyQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/DateOnlyQueryMySqlTest.cs index 43937b2e5..7326a9ceb 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/DateOnlyQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/DateOnlyQueryMySqlTest.cs @@ -1,6 +1,5 @@ -using System; +using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; @@ -34,12 +33,14 @@ await AssertSingle( .Where(i => i.BestServedBefore.DayNumber - todayDateTime.DayNumber < 30)); AssertSql( - $@"@__todayDateTime_DayNumber_0='{todayDateTime.DayNumber}' +$""" +@todayDateTime_DayNumber='{todayDateTime.DayNumber}' SELECT `i`.`IceCreamId`, `i`.`BestServedBefore`, `i`.`Name` FROM `IceCream` AS `i` -WHERE ((TO_DAYS(`i`.`BestServedBefore`) - 366) - @__todayDateTime_DayNumber_0) < 30 -LIMIT 2"); +WHERE ((TO_DAYS(`i`.`BestServedBefore`) - 366) - @todayDateTime_DayNumber) < 30 +LIMIT 2 +"""); } [ConditionalTheory] @@ -54,12 +55,14 @@ await AssertSingle( .Where(i => i.BestServedBefore.DayNumber == matchaExpireDayNumber)); AssertSql( - @"@__matchaExpireDayNumber_0='839691' +""" +@matchaExpireDayNumber='839691' SELECT `i`.`IceCreamId`, `i`.`BestServedBefore`, `i`.`Name` FROM `IceCream` AS `i` -WHERE (TO_DAYS(`i`.`BestServedBefore`) - 366) = @__matchaExpireDayNumber_0 -LIMIT 2"); +WHERE (TO_DAYS(`i`.`BestServedBefore`) - 366) = @matchaExpireDayNumber +LIMIT 2 +"""); } [ConditionalTheory] @@ -74,12 +77,14 @@ await AssertSingle( .Where(i => i.BestServedBefore.ToDateTime(new TimeOnly(12, 21, 42)) == matchExpireDateTime)); AssertSql( - @"@__matchExpireDateTime_0='2299-12-31T12:21:42.0000000' (DbType = DateTime) +""" +@matchExpireDateTime='2299-12-31T12:21:42.0000000' (DbType = DateTime) SELECT `i`.`IceCreamId`, `i`.`BestServedBefore`, `i`.`Name` FROM `IceCream` AS `i` -WHERE ADDTIME(CAST(`i`.`BestServedBefore` AS datetime(6)), TIME '12:21:42') = @__matchExpireDateTime_0 -LIMIT 2"); +WHERE ADDTIME(CAST(`i`.`BestServedBefore` AS datetime(6)), TIME '12:21:42') = @matchExpireDateTime +LIMIT 2 +"""); } [ConditionalTheory] @@ -94,12 +99,14 @@ await AssertSingle( .Where(i => i.BestServedBefore.ToDateTime(new TimeOnly()) == matchExpireDateTime)); AssertSql( - @"@__matchExpireDateTime_0='2299-12-31T00:00:00.0000000' (DbType = DateTime) +""" +@matchExpireDateTime='2299-12-31T00:00:00.0000000' (DbType = DateTime) SELECT `i`.`IceCreamId`, `i`.`BestServedBefore`, `i`.`Name` FROM `IceCream` AS `i` -WHERE CAST(`i`.`BestServedBefore` AS datetime(6)) = @__matchExpireDateTime_0 -LIMIT 2"); +WHERE CAST(`i`.`BestServedBefore` AS datetime(6)) = @matchExpireDateTime +LIMIT 2 +"""); } [ConditionalTheory] @@ -131,12 +138,14 @@ public async Task DateDiffDay(bool isAsync) Assert.Single(result); - AssertSql( - $@"@__todayDateOnly_1='{todayDateOnly:MM'/'dd'/'yyyy}' (DbType = Date) + AssertSql( +$""" +@todayDateOnly='{todayDateOnly:MM'/'dd'/'yyyy}' (DbType = Date) SELECT `i`.`IceCreamId`, `i`.`BestServedBefore`, `i`.`Name` FROM `IceCream` AS `i` -WHERE TIMESTAMPDIFF(DAY, @__todayDateOnly_1, `i`.`BestServedBefore`) < 30"); +WHERE TIMESTAMPDIFF(DAY, @todayDateOnly, `i`.`BestServedBefore`) < 30 +"""); } [ConditionalTheory] diff --git a/test/EFCore.MySql.FunctionalTests/Query/Ef6GroupByMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Ef6GroupByMySqlTest.cs index e18c57229..39c852b13 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/Ef6GroupByMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/Ef6GroupByMySqlTest.cs @@ -754,7 +754,7 @@ public override async Task Whats_new_2021_sample_7(bool async) AssertSql( """ -@__size_0='11' +@size='11' SELECT `p0`.`LastName`, `f`.`Size`, ( SELECT MIN(`f1`.`Size`) @@ -762,11 +762,11 @@ SELECT MIN(`f1`.`Size`) LEFT JOIN `Feet` AS `f0` ON `p1`.`Id` = `f0`.`Id` LEFT JOIN `Person` AS `p2` ON `f0`.`Id` = `p2`.`Id` LEFT JOIN `Feet` AS `f1` ON `p1`.`Id` = `f1`.`Id` - WHERE (((`f0`.`Size` = @__size_0) AND `p1`.`MiddleInitial` IS NOT NULL) AND ((`f0`.`Id` <> 1) OR `f0`.`Id` IS NULL)) AND (((`f`.`Size` = `f0`.`Size`) OR (`f`.`Size` IS NULL AND (`f0`.`Size` IS NULL))) AND ((`p0`.`LastName` = `p2`.`LastName`) OR (`p0`.`LastName` IS NULL AND (`p2`.`LastName` IS NULL))))) AS `Min` + WHERE (((`f0`.`Size` = @size) AND `p1`.`MiddleInitial` IS NOT NULL) AND ((`f0`.`Id` <> 1) OR `f0`.`Id` IS NULL)) AND (((`f`.`Size` = `f0`.`Size`) OR (`f`.`Size` IS NULL AND (`f0`.`Size` IS NULL))) AND ((`p0`.`LastName` = `p2`.`LastName`) OR (`p0`.`LastName` IS NULL AND (`p2`.`LastName` IS NULL))))) AS `Min` FROM `Person` AS `p` LEFT JOIN `Feet` AS `f` ON `p`.`Id` = `f`.`Id` LEFT JOIN `Person` AS `p0` ON `f`.`Id` = `p0`.`Id` -WHERE ((`f`.`Size` = @__size_0) AND `p`.`MiddleInitial` IS NOT NULL) AND ((`f`.`Id` <> 1) OR `f`.`Id` IS NULL) +WHERE ((`f`.`Size` = @size) AND `p`.`MiddleInitial` IS NOT NULL) AND ((`f`.`Id` <> 1) OR `f`.`Id` IS NULL) GROUP BY `f`.`Size`, `p0`.`LastName` """); } diff --git a/test/EFCore.MySql.FunctionalTests/Query/EntitySplittingQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/EntitySplittingQueryMySqlTest.cs index d1456a8ab..7e7db5180 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/EntitySplittingQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/EntitySplittingQueryMySqlTest.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; @@ -9,7 +10,8 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class EntitySplittingQueryMySqlTest : EntitySplittingQueryTestBase { - public EntitySplittingQueryMySqlTest(ITestOutputHelper testOutputHelper) + public EntitySplittingQueryMySqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) { // Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } diff --git a/test/EFCore.MySql.FunctionalTests/Query/EscapesMySqlNoBackslashesTest.cs b/test/EFCore.MySql.FunctionalTests/Query/EscapesMySqlNoBackslashesTest.cs index 461cdc759..cddc28732 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/EscapesMySqlNoBackslashesTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/EscapesMySqlNoBackslashesTest.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.Infrastructure.Internal; @@ -69,11 +69,13 @@ public override async Task Where_query_escapes_parameter(bool async) await base.Where_query_escapes_parameter(async); AssertSql( - @"@__artistName_0='Back\slasher's' (Size = 4000) +""" +@artistName='Back\slasher's' (Size = 4000) SELECT `a`.`ArtistId`, `a`.`Name` FROM `Artists` AS `a` -WHERE `a`.`Name` = @__artistName_0"); +WHERE `a`.`Name` = @artistName +"""); } [ConditionalTheory] @@ -100,9 +102,12 @@ FROM JSON_TABLE('["Back\\slasher\u0027s","John\u0027s Chill Box"]', '$[*]' COLUM { AssertSql( """ +@artistNames1='Back\slasher's' (Size = 4000) +@artistNames2='John's Chill Box' (Size = 4000) + SELECT `a`.`ArtistId`, `a`.`Name` FROM `Artists` AS `a` -WHERE `a`.`Name` IN ('Back\slasher''s', 'John''s Chill Box') +WHERE `a`.`Name` IN (@artistNames1, @artistNames2) """); } } diff --git a/test/EFCore.MySql.FunctionalTests/Query/EscapesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/EscapesMySqlTest.cs index d58d53b60..f7f5ad088 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/EscapesMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/EscapesMySqlTest.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.Tests; @@ -68,11 +68,13 @@ public override async Task Where_query_escapes_parameter(bool async) await base.Where_query_escapes_parameter(async); AssertSql( - @"@__artistName_0='Back\slasher's' (Size = 4000) +""" +@artistName='Back\slasher's' (Size = 4000) SELECT `a`.`ArtistId`, `a`.`Name` FROM `Artists` AS `a` -WHERE `a`.`Name` = @__artistName_0"); +WHERE `a`.`Name` = @artistName +"""); } [ConditionalTheory] @@ -99,9 +101,12 @@ FROM JSON_TABLE('["Back\\\\slasher\\u0027s","John\\u0027s Chill Box"]', '$[*]' C { AssertSql( """ +@artistNames1='Back\slasher's' (Size = 4000) +@artistNames2='John's Chill Box' (Size = 4000) + SELECT `a`.`ArtistId`, `a`.`Name` FROM `Artists` AS `a` -WHERE `a`.`Name` IN ('Back\\slasher''s', 'John''s Chill Box') +WHERE `a`.`Name` IN (@artistNames1, @artistNames2) """); } } diff --git a/test/EFCore.MySql.FunctionalTests/Query/GearsOfWarQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/GearsOfWarQueryMySqlTest.cs index 081add88c..ec7fa40bc 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/GearsOfWarQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/GearsOfWarQueryMySqlTest.cs @@ -34,24 +34,6 @@ public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) m => start <= m.Timeline.Date && m.Timeline < end && dates.Contains(m.Timeline))); } - public override Task Where_datetimeoffset_milliseconds_parameter_and_constant(bool async) - { - var dateTimeOffset = MySqlTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0))); - - // Literal where clause - var p = Expression.Parameter(typeof(Mission), "i"); - var dynamicWhere = Expression.Lambda>( - Expression.Equal( - Expression.Property(p, "Timeline"), - Expression.Constant(dateTimeOffset) - ), p); - - return AssertCount( - async, - ss => ss.Set().Where(dynamicWhere), - ss => ss.Set().Where(m => m.Timeline == dateTimeOffset)); - } - [ConditionalTheory(Skip = "TODO: Does not work as expected, probably due to some test definition issues.")] public override async Task DateTimeOffsetNow_minus_timespan(bool async) { @@ -250,60 +232,6 @@ GROUP BY `g0`.`Key` """); } - public override async Task Array_access_on_byte_array(bool async) - { - await base.Array_access_on_byte_array(async); - - AssertSql( -""" -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` -FROM `Squads` AS `s` -WHERE ASCII(SUBSTRING(`s`.`Banner5`, 2 + 1, 1)) = 6 -"""); - } - - public override async Task DateTimeOffset_to_unix_time_milliseconds(bool async) - { - await base.DateTimeOffset_to_unix_time_milliseconds(async); - - AssertSql( -""" -@__unixEpochMilliseconds_0='0' - -SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`Discriminator`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s1`.`SquadId`, `s1`.`MissionId` -FROM `Gears` AS `g` -INNER JOIN `Squads` AS `s` ON `g`.`SquadId` = `s`.`Id` -LEFT JOIN `SquadMissions` AS `s1` ON `s`.`Id` = `s1`.`SquadId` -WHERE NOT EXISTS ( - SELECT 1 - FROM `SquadMissions` AS `s0` - INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` - WHERE (`s`.`Id` = `s0`.`SquadId`) AND (@__unixEpochMilliseconds_0 = (TIMESTAMPDIFF(microsecond, TIMESTAMP '1970-01-01 00:00:00', `m`.`Timeline`)) DIV (1000))) -ORDER BY `g`.`Nickname`, `g`.`SquadId`, `s`.`Id`, `s1`.`SquadId` -"""); - } - - public override async Task DateTimeOffset_to_unix_time_seconds(bool async) - { - await base.DateTimeOffset_to_unix_time_seconds(async); - - AssertSql( -""" -@__unixEpochSeconds_0='0' - -SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`Discriminator`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s1`.`SquadId`, `s1`.`MissionId` -FROM `Gears` AS `g` -INNER JOIN `Squads` AS `s` ON `g`.`SquadId` = `s`.`Id` -LEFT JOIN `SquadMissions` AS `s1` ON `s`.`Id` = `s1`.`SquadId` -WHERE NOT EXISTS ( - SELECT 1 - FROM `SquadMissions` AS `s0` - INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` - WHERE (`s`.`Id` = `s0`.`SquadId`) AND (@__unixEpochSeconds_0 = TIMESTAMPDIFF(second, TIMESTAMP '1970-01-01 00:00:00', `m`.`Timeline`))) -ORDER BY `g`.`Nickname`, `g`.`SquadId`, `s`.`Id`, `s1`.`SquadId` -"""); - } - public override async Task Group_by_with_having_StartsWith_with_null_parameter_as_argument(bool async) { await base.Group_by_with_having_StartsWith_with_null_parameter_as_argument(async); @@ -339,22 +267,6 @@ public override async Task Where_subquery_with_ElementAt_using_column_as_index(b AssertSql(""); } - public override async Task Where_datetimeoffset_hour_component(bool async) - { - await AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Hour == /* 10 */ 8 - select m); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(hour FROM `m`.`Timeline`) = 8 -"""); - } - // TODO: Implement once TimeSpan is translated as ticks instead of TIME. public override async Task Non_string_concat_uses_appropriate_type_mapping(bool async) { diff --git a/test/EFCore.MySql.FunctionalTests/Query/JsonMicrosoftDomQueryTest.cs b/test/EFCore.MySql.FunctionalTests/Query/JsonMicrosoftDomQueryTest.cs index c5494e442..415bc8dc1 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/JsonMicrosoftDomQueryTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/JsonMicrosoftDomQueryTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Text.Json; using System.Threading.Tasks; @@ -77,19 +77,23 @@ public void Parameter_document() Assert.Equal(actual, expected); AssertSql( - @"@__p_0='1' +""" +@p='1' SELECT `j`.`Id`, `j`.`CustomerDocument`, `j`.`CustomerElement` FROM `JsonEntities` AS `j` -WHERE `j`.`Id` = @__p_0 -LIMIT 1", +WHERE `j`.`Id` = @p +LIMIT 1 +""", // - $@"{InsertJsonDocument(@"@__expected_0='{""ID"":""00000000-0000-0000-0000-000000000000"",""Age"":25,""Name"":""Joe"",""IsVip"":false,""Orders"":[{""Price"":99.5,""ShippingDate"":""2019-10-01"",""ShippingAddress"":""Some address 1""},{""Price"":23.1,""ShippingDate"":""2019-10-10"",""ShippingAddress"":""Some address 2""}],""Statistics"":{""Nested"":{""IntArray"":[3,4],""SomeProperty"":10,""SomeNullableInt"":20,""SomeNullableGuid"":""d5f2685d-e5c4-47e5-97aa-d0266154eb2d""},""Visits"":4,""Purchases"":3}}'", @"@__expected_0='{""Name"":""Joe"",""Age"":25,""ID"":""00000000-0000-0000-0000-000000000000"",""IsVip"":false,""Statistics"":{""Visits"":4,""Purchases"":3,""Nested"":{""SomeProperty"":10,""SomeNullableInt"":20,""SomeNullableGuid"":""d5f2685d-e5c4-47e5-97aa-d0266154eb2d"",""IntArray"":[3,4]}},""Orders"":[{""Price"":99.5,""ShippingAddress"":""Some address 1"",""ShippingDate"":""2019-10-01""},{""Price"":23.1,""ShippingAddress"":""Some address 2"",""ShippingDate"":""2019-10-10""}]}'")} (Size = 4000) + """ +@expected='{"ID":"00000000-0000-0000-0000-000000000000","Age":25,"Name":"Joe","IsVip":false,"Orders":[{"Price":99.5,"ShippingDate":"2019-10-01","ShippingAddress":"Some address 1"},{"Price":23.1,"ShippingDate":"2019-10-10","ShippingAddress":"Some address 2"}],"Statistics":{"Nested":{"IntArray":[3,4],"SomeProperty":10,"SomeNullableInt":20,"SomeNullableGuid":"d5f2685d-e5c4-47e5-97aa-d0266154eb2d"},"Visits":4,"Purchases":3}}' (Size = 4000) SELECT `j`.`Id`, `j`.`CustomerDocument`, `j`.`CustomerElement` FROM `JsonEntities` AS `j` -WHERE `j`.`CustomerDocument` = {InsertJsonConvert("@__expected_0")} -LIMIT 2"); +WHERE `j`.`CustomerDocument` = CAST(@expected AS json) +LIMIT 2 +"""); } [Fact] @@ -101,19 +105,23 @@ public void Parameter_element() Assert.Equal(actual, expected); AssertSql( - @"@__p_0='1' +""" +@p='1' SELECT `j`.`Id`, `j`.`CustomerDocument`, `j`.`CustomerElement` FROM `JsonEntities` AS `j` -WHERE `j`.`Id` = @__p_0 -LIMIT 1", +WHERE `j`.`Id` = @p +LIMIT 1 +""", // - $@"{InsertJsonDocument(@"@__expected_0='{""ID"":""00000000-0000-0000-0000-000000000000"",""Age"":25,""Name"":""Joe"",""IsVip"":false,""Orders"":[{""Price"":99.5,""ShippingDate"":""2019-10-01"",""ShippingAddress"":""Some address 1""},{""Price"":23.1,""ShippingDate"":""2019-10-10"",""ShippingAddress"":""Some address 2""}],""Statistics"":{""Nested"":{""IntArray"":[3,4],""SomeProperty"":10,""SomeNullableInt"":20,""SomeNullableGuid"":""d5f2685d-e5c4-47e5-97aa-d0266154eb2d""},""Visits"":4,""Purchases"":3}}'", @"@__expected_0='{""Name"":""Joe"",""Age"":25,""ID"":""00000000-0000-0000-0000-000000000000"",""IsVip"":false,""Statistics"":{""Visits"":4,""Purchases"":3,""Nested"":{""SomeProperty"":10,""SomeNullableInt"":20,""SomeNullableGuid"":""d5f2685d-e5c4-47e5-97aa-d0266154eb2d"",""IntArray"":[3,4]}},""Orders"":[{""Price"":99.5,""ShippingAddress"":""Some address 1"",""ShippingDate"":""2019-10-01""},{""Price"":23.1,""ShippingAddress"":""Some address 2"",""ShippingDate"":""2019-10-10""}]}'")} (Nullable = false) (Size = 4000) + """ +@expected='{"ID":"00000000-0000-0000-0000-000000000000","Age":25,"Name":"Joe","IsVip":false,"Orders":[{"Price":99.5,"ShippingDate":"2019-10-01","ShippingAddress":"Some address 1"},{"Price":23.1,"ShippingDate":"2019-10-10","ShippingAddress":"Some address 2"}],"Statistics":{"Nested":{"IntArray":[3,4],"SomeProperty":10,"SomeNullableInt":20,"SomeNullableGuid":"d5f2685d-e5c4-47e5-97aa-d0266154eb2d"},"Visits":4,"Purchases":3}}' (Nullable = false) (Size = 4000) SELECT `j`.`Id`, `j`.`CustomerDocument`, `j`.`CustomerElement` FROM `JsonEntities` AS `j` -WHERE `j`.`CustomerElement` = {InsertJsonConvert("@__expected_0")} -LIMIT 2"); +WHERE `j`.`CustomerElement` = CAST(@expected AS json) +LIMIT 2 +"""); } [Fact] @@ -253,12 +261,14 @@ public void Array_parameter_index() Assert.Equal("Joe", x.CustomerElement.GetProperty("Name").GetString()); AssertSql( - @"@__i_0='1' +""" +@i='1' SELECT `j`.`Id`, `j`.`CustomerDocument`, `j`.`CustomerElement` FROM `JsonEntities` AS `j` -WHERE JSON_EXTRACT(`j`.`CustomerElement`, CONCAT('$.Statistics.Nested.IntArray[', @__i_0, ']')) = 4 -LIMIT 2"); +WHERE JSON_EXTRACT(`j`.`CustomerElement`, CONCAT('$.Statistics.Nested.IntArray[', @i, ']')) = 4 +LIMIT 2 +"""); } [Fact] @@ -331,11 +341,11 @@ public void JsonOverlaps_with_json_element() Assert.Equal(1, count); AssertSql( - $@"@__element_1='{{""Name"":""Joe"",""Age"":-1}}' (Nullable = false) (Size = 4000) + $@"@element='{{""Name"":""Joe"",""Age"":-1}}' (Nullable = false) (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_OVERLAPS(`j`.`CustomerElement`, {InsertJsonConvert("@__element_1")})"); +WHERE JSON_OVERLAPS(`j`.`CustomerElement`, {InsertJsonConvert("@element")})"); } [ConditionalFact] @@ -364,11 +374,11 @@ public void JsonOverlaps_using_JsonExtract_with_json_element() Assert.Equal(1, count); AssertSql( - $@"@__element_1='[3,-1]' (Nullable = false) (Size = 4000) + $@"@element='[3,-1]' (Nullable = false) (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_OVERLAPS(JSON_EXTRACT(`j`.`CustomerElement`, '$.Statistics.Nested.IntArray'), {InsertJsonConvert("@__element_1")})"); +WHERE JSON_OVERLAPS(JSON_EXTRACT(`j`.`CustomerElement`, '$.Statistics.Nested.IntArray'), {InsertJsonConvert("@element")})"); } [ConditionalFact] @@ -396,11 +406,11 @@ public void JsonContains_with_json_element() Assert.Equal(1, count); AssertSql( - $@"@__element_1='{{""Name"":""Joe"",""Age"":25}}' (Nullable = false) (Size = 4000) + $@"@element='{{""Name"":""Joe"",""Age"":25}}' (Nullable = false) (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_CONTAINS(`j`.`CustomerElement`, {InsertJsonConvert("@__element_1")})"); +WHERE JSON_CONTAINS(`j`.`CustomerElement`, {InsertJsonConvert("@element")})"); } [Fact] diff --git a/test/EFCore.MySql.FunctionalTests/Query/JsonMicrosoftPocoQueryTest.cs b/test/EFCore.MySql.FunctionalTests/Query/JsonMicrosoftPocoQueryTest.cs index 9f998454a..2e1031e2d 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/JsonMicrosoftPocoQueryTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/JsonMicrosoftPocoQueryTest.cs @@ -30,11 +30,11 @@ public override void JsonContains_with_json_element() Assert.Equal(1, count); AssertSql( - $@"@__element_1='{{""Name"":""Joe"",""Age"":25}}' (Nullable = false) (Size = 4000) + $@"@element='{{""Name"":""Joe"",""Age"":25}}' (Nullable = false) (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_CONTAINS(`j`.`Customer`, {InsertJsonConvert("@__element_1")})"); +WHERE JSON_CONTAINS(`j`.`Customer`, {InsertJsonConvert("@element")})"); } public class JsonMicrosoftPocoQueryFixture : JsonPocoQueryFixtureBase diff --git a/test/EFCore.MySql.FunctionalTests/Query/JsonNewtonsoftDomQueryTest.cs b/test/EFCore.MySql.FunctionalTests/Query/JsonNewtonsoftDomQueryTest.cs index dad8e037d..afcc68d16 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/JsonNewtonsoftDomQueryTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/JsonNewtonsoftDomQueryTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; @@ -77,19 +77,23 @@ public void Parameter_document() Assert.Equal(actual, expected); AssertSql( - @"@__p_0='1' +""" +@p='1' SELECT `j`.`Id`, `j`.`CustomerJObject`, `j`.`CustomerJToken` FROM `JsonEntities` AS `j` -WHERE `j`.`Id` = @__p_0 -LIMIT 1", +WHERE `j`.`Id` = @p +LIMIT 1 +""", // - $@"{InsertJsonDocument(@"@__expected_0='{""ID"":""00000000-0000-0000-0000-000000000000"",""Age"":25,""Name"":""Joe"",""IsVip"":false,""Orders"":[{""Price"":99.5,""ShippingDate"":""2019-10-01"",""ShippingAddress"":""Some address 1""},{""Price"":23.1,""ShippingDate"":""2019-10-10"",""ShippingAddress"":""Some address 2""}],""Statistics"":{""Nested"":{""IntArray"":[3,4],""SomeProperty"":10,""SomeNullableInt"":20,""SomeNullableGuid"":""d5f2685d-e5c4-47e5-97aa-d0266154eb2d""},""Visits"":4,""Purchases"":3}}'", @"@__expected_0='{""Name"":""Joe"",""Age"":25,""ID"":""00000000-0000-0000-0000-000000000000"",""IsVip"":false,""Statistics"":{""Visits"":4,""Purchases"":3,""Nested"":{""SomeProperty"":10,""SomeNullableInt"":20,""SomeNullableGuid"":""d5f2685d-e5c4-47e5-97aa-d0266154eb2d"",""IntArray"":[3,4]}},""Orders"":[{""Price"":99.5,""ShippingAddress"":""Some address 1"",""ShippingDate"":""2019-10-01""},{""Price"":23.1,""ShippingAddress"":""Some address 2"",""ShippingDate"":""2019-10-10""}]}'")} (Size = 4000) + """ +@expected='{"ID":"00000000-0000-0000-0000-000000000000","Age":25,"Name":"Joe","IsVip":false,"Orders":[{"Price":99.5,"ShippingDate":"2019-10-01","ShippingAddress":"Some address 1"},{"Price":23.1,"ShippingDate":"2019-10-10","ShippingAddress":"Some address 2"}],"Statistics":{"Nested":{"IntArray":[3,4],"SomeProperty":10,"SomeNullableInt":20,"SomeNullableGuid":"d5f2685d-e5c4-47e5-97aa-d0266154eb2d"},"Visits":4,"Purchases":3}}' (Size = 4000) SELECT `j`.`Id`, `j`.`CustomerJObject`, `j`.`CustomerJToken` FROM `JsonEntities` AS `j` -WHERE `j`.`CustomerJObject` = {InsertJsonConvert("@__expected_0")} -LIMIT 2"); +WHERE `j`.`CustomerJObject` = CAST(@expected AS json) +LIMIT 2 +"""); } [Fact] @@ -101,19 +105,23 @@ public void Parameter_element() Assert.Equal(actual, expected); AssertSql( - @"@__p_0='1' +""" +@p='1' SELECT `j`.`Id`, `j`.`CustomerJObject`, `j`.`CustomerJToken` FROM `JsonEntities` AS `j` -WHERE `j`.`Id` = @__p_0 -LIMIT 1", +WHERE `j`.`Id` = @p +LIMIT 1 +""", // - $@"{InsertJsonDocument(@"@__expected_0='{""ID"":""00000000-0000-0000-0000-000000000000"",""Age"":25,""Name"":""Joe"",""IsVip"":false,""Orders"":[{""Price"":99.5,""ShippingDate"":""2019-10-01"",""ShippingAddress"":""Some address 1""},{""Price"":23.1,""ShippingDate"":""2019-10-10"",""ShippingAddress"":""Some address 2""}],""Statistics"":{""Nested"":{""IntArray"":[3,4],""SomeProperty"":10,""SomeNullableInt"":20,""SomeNullableGuid"":""d5f2685d-e5c4-47e5-97aa-d0266154eb2d""},""Visits"":4,""Purchases"":3}}'", @"@__expected_0='{""Name"":""Joe"",""Age"":25,""ID"":""00000000-0000-0000-0000-000000000000"",""IsVip"":false,""Statistics"":{""Visits"":4,""Purchases"":3,""Nested"":{""SomeProperty"":10,""SomeNullableInt"":20,""SomeNullableGuid"":""d5f2685d-e5c4-47e5-97aa-d0266154eb2d"",""IntArray"":[3,4]}},""Orders"":[{""Price"":99.5,""ShippingAddress"":""Some address 1"",""ShippingDate"":""2019-10-01""},{""Price"":23.1,""ShippingAddress"":""Some address 2"",""ShippingDate"":""2019-10-10""}]}'")} (Size = 4000) + """ +@expected='{"ID":"00000000-0000-0000-0000-000000000000","Age":25,"Name":"Joe","IsVip":false,"Orders":[{"Price":99.5,"ShippingDate":"2019-10-01","ShippingAddress":"Some address 1"},{"Price":23.1,"ShippingDate":"2019-10-10","ShippingAddress":"Some address 2"}],"Statistics":{"Nested":{"IntArray":[3,4],"SomeProperty":10,"SomeNullableInt":20,"SomeNullableGuid":"d5f2685d-e5c4-47e5-97aa-d0266154eb2d"},"Visits":4,"Purchases":3}}' (Size = 4000) SELECT `j`.`Id`, `j`.`CustomerJObject`, `j`.`CustomerJToken` FROM `JsonEntities` AS `j` -WHERE `j`.`CustomerJToken` = {InsertJsonConvert("@__expected_0")} -LIMIT 2"); +WHERE `j`.`CustomerJToken` = CAST(@expected AS json) +LIMIT 2 +"""); } [Fact] @@ -253,12 +261,14 @@ public void Array_parameter_index() Assert.Equal("Joe", x.CustomerJToken["Name"].Value()); AssertSql( - @"@__i_0='1' +""" +@i='1' SELECT `j`.`Id`, `j`.`CustomerJObject`, `j`.`CustomerJToken` FROM `JsonEntities` AS `j` -WHERE JSON_EXTRACT(`j`.`CustomerJToken`, CONCAT('$.Statistics.Nested.IntArray[', @__i_0, ']')) = 4 -LIMIT 2"); +WHERE JSON_EXTRACT(`j`.`CustomerJToken`, CONCAT('$.Statistics.Nested.IntArray[', @i, ']')) = 4 +LIMIT 2 +"""); } [Fact] @@ -359,11 +369,11 @@ public void JsonOverlaps_with_json_element() Assert.Equal(1, count); AssertSql( - $@"@__element_1='{{""Name"":""Joe"",""Age"":-1}}' (Size = 4000) + $@"@element='{{""Name"":""Joe"",""Age"":-1}}' (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_OVERLAPS(`j`.`CustomerJToken`, {InsertJsonConvert("@__element_1")})"); +WHERE JSON_OVERLAPS(`j`.`CustomerJToken`, {InsertJsonConvert("@element")})"); } [ConditionalFact] @@ -392,11 +402,11 @@ public void JsonOverlaps_using_JsonExtract_with_json_element() Assert.Equal(1, count); AssertSql( - $@"@__element_1='[3,-1]' (Size = 4000) + $@"@element='[3,-1]' (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_OVERLAPS(JSON_EXTRACT(`j`.`CustomerJToken`, '$.Statistics.Nested.IntArray'), {InsertJsonConvert("@__element_1")})"); +WHERE JSON_OVERLAPS(JSON_EXTRACT(`j`.`CustomerJToken`, '$.Statistics.Nested.IntArray'), {InsertJsonConvert("@element")})"); } [ConditionalFact] @@ -424,11 +434,11 @@ public void JsonContains_with_json_element() Assert.Equal(1, count); AssertSql( - $@"@__element_1='{{""Name"":""Joe"",""Age"":25}}' (Size = 4000) + $@"@element='{{""Name"":""Joe"",""Age"":25}}' (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_CONTAINS(`j`.`CustomerJToken`, {InsertJsonConvert("@__element_1")})"); +WHERE JSON_CONTAINS(`j`.`CustomerJToken`, {InsertJsonConvert("@element")})"); } [Fact] diff --git a/test/EFCore.MySql.FunctionalTests/Query/JsonNewtonsoftPocoQueryTest.cs b/test/EFCore.MySql.FunctionalTests/Query/JsonNewtonsoftPocoQueryTest.cs index 7cbc5143c..b5891ea69 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/JsonNewtonsoftPocoQueryTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/JsonNewtonsoftPocoQueryTest.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.Extensions.DependencyInjection; @@ -30,11 +30,11 @@ public override void JsonContains_with_json_element() Assert.Equal(1, count); AssertSql( - $@"@__element_1='{{""Name"":""Joe"",""Age"":25}}' (Size = 4000) + $@"@element='{{""Name"":""Joe"",""Age"":25}}' (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_CONTAINS(`j`.`Customer`, {InsertJsonConvert("@__element_1")})"); +WHERE JSON_CONTAINS(`j`.`Customer`, {InsertJsonConvert("@element")})"); } public class JsonNewtonsoftPocoQueryFixture : JsonPocoQueryFixtureBase diff --git a/test/EFCore.MySql.FunctionalTests/Query/JsonPocoQueryTestBase.cs b/test/EFCore.MySql.FunctionalTests/Query/JsonPocoQueryTestBase.cs index ff9b59bf5..3f81cff7c 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/JsonPocoQueryTestBase.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/JsonPocoQueryTestBase.cs @@ -63,18 +63,18 @@ public void Parameter() Assert.Equal(actual.Name, expected.Name); AssertSql( - @"@__p_0='1' + @"@p='1' SELECT `j`.`Id`, `j`.`Customer`, `j`.`ToplevelArray` FROM `JsonEntities` AS `j` -WHERE `j`.`Id` = @__p_0 +WHERE `j`.`Id` = @p LIMIT 1", // - $@"@__expected_0='{{""Name"":""Joe"",""Age"":25,""ID"":""00000000-0000-0000-0000-000000000000"",""is_vip"":false,""Statistics"":{{""Visits"":4,""Purchases"":3,""Nested"":{{""SomeProperty"":10,""SomeNullableInt"":20,""IntArray"":[3,4],""SomeNullableGuid"":""d5f2685d-e5c4-47e5-97aa-d0266154eb2d""}}}},""Orders"":[{{""Price"":99.5,""ShippingAddress"":""Some address 1"",""ShippingDate"":""2019-10-01T00:00:00""}},{{""Price"":23.1,""ShippingAddress"":""Some address 2"",""ShippingDate"":""2019-10-10T00:00:00""}}]}}' (Size = 4000) + $@"@expected='{{""Name"":""Joe"",""Age"":25,""ID"":""00000000-0000-0000-0000-000000000000"",""is_vip"":false,""Statistics"":{{""Visits"":4,""Purchases"":3,""Nested"":{{""SomeProperty"":10,""SomeNullableInt"":20,""IntArray"":[3,4],""SomeNullableGuid"":""d5f2685d-e5c4-47e5-97aa-d0266154eb2d""}}}},""Orders"":[{{""Price"":99.5,""ShippingAddress"":""Some address 1"",""ShippingDate"":""2019-10-01T00:00:00""}},{{""Price"":23.1,""ShippingAddress"":""Some address 2"",""ShippingDate"":""2019-10-10T00:00:00""}}]}}' (Size = 4000) SELECT `j`.`Id`, `j`.`Customer`, `j`.`ToplevelArray` FROM `JsonEntities` AS `j` -WHERE `j`.`Customer` = {InsertJsonConvert("@__expected_0")} +WHERE `j`.`Customer` = {InsertJsonConvert("@expected")} LIMIT 2"); } @@ -242,11 +242,11 @@ public void Array_parameter_index() Assert.Equal("Joe", x.Customer.Name); AssertSql( - @"@__i_0='1' + @"@i='1' SELECT `j`.`Id`, `j`.`Customer`, `j`.`ToplevelArray` FROM `JsonEntities` AS `j` -WHERE JSON_EXTRACT(`j`.`Customer`, CONCAT('$.Statistics.Nested.IntArray[', @__i_0, ']')) = 4 +WHERE JSON_EXTRACT(`j`.`Customer`, CONCAT('$.Statistics.Nested.IntArray[', @i, ']')) = 4 LIMIT 2"); } @@ -335,11 +335,11 @@ public void JsonExtract() Assert.Equal(1, count); AssertSql( - $@"@__name_1='Joe' (Size = 4000) + $@"@name='Joe' (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_EXTRACT(`j`.`Customer`, '$.Name') = @__name_1"); +WHERE JSON_EXTRACT(`j`.`Customer`, '$.Name') = @name"); } [Fact] @@ -353,11 +353,11 @@ public void JsonExtract_JsonUnquote() Assert.Equal(1, count); AssertSql( - $@"@__name_1='Joe' (Size = 4000) + $@"@name='Joe' (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_UNQUOTE(JSON_EXTRACT(`j`.`Customer`, '$.Name')) = @__name_1"); +WHERE JSON_UNQUOTE(JSON_EXTRACT(`j`.`Customer`, '$.Name')) = @name"); } [Fact] @@ -387,11 +387,11 @@ public void JsonContains_with_string_parameter() Assert.Equal(1, count); AssertSql( - @"@__someJson_1='{""Name"": ""Joe"", ""Age"": 25}' (Size = 4000) + @"@someJson='{""Name"": ""Joe"", ""Age"": 25}' (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_CONTAINS(`j`.`Customer`, @__someJson_1)"); +WHERE JSON_CONTAINS(`j`.`Customer`, @someJson)"); } [Fact] diff --git a/test/EFCore.MySql.FunctionalTests/Query/JsonStringQueryTestBase.cs b/test/EFCore.MySql.FunctionalTests/Query/JsonStringQueryTestBase.cs index 7f7757591..055b83987 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/JsonStringQueryTestBase.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/JsonStringQueryTestBase.cs @@ -71,18 +71,18 @@ public void Parameter() Assert.Equal(actual, expected); AssertSql( - @"@__p_0='1' + @"@p='1' SELECT `j`.`Id`, `j`.`CustomerJson` FROM `JsonEntities` AS `j` -WHERE `j`.`Id` = @__p_0 +WHERE `j`.`Id` = @p LIMIT 1", // - $@"{InsertJsonDocument(@"@__expected_1='{""Age"":25,""Name"":""Joe"",""IsVip"":false,""Orders"":[{""Price"":99.5,""ShippingDate"":""2019-10-01"",""ShippingAddress"":""Some address 1""},{""Price"":23,""ShippingDate"":""2019-10-10"",""ShippingAddress"":""Some address 2""}],""Statistics"":{""Nested"":{""IntArray"":[3,4],""SomeProperty"":10},""Visits"":4,""Purchases"":3}}'", @"@__expected_1='{""Name"":""Joe"",""Age"":25,""IsVip"":false,""Statistics"":{""Visits"":4,""Purchases"":3,""Nested"":{""SomeProperty"":10,""IntArray"":[3,4]}},""Orders"":[{""Price"":99.5,""ShippingAddress"":""Some address 1"",""ShippingDate"":""2019-10-01""},{""Price"":23,""ShippingAddress"":""Some address 2"",""ShippingDate"":""2019-10-10""}]}'")} (Size = 4000) + $@"{InsertJsonDocument(@"@expected='{""Age"":25,""Name"":""Joe"",""IsVip"":false,""Orders"":[{""Price"":99.5,""ShippingDate"":""2019-10-01"",""ShippingAddress"":""Some address 1""},{""Price"":23,""ShippingDate"":""2019-10-10"",""ShippingAddress"":""Some address 2""}],""Statistics"":{""Nested"":{""IntArray"":[3,4],""SomeProperty"":10},""Visits"":4,""Purchases"":3}}'", @"@expected='{""Name"":""Joe"",""Age"":25,""IsVip"":false,""Statistics"":{""Visits"":4,""Purchases"":3,""Nested"":{""SomeProperty"":10,""IntArray"":[3,4]}},""Orders"":[{""Price"":99.5,""ShippingAddress"":""Some address 1"",""ShippingDate"":""2019-10-01""},{""Price"":23,""ShippingAddress"":""Some address 2"",""ShippingDate"":""2019-10-10""}]}'")} (Size = 4000) SELECT `j`.`Id`, `j`.`CustomerJson` FROM `JsonEntities` AS `j` -WHERE {InsertJsonConvert("`j`.`CustomerJson`")} = {InsertJsonConvert("@__expected_1")} +WHERE {InsertJsonConvert("`j`.`CustomerJson`")} = {InsertJsonConvert("@expected")} LIMIT 2"); } @@ -95,18 +95,18 @@ public void Parameter_cast_MySqlJsonString() Assert.Equal(actual, expected); AssertSql( - @"@__p_0='1' + @"@p='1' SELECT `j`.`Id`, `j`.`CustomerJson` FROM `JsonEntities` AS `j` -WHERE `j`.`Id` = @__p_0 +WHERE `j`.`Id` = @p LIMIT 1", // - $@"{InsertJsonDocument(@"@__p_0='{""Age"":25,""Name"":""Joe"",""IsVip"":false,""Orders"":[{""Price"":99.5,""ShippingDate"":""2019-10-01"",""ShippingAddress"":""Some address 1""},{""Price"":23,""ShippingDate"":""2019-10-10"",""ShippingAddress"":""Some address 2""}],""Statistics"":{""Nested"":{""IntArray"":[3,4],""SomeProperty"":10},""Visits"":4,""Purchases"":3}}'", @"@__p_0='{""Name"":""Joe"",""Age"":25,""IsVip"":false,""Statistics"":{""Visits"":4,""Purchases"":3,""Nested"":{""SomeProperty"":10,""IntArray"":[3,4]}},""Orders"":[{""Price"":99.5,""ShippingAddress"":""Some address 1"",""ShippingDate"":""2019-10-01""},{""Price"":23,""ShippingAddress"":""Some address 2"",""ShippingDate"":""2019-10-10""}]}'")} (Size = 4000) + $@"{InsertJsonDocument(@"@p='{""Age"":25,""Name"":""Joe"",""IsVip"":false,""Orders"":[{""Price"":99.5,""ShippingDate"":""2019-10-01"",""ShippingAddress"":""Some address 1""},{""Price"":23,""ShippingDate"":""2019-10-10"",""ShippingAddress"":""Some address 2""}],""Statistics"":{""Nested"":{""IntArray"":[3,4],""SomeProperty"":10},""Visits"":4,""Purchases"":3}}'", @"@p='{""Name"":""Joe"",""Age"":25,""IsVip"":false,""Statistics"":{""Visits"":4,""Purchases"":3,""Nested"":{""SomeProperty"":10,""IntArray"":[3,4]}},""Orders"":[{""Price"":99.5,""ShippingAddress"":""Some address 1"",""ShippingDate"":""2019-10-01""},{""Price"":23,""ShippingAddress"":""Some address 2"",""ShippingDate"":""2019-10-10""}]}'")} (Size = 4000) SELECT `j`.`Id`, `j`.`CustomerJson` FROM `JsonEntities` AS `j` -WHERE {InsertJsonConvert("`j`.`CustomerJson`")} = {InsertJsonConvert("@__p_0")} +WHERE {InsertJsonConvert("`j`.`CustomerJson`")} = {InsertJsonConvert("@p")} LIMIT 2"); } @@ -138,11 +138,11 @@ public void JsonExtract_JsonUnquote() Assert.Equal(1, count); AssertSql( - $@"@__name_1='Joe' (Size = 4000) + $@"@name='Joe' (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_UNQUOTE(JSON_EXTRACT(`j`.`CustomerJson`, '$.Name')) = @__name_1"); +WHERE JSON_UNQUOTE(JSON_EXTRACT(`j`.`CustomerJson`, '$.Name')) = @name"); } [Fact] @@ -156,11 +156,11 @@ public void JsonExtract_JsonUnquote_JsonQuote() Assert.Equal(1, count); AssertSql( - $@"@__name_1='""Joe""' (Size = 4000) + $@"@name='""Joe""' (Size = 4000) SELECT COUNT(*) FROM `JsonEntities` AS `j` -WHERE JSON_QUOTE(JSON_UNQUOTE(JSON_EXTRACT(`j`.`CustomerJson`, '$.Name'))) = @__name_1"); +WHERE JSON_QUOTE(JSON_UNQUOTE(JSON_EXTRACT(`j`.`CustomerJson`, '$.Name'))) = @name"); } [Fact] diff --git a/test/EFCore.MySql.FunctionalTests/Query/MatchQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/MatchQueryMySqlTest.cs index de8e829eb..e6b3a7443 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/MatchQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/MatchQueryMySqlTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore; @@ -288,11 +288,13 @@ public virtual void IsMatch_in_boolean_mode_with_search_mode_parameter() Assert.Equal(3, count); AssertSql( - @"@__searchMode_1='2' +""" +@searchMode='2' SELECT COUNT(*) FROM `Herb` AS `h` -WHERE ((@__searchMode_1 = 0) AND (MATCH (`h`.`Name`) AGAINST ('First*') > 0.0)) OR (((@__searchMode_1 = 1) AND (MATCH (`h`.`Name`) AGAINST ('First*' WITH QUERY EXPANSION) > 0.0)) OR ((@__searchMode_1 = 2) AND (MATCH (`h`.`Name`) AGAINST ('First*' IN BOOLEAN MODE) > 0.0)))"); +WHERE ((@searchMode = 0) AND (MATCH (`h`.`Name`) AGAINST ('First*') > 0.0)) OR (((@searchMode = 1) AND (MATCH (`h`.`Name`) AGAINST ('First*' WITH QUERY EXPANSION) > 0.0)) OR ((@searchMode = 2) AND (MATCH (`h`.`Name`) AGAINST ('First*' IN BOOLEAN MODE) > 0.0))) +"""); } [ConditionalFact] @@ -317,11 +319,13 @@ public virtual void IsMatch_in_boolean_mode_with_search_mode_parameter_multiple_ Assert.Equal(5, count); AssertSql( - @"@__searchMode_1='2' +""" +@searchMode='2' SELECT COUNT(*) FROM `Herb` AS `h` -WHERE ((@__searchMode_1 = 0) AND (MATCH (`h`.`Name`, `h`.`Garden`) AGAINST ('First*') > 0.0)) OR (((@__searchMode_1 = 1) AND (MATCH (`h`.`Name`, `h`.`Garden`) AGAINST ('First*' WITH QUERY EXPANSION) > 0.0)) OR ((@__searchMode_1 = 2) AND (MATCH (`h`.`Name`, `h`.`Garden`) AGAINST ('First*' IN BOOLEAN MODE) > 0.0)))"); +WHERE ((@searchMode = 0) AND (MATCH (`h`.`Name`, `h`.`Garden`) AGAINST ('First*') > 0.0)) OR (((@searchMode = 1) AND (MATCH (`h`.`Name`, `h`.`Garden`) AGAINST ('First*' WITH QUERY EXPANSION) > 0.0)) OR ((@searchMode = 2) AND (MATCH (`h`.`Name`, `h`.`Garden`) AGAINST ('First*' IN BOOLEAN MODE) > 0.0))) +"""); } [ConditionalFact] @@ -371,11 +375,14 @@ public virtual void Match_in_boolean_mode_keywords_evaluate_score() Assert.Equal(3, count); - AssertSql(@"@__minScore_1='0.2' + AssertSql( +""" +@minScore='0.2' SELECT COUNT(*) FROM `Herb` AS `h` -WHERE MATCH (`h`.`Name`) AGAINST ('First* Herb*' IN BOOLEAN MODE) > @__minScore_1"); +WHERE MATCH (`h`.`Name`) AGAINST ('First* Herb*' IN BOOLEAN MODE) > @minScore +"""); } [ConditionalFact] diff --git a/test/EFCore.MySql.FunctionalTests/Query/MathQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/MathQueryMySqlTest.cs new file mode 100644 index 000000000..209d0ca06 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/MathQueryMySqlTest.cs @@ -0,0 +1,427 @@ +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; + +namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; + +public class MathQueryMySqlTest : IClassFixture +{ + private MathQueryMySqlFixture Fixture { get; } + + public MathQueryMySqlTest(MathQueryMySqlFixture fixture) + { + Fixture = fixture; + + // ReSharper disable once VirtualMemberCallInConstructor + ClearLog(); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_clientside() + { + using var context = CreateContext(); + + var result = context.Set() + .Select(_ => 5 / 2) + .Single(); + + Assert.Equal(2, result); + + AssertSql( +""" +SELECT 2 +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_cast_decimal1_clientside() + { + using var context = CreateContext(); + + var result = context.Set() + .Select(_ => (decimal)5 / 2) + .Single(); + + Assert.Equal(2.5M, result); + + AssertSql( +""" +SELECT 2.5 +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_cast_decimal2_clientside() + { + using var context = CreateContext(); + + var result = context.Set() + .Select(_ => (decimal)(5 / 2)) + .Single(); + + Assert.Equal(2.0M, result); + + AssertSql( +""" +SELECT 2.0 +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_constants() + { + using var context = CreateContext(); + + var result = context.Set() + .Select(_ => EF.Constant(5) / EF.Constant(2)) + .Single(); + + Assert.Equal(2, result); + + AssertSql( +""" +SELECT 5 / 2 +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_cast_decimal1_constants() + { + using var context = CreateContext(); + + var result = context.Set() + .Select(_ => EF.Constant((decimal)5) / EF.Constant(2)) + .Single(); + + Assert.Equal(2.5M, result); + + AssertSql( +""" +SELECT 5.0 / CAST(2 AS decimal(65,30)) +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_cast_decimal2_constants() + { + using var context = CreateContext(); + + var result = context.Set() + .Select(_ => (decimal)(EF.Constant(5) / EF.Constant(2))) + .Single(); + + Assert.Equal(2.0M, result); + + AssertSql( +""" +SELECT CAST(5 / 2 AS numeric) +FROM "Dummy" AS d +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_parameters() + { + using var context = CreateContext(); + + var result = context.Set() + .Select(d => d.IntLeftOperand / d.IntRightOperand) + .Single(); + + Assert.Equal(2, result); + + AssertSql( +""" +SELECT `d`.`IntLeftOperand` / `d`.`IntRightOperand` +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_cast_decimal1_parameters() + { + using var context = CreateContext(); + + var result = context.Set() + .Select(d => (decimal)d.IntLeftOperand / d.IntRightOperand) + .Single(); + + Assert.Equal(2.5M, result); + + AssertSql( +""" +SELECT CAST(`d`.`IntLeftOperand` AS decimal(65,30)) / CAST(`d`.`IntRightOperand` AS decimal(65,30)) +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_cast_decimal2_parameters() + { + using var context = CreateContext(); + + var result = context.Set() + .Select(d => (decimal)(d.IntLeftOperand / d.IntRightOperand)) + .Single(); + + Assert.Equal(2.0M, result); + + AssertSql( +""" +SELECT CAST(d."IntLeftOperand" / d."IntRightOperand" AS numeric) +FROM "Dummy" AS d +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_then_multiply_clientside() + { + using var context = CreateContext(); + + // "(int)5 / (int)2 * (int)2" should be "4". Which it is. + var result = context.Set() + .Select(d => 5 / 2 * 2) + .Single(); + + Assert.Equal(4, result); + + AssertSql( +""" +SELECT 4 +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_then_multiply_constants() + { + using var context = CreateContext(); + + // "(int)5 / (int)2 * (int)2" should be "4". Which it is. + var result = context.Set() + .Select(d => EF.Constant(5) / EF.Constant(2) * EF.Constant(2)) + .Single(); + + Assert.Equal(4, result); + + AssertSql( +""" +SELECT (5 / 2) * 2 +FROM "Dummy" AS d +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_then_multiply_cast_decimal1_clientside() + { + using var context = CreateContext(); + + // "(int)5 / (int)2 * (int)2" should be "4". Which it is. + var result = context.Set() + .Select(d => (decimal)5 / 2 * 2) + .Single(); + + Assert.Equal(5.0M, result); + + AssertSql( +""" +SELECT 5.0 +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_then_multiply_cast_decimal1_constants() + { + using var context = CreateContext(); + + // "(int)5 / (int)2 * (int)2" should be "4". Which it is. + var result = context.Set() + .Select(d => (decimal)EF.Constant(5) / EF.Constant(2) * EF.Constant(2)) + .Single(); + + Assert.Equal(5.0M, result); + + AssertSql( +""" +SELECT (CAST(5 AS decimal(65,30)) / CAST(2 AS decimal(65,30))) * CAST(2 AS decimal(65,30)) +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_then_multiply_cast_decimal2_clientside() + { + using var context = CreateContext(); + + // "(int)5 / (int)2 * (int)2" should be "4". Which it is. + var result = context.Set() + .Select(d => (decimal)(5 / 2 * 2)) + .Single(); + + Assert.Equal(4.0M, result); + + AssertSql( +""" +SELECT 4.0 +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_then_multiply_cast_decimal2_constants() + { + using var context = CreateContext(); + + // "(int)5 / (int)2 * (int)2" should be "4". Which it is. + var result = context.Set() + .Select(d => (decimal)(EF.Constant(5) / EF.Constant(2) * EF.Constant(2))) + .Single(); + + Assert.Equal(4.0M, result); + + AssertSql( +""" +SELECT CAST((5 / 2) * 2 AS numeric) +FROM "Dummy" AS d +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_then_multiply_parameters() + { + using var context = CreateContext(); + + // "(int)5 / (int)2 * (int)2" should be "4". But here it is "5". + var result = context.Set() + .Select(d => d.IntLeftOperand / d.IntRightOperand * d.IntRightOperand) + .Single(); + + Assert.Equal(4, result); + + AssertSql( +""" +SELECT (d."IntLeftOperand" / d."IntRightOperand") * d."IntRightOperand" +FROM "Dummy" AS d +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_then_multiply_cast_decimal1_parameters() + { + using var context = CreateContext(); + + // "(int)5 / (int)2 * (int)2" should be "4". Which it is. + var result = context.Set() + .Select(d => (decimal)d.IntLeftOperand / d.IntRightOperand * d.IntRightOperand) + .Single(); + + Assert.Equal(5.0M, result); + + AssertSql( +""" +SELECT (CAST(`d`.`IntLeftOperand` AS decimal(65,30)) / CAST(`d`.`IntRightOperand` AS decimal(65,30))) * CAST(`d`.`IntRightOperand` AS decimal(65,30)) +FROM `Dummy` AS `d` +LIMIT 2 +"""); + } + + [ConditionalFact] + public virtual void Divide_integer_by_integer_then_multiply_cast_decimal2_parameters() + { + using var context = CreateContext(); + + // "(int)5 / (int)2 * (int)2" should be "4". Which it is. + var result = context.Set() + .Select(d => (decimal)(d.IntLeftOperand / d.IntRightOperand * d.IntRightOperand)) + .Single(); + + Assert.Equal(4.0M, result); + + AssertSql( +""" +SELECT CAST((d."IntLeftOperand" / d."IntRightOperand") * d."IntRightOperand" AS numeric) +FROM "Dummy" AS d +LIMIT 2 +"""); + } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected virtual void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); + + protected virtual DbContext CreateContext() + => Fixture.CreateContext(); + + public class MathQueryMySqlFixture : SharedStoreFixtureBase, ITestSqlLoggerFactory + { + protected override string StoreName + => "Math"; + + protected override ITestStoreFactory TestStoreFactory + => MySqlTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService(); + + protected override async Task SeedAsync(MathQueryContext context) + { + context.Add( + new Dummy + { + DummyId = 1, + IntLeftOperand = 5, + IntRightOperand = 2, + IntOne = 1, + IntZero = 0, + }); + + await context.SaveChangesAsync(); + } + } + + public class MathQueryContext(DbContextOptions options) : DbContext(options) + { + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(); + } + } + + public class Dummy + { + public int DummyId { get; set; } + public int IntLeftOperand { get; set; } + public int IntRightOperand { get; set; } + public int IntOne { get; set; } + public int IntZero { get; set; } + } +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryMySqlTest.cs index ff692781c..9937af3ba 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryMySqlTest.cs @@ -13,6 +13,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class NonSharedPrimitiveCollectionsQueryMySqlTest : NonSharedPrimitiveCollectionsQueryRelationalTestBase { + public NonSharedPrimitiveCollectionsQueryMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + #region Support for specific element types public override async Task Array_of_string() @@ -479,86 +484,43 @@ public override async Task Column_collection_inside_json_owned_entity() #endregion Type mapping inference - public override async Task Parameter_collection_Count_with_column_predicate_with_default_constants() + public override async Task Parameter_collection_Count_with_column_predicate_with_default_mode(ParameterTranslationMode mode) { - await base.Parameter_collection_Count_with_column_predicate_with_default_constants(); + await base.Parameter_collection_Count_with_column_predicate_with_default_mode(mode); + + switch (mode) + { + case ParameterTranslationMode.MultipleParameters: + AssertSql( +""" +@ids1='2' +@ids2='999' - AssertSql( -$""" SELECT `t`.`Id` FROM `TestEntity` AS `t` WHERE ( SELECT COUNT(*) - FROM (SELECT 2 AS `Value` UNION ALL VALUES {(AppConfig.ServerVersion.Supports.ValuesWithRows ? "ROW" : string.Empty)}(999)) AS `i` + FROM (SELECT @ids1 AS `Value` UNION ALL VALUES ROW(@ids2)) AS `i` WHERE `i`.`Value` > `t`.`Id`) = 1 """); - } - - public override async Task Parameter_collection_of_ints_Contains_int_with_default_constants() - { - await base.Parameter_collection_of_ints_Contains_int_with_default_constants(); - - AssertSql( + break; + case ParameterTranslationMode.Constant: + AssertSql( """ SELECT `t`.`Id` FROM `TestEntity` AS `t` -WHERE `t`.`Id` IN (2, 999) -"""); - } - - public override async Task Parameter_collection_Count_with_column_predicate_with_default_constants_EF_Parameter() - { - await base.Parameter_collection_Count_with_column_predicate_with_default_constants_EF_Parameter(); - - AssertSql(); - } - - public override async Task Parameter_collection_of_ints_Contains_int_with_default_constants_EF_Parameter() - { - await base.Parameter_collection_of_ints_Contains_int_with_default_constants_EF_Parameter(); - - AssertSql(); - } - - public override async Task Parameter_collection_Count_with_column_predicate_with_default_parameters() - { - await base.Parameter_collection_Count_with_column_predicate_with_default_parameters(); - - AssertSql(); - } - - public override async Task Parameter_collection_of_ints_Contains_int_with_default_parameters() - { - await base.Parameter_collection_of_ints_Contains_int_with_default_parameters(); - - AssertSql(); - } - - public override async Task Parameter_collection_Count_with_column_predicate_with_default_parameters_EF_Constant() - { - await base.Parameter_collection_Count_with_column_predicate_with_default_parameters_EF_Constant(); - - AssertSql( -$""" -SELECT `t`.`Id` -FROM `TestEntity` AS `t` WHERE ( SELECT COUNT(*) - FROM (SELECT 2 AS `Value` UNION ALL VALUES {(AppConfig.ServerVersion.Supports.ValuesWithRows ? "ROW" : string.Empty)}(999)) AS `i` + FROM (SELECT CAST(2 AS signed) AS `Value` UNION ALL VALUES ROW(999)) AS `i` WHERE `i`.`Value` > `t`.`Id`) = 1 """); - } - - public override async Task Parameter_collection_of_ints_Contains_int_with_default_parameters_EF_Constant() - { - await base.Parameter_collection_of_ints_Contains_int_with_default_parameters_EF_Constant(); - - AssertSql( -""" -SELECT `t`.`Id` -FROM `TestEntity` AS `t` -WHERE `t`.`Id` IN (2, 999) -"""); + break; + case ParameterTranslationMode.Parameter: + AssertSql(""); + break; + default: + throw new NotImplementedException(); + } } public override async Task Project_collection_from_entity_type_with_owned() @@ -576,16 +538,11 @@ public override async Task Project_collection_from_entity_type_with_owned() public virtual void Check_all_tests_overridden() => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); - protected override DbContextOptionsBuilder SetTranslateParameterizedCollectionsToConstants(DbContextOptionsBuilder optionsBuilder) - { - new MySqlDbContextOptionsBuilder(optionsBuilder).TranslateParameterizedCollectionsToConstants(); - - return optionsBuilder; - } - - protected override DbContextOptionsBuilder SetTranslateParameterizedCollectionsToParameters(DbContextOptionsBuilder optionsBuilder) + protected override DbContextOptionsBuilder SetParameterizedCollectionMode( + DbContextOptionsBuilder optionsBuilder, + ParameterTranslationMode parameterizedCollectionMode) { - new MySqlDbContextOptionsBuilder(optionsBuilder).TranslateParameterizedCollectionsToParameters(); + new MySqlDbContextOptionsBuilder(optionsBuilder).UseParameterizedCollectionMode(parameterizedCollectionMode); return optionsBuilder; } diff --git a/test/EFCore.MySql.FunctionalTests/Query/NorthwindDbFunctionsQueryMySqlTest.MySql.cs b/test/EFCore.MySql.FunctionalTests/Query/NorthwindDbFunctionsQueryMySqlTest.MySql.cs index 1093929cc..4627c3a20 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NorthwindDbFunctionsQueryMySqlTest.MySql.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NorthwindDbFunctionsQueryMySqlTest.MySql.cs @@ -340,12 +340,14 @@ public virtual void Degrees() Assert.Equal(degrees, office.OfficeRoofAngleDegrees); AssertSql( - @"@__radians_1='1.5707963267948966' +""" +@radians='1.5707963267948966' -SELECT `c`.`CustomerID`, DEGREES(@__radians_1) AS `OfficeRoofAngleDegrees` +SELECT `c`.`CustomerID`, DEGREES(@radians) AS `OfficeRoofAngleDegrees` FROM `Customers` AS `c` WHERE `c`.`CustomerID` = 'VINET' -LIMIT 1"); +LIMIT 1 +"""); } [ConditionalFact] @@ -363,12 +365,14 @@ public virtual void Radians() Assert.Equal(radians, office.OfficeRoofAngleRadians); AssertSql( - @"@__degrees_1='90' +""" +@degrees='90' -SELECT `c`.`CustomerID`, RADIANS(@__degrees_1) AS `OfficeRoofAngleRadians` +SELECT `c`.`CustomerID`, RADIANS(@degrees) AS `OfficeRoofAngleRadians` FROM `Customers` AS `c` WHERE `c`.`CustomerID` = 'VINET' -LIMIT 1"); +LIMIT 1 +"""); } [ConditionalFact] diff --git a/test/EFCore.MySql.FunctionalTests/Query/NorthwindEFPropertyIncludeQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/NorthwindEFPropertyIncludeQueryMySqlTest.cs index a688fda27..a7f445893 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NorthwindEFPropertyIncludeQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NorthwindEFPropertyIncludeQueryMySqlTest.cs @@ -160,14 +160,14 @@ public override async Task Include_collection_skip_take_no_order_by(bool async) AssertSql( """ -@__p_1='5' -@__p_0='10' +@p0='5' +@p='10' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`CustomerID` @@ -278,14 +278,14 @@ public override async Task Include_duplicate_reference3(bool async) AssertSql( """ -@__p_0='2' +@p='2' SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` ORDER BY `o`.`OrderID` - LIMIT @__p_0 + LIMIT @p ) AS `o1` CROSS JOIN ( SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` @@ -304,14 +304,14 @@ public override async Task Include_collection_order_by_non_key_with_take(bool as AssertSql( """ -@__p_0='10' +@p='10' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`ContactTitle` - LIMIT @__p_0 + LIMIT @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`ContactTitle`, `c0`.`CustomerID` @@ -346,13 +346,13 @@ public override async Task Include_collection_take_no_order_by(bool async) AssertSql( """ -@__p_0='10' +@p='10' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` - LIMIT @__p_0 + LIMIT @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`CustomerID` @@ -417,8 +417,8 @@ from c2 in ss.Set().OrderBy(c => c.CustomerID).Skip(2).Take(2) AssertSql( """ -@__p_0='2' -@__p_1='1' +@p='2' +@p0='1' SELECT `s`.`CustomerID`, `s`.`Address`, `s`.`City`, `s`.`CompanyName`, `s`.`ContactName`, `s`.`ContactTitle`, `s`.`Country`, `s`.`Fax`, `s`.`Phone`, `s`.`PostalCode`, `s`.`Region`, `s`.`CustomerID0`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, `s`.`Address0`, `s`.`City0`, `s`.`CompanyName0`, `s`.`ContactName0`, `s`.`ContactTitle0`, `s`.`Country0`, `s`.`Fax0`, `s`.`Phone0`, `s`.`PostalCode0`, `s`.`Region0` FROM ( @@ -431,7 +431,7 @@ from c2 in ss.Set().OrderBy(c => c.CustomerID).Skip(2).Take(2) FROM `Orders` AS `o` WHERE `c`.`CustomerID` = `o`.`CustomerID` LIMIT 1) - LIMIT @__p_0 + LIMIT @p ) AS `c1` CROSS JOIN ( SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` @@ -440,7 +440,7 @@ ORDER BY `c0`.`CustomerID` LIMIT 2 OFFSET 2 ) AS `c2` ORDER BY `c1`.`CustomerID`, `c2`.`CustomerID` - LIMIT @__p_1 + LIMIT @p0 ) AS `s` LEFT JOIN `Orders` AS `o0` ON `s`.`CustomerID` = `o0`.`CustomerID` ORDER BY `s`.`CustomerID`, `s`.`CustomerID0` @@ -460,7 +460,7 @@ await AssertQuery( AssertSql( """ -@__p_0='2' +@p='2' SELECT `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`CustomerID0`, `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` FROM ( @@ -474,7 +474,7 @@ END AS `c0` WHEN `c`.`CustomerID` IS NOT NULL THEN `c`.`CustomerID` ELSE '' END, `o`.`EmployeeID` - LIMIT @__p_0 + LIMIT @p ) AS `s` LEFT JOIN `Order Details` AS `o0` ON `s`.`OrderID` = `o0`.`OrderID` ORDER BY `s`.`c`, `s`.`c0`, `s`.`EmployeeID`, `s`.`OrderID`, `s`.`CustomerID0`, `o0`.`OrderID` @@ -541,14 +541,14 @@ public override async Task Include_duplicate_collection(bool async) AssertSql( """ -@__p_0='2' +@p='2' SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region`, `c2`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `c2`.`Address`, `c2`.`City`, `c2`.`CompanyName`, `c2`.`ContactName`, `c2`.`ContactTitle`, `c2`.`Country`, `c2`.`Fax`, `c2`.`Phone`, `c2`.`PostalCode`, `c2`.`Region`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`CustomerID` - LIMIT @__p_0 + LIMIT @p ) AS `c1` CROSS JOIN ( SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` @@ -692,15 +692,16 @@ LIMIT 18446744073709551610 OFFSET @__p_1 { AssertSql( """ -@__p_1='1' +@list1='ALFKI' (Size = 5) (DbType = StringFixedLength) +@p='1' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `c`.`CustomerID` <> 'ALFKI' AS `c` + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `c`.`CustomerID` <> @list1 AS `c` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'A%' - ORDER BY `c`.`CustomerID` <> 'ALFKI' - LIMIT 18446744073709551610 OFFSET @__p_1 + ORDER BY `c`.`CustomerID` <> @list1 + LIMIT 18446744073709551610 OFFSET @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`c`, `c0`.`CustomerID` @@ -747,14 +748,14 @@ public override async Task Include_duplicate_reference(bool async) AssertSql( """ -@__p_0='2' +@p='2' SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` ORDER BY `o`.`CustomerID`, `o`.`OrderID` - LIMIT @__p_0 + LIMIT @p ) AS `o1` CROSS JOIN ( SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` @@ -786,7 +787,7 @@ public override async Task Include_collection_order_by_non_key_with_skip(bool as AssertSql( """ -@__p_0='2' +@p='2' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( @@ -794,7 +795,7 @@ public override async Task Include_collection_order_by_non_key_with_skip(bool as FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'F%' ORDER BY `c`.`ContactTitle` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`ContactTitle`, `c0`.`CustomerID` @@ -922,14 +923,14 @@ public override async Task Include_collection_on_additional_from_clause2(bool as AssertSql( """ -@__p_0='5' +@p='5' SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`CustomerID` - LIMIT @__p_0 + LIMIT @p ) AS `c1` CROSS JOIN `Customers` AS `c0` ORDER BY `c1`.`CustomerID` @@ -1069,7 +1070,7 @@ LIMIT 18446744073709551610 OFFSET @__p_1 { AssertSql( """ -@__p_1='1' +@p='1' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( @@ -1077,7 +1078,7 @@ LIMIT 18446744073709551610 OFFSET @__p_1 FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'A%' ORDER BY (SELECT 1) - LIMIT 18446744073709551610 OFFSET @__p_1 + LIMIT 18446744073709551610 OFFSET @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`c`, `c0`.`CustomerID` @@ -1205,7 +1206,7 @@ await AssertQuery( AssertSql( """ -@__p_0='5' +@p='5' SELECT `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`CustomerID0`, `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` FROM ( @@ -1219,7 +1220,7 @@ END AS `c0` WHEN `c`.`CustomerID` IS NOT NULL THEN `c`.`City` ELSE '' END, `o`.`OrderID` - LIMIT @__p_0 + LIMIT @p ) AS `s` LEFT JOIN `Order Details` AS `o0` ON `s`.`OrderID` = `o0`.`OrderID` ORDER BY `s`.`c`, `s`.`c0`, `s`.`OrderID`, `s`.`CustomerID0`, `o0`.`OrderID` @@ -1476,15 +1477,16 @@ LIMIT 18446744073709551610 OFFSET @__p_1 { AssertSql( """ -@__p_1='1' +@list1='ALFKI' (Size = 5) (DbType = StringFixedLength) +@p='1' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `c`.`CustomerID` = 'ALFKI' AS `c` + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `c`.`CustomerID` = @list1 AS `c` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'A%' - ORDER BY `c`.`CustomerID` = 'ALFKI' - LIMIT 18446744073709551610 OFFSET @__p_1 + ORDER BY `c`.`CustomerID` = @list1 + LIMIT 18446744073709551610 OFFSET @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`c`, `c0`.`CustomerID` @@ -1498,7 +1500,7 @@ public override async Task Multi_level_includes_are_applied_with_skip(bool async AssertSql( """ -@__p_0='1' +@p='1' SELECT `c0`.`CustomerID`, `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`OrderID0`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice` FROM ( @@ -1506,7 +1508,7 @@ public override async Task Multi_level_includes_are_applied_with_skip(bool async FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'A%' ORDER BY `c`.`CustomerID` - LIMIT 1 OFFSET @__p_0 + LIMIT 1 OFFSET @p ) AS `c0` LEFT JOIN ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `o0`.`OrderID` AS `OrderID0`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` @@ -1523,14 +1525,14 @@ public override async Task Include_collection_on_additional_from_clause(bool asy AssertSql( """ -@__p_0='5' +@p='5' SELECT `c2`.`CustomerID`, `c2`.`Address`, `c2`.`City`, `c2`.`CompanyName`, `c2`.`ContactName`, `c2`.`ContactTitle`, `c2`.`Country`, `c2`.`Fax`, `c2`.`Phone`, `c2`.`PostalCode`, `c2`.`Region`, `c1`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID` FROM `Customers` AS `c` ORDER BY `c`.`CustomerID` - LIMIT @__p_0 + LIMIT @p ) AS `c1` CROSS JOIN ( SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` @@ -1605,8 +1607,8 @@ from c2 in ss.Set().Include(c => c.Orders).OrderBy(c => c.CustomerID). AssertSql( """ -@__p_0='2' -@__p_1='1' +@p='2' +@p0='1' SELECT `s`.`CustomerID`, `s`.`Address`, `s`.`City`, `s`.`CompanyName`, `s`.`ContactName`, `s`.`ContactTitle`, `s`.`Country`, `s`.`Fax`, `s`.`Phone`, `s`.`PostalCode`, `s`.`Region`, `s`.`CustomerID0`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, `s`.`Address0`, `s`.`City0`, `s`.`CompanyName0`, `s`.`ContactName0`, `s`.`ContactTitle0`, `s`.`Country0`, `s`.`Fax0`, `s`.`Phone0`, `s`.`PostalCode0`, `s`.`Region0`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` FROM ( @@ -1619,7 +1621,7 @@ from c2 in ss.Set().Include(c => c.Orders).OrderBy(c => c.CustomerID). FROM `Orders` AS `o` WHERE `c`.`CustomerID` = `o`.`CustomerID` LIMIT 1) - LIMIT @__p_0 + LIMIT @p ) AS `c1` CROSS JOIN ( SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` @@ -1628,7 +1630,7 @@ ORDER BY `c0`.`CustomerID` LIMIT 2 OFFSET 2 ) AS `c2` ORDER BY `c1`.`CustomerID`, `c2`.`CustomerID` - LIMIT @__p_1 + LIMIT @p0 ) AS `s` LEFT JOIN `Orders` AS `o0` ON `s`.`CustomerID` = `o0`.`CustomerID` LEFT JOIN `Orders` AS `o1` ON `s`.`CustomerID0` = `o1`.`CustomerID` @@ -1694,14 +1696,14 @@ public override async Task Include_with_skip(bool async) AssertSql( """ -@__p_0='80' +@p='80' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`ContactName` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`ContactName`, `c0`.`CustomerID` @@ -1770,14 +1772,14 @@ public override async Task Include_collection_orderby_take(bool async) AssertSql( """ -@__p_0='5' +@p='5' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`CustomerID` - LIMIT @__p_0 + LIMIT @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`CustomerID` @@ -1845,14 +1847,14 @@ public override async Task Include_duplicate_reference2(bool async) AssertSql( """ -@__p_0='2' +@p='2' SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate` FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` ORDER BY `o`.`OrderID` - LIMIT @__p_0 + LIMIT @p ) AS `o1` CROSS JOIN ( SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` @@ -1996,7 +1998,7 @@ LIMIT 18446744073709551610 OFFSET @__p_1 { AssertSql( """ -@__p_1='1' +@p='1' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( @@ -2004,7 +2006,7 @@ LIMIT 18446744073709551610 OFFSET @__p_1 FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'A%' ORDER BY (SELECT 1) - LIMIT 18446744073709551610 OFFSET @__p_1 + LIMIT 18446744073709551610 OFFSET @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`c`, `c0`.`CustomerID` @@ -2167,13 +2169,13 @@ public override async Task Include_collection_skip_no_order_by(bool async) AssertSql( """ -@__p_0='10' +@p='10' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`CustomerID` @@ -2222,8 +2224,8 @@ public override async Task Include_where_skip_take_projection(bool async) AssertSql( """ -@__p_1='2' -@__p_0='1' +@p0='2' +@p='1' SELECT `o0`.`CustomerID` FROM ( @@ -2231,7 +2233,7 @@ public override async Task Include_where_skip_take_projection(bool async) FROM `Order Details` AS `o` WHERE `o`.`Quantity` = 10 ORDER BY `o`.`OrderID`, `o`.`ProductID` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `o1` INNER JOIN `Orders` AS `o0` ON `o1`.`OrderID` = `o0`.`OrderID` ORDER BY `o1`.`OrderID`, `o1`.`ProductID` @@ -2244,14 +2246,14 @@ public override async Task Include_with_take(bool async) AssertSql( """ -@__p_0='10' +@p='10' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`ContactName` DESC - LIMIT @__p_0 + LIMIT @p ) AS `c0` LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` ORDER BY `c0`.`ContactName` DESC, `c0`.`CustomerID` diff --git a/test/EFCore.MySql.FunctionalTests/Query/NorthwindFunctionsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/NorthwindFunctionsQueryMySqlTest.cs index 767fb6783..2d1e2adba 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NorthwindFunctionsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NorthwindFunctionsQueryMySqlTest.cs @@ -1,4 +1,3 @@ -using System; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -20,2746 +19,121 @@ public NorthwindFunctionsQueryMySqlTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - [ConditionalTheory] - public override async Task String_StartsWith_Literal(bool async) - { - await base.String_StartsWith_Literal(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE 'M%' -"""); - } - - [ConditionalTheory] - public override async Task String_StartsWith_Identity(bool async) - { - await base.String_StartsWith_Identity(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` IS NOT NULL AND (LEFT(`c`.`ContactName`, CHAR_LENGTH(`c`.`ContactName`)) = `c`.`ContactName`) -"""); - } - - [ConditionalTheory] - public override async Task String_StartsWith_Column(bool async) - { - await base.String_StartsWith_Column(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` IS NOT NULL AND (LEFT(`c`.`ContactName`, CHAR_LENGTH(`c`.`ContactName`)) = `c`.`ContactName`) -"""); - } - - [ConditionalTheory] - public override async Task String_StartsWith_MethodCall(bool async) - { - await base.String_StartsWith_MethodCall(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE 'M%' -"""); - } - - [ConditionalTheory] - public override async Task String_EndsWith_Literal(bool async) - { - await base.String_EndsWith_Literal(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE '%b' -"""); - } - - [ConditionalTheory] - public override async Task String_EndsWith_Identity(bool async) - { - await base.String_EndsWith_Identity(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` IS NOT NULL AND (RIGHT(`c`.`ContactName`, CHAR_LENGTH(`c`.`ContactName`)) = `c`.`ContactName`) -"""); - } - - [ConditionalTheory] - public override async Task String_EndsWith_Column(bool async) - { - await base.String_EndsWith_Column(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` IS NOT NULL AND (RIGHT(`c`.`ContactName`, CHAR_LENGTH(`c`.`ContactName`)) = `c`.`ContactName`) -"""); - } - - [ConditionalTheory] - public override async Task String_EndsWith_MethodCall(bool async) - { - await base.String_EndsWith_MethodCall(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE '%m' -"""); - } - - [ConditionalTheory] - public override async Task String_Contains_Literal(bool async) - { - await base.String_Contains_Literal(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE '%M%'"); - } - - [ConditionalTheory] - public override async Task String_Contains_Identity(bool async) - { - await base.String_Contains_Identity(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` IS NOT NULL AND ((LOCATE(`c`.`ContactName`, `c`.`ContactName`) > 0) OR (`c`.`ContactName` LIKE '')) -"""); - } - - [ConditionalTheory] - public override async Task String_Contains_Column(bool async) - { - await base.String_Contains_Column(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` IS NOT NULL AND ((LOCATE(`c`.`ContactName`, `c`.`CompanyName`) > 0) OR (`c`.`ContactName` LIKE '')) -"""); - } - - [ConditionalTheory] - public override async Task String_Contains_MethodCall(bool async) - { - await base.String_Contains_MethodCall(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE '%M%'"); - } - - [ConditionalTheory] - public override async Task IsNullOrWhiteSpace_in_predicate(bool async) - { - await base.IsNullOrWhiteSpace_in_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`Region` IS NULL OR (TRIM(`c`.`Region`) = '')"); - } - - [ConditionalTheory] - public override async Task Indexof_with_emptystring(bool async) - { - await base.Indexof_with_emptystring(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE (LOCATE('', `c`.`Region`) - 1) = 0 -"""); - } - - [ConditionalTheory] - public override async Task Replace_with_emptystring(bool async) - { - await base.Replace_with_emptystring(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE REPLACE(`c`.`ContactName`, 'ia', '') = 'Mar Anders'"); - } - - [ConditionalTheory] - public override async Task Substring_with_one_arg_with_zero_startindex(bool async) - { - await base.Substring_with_one_arg_with_zero_startindex(async); - - AssertSql( - @"SELECT `c`.`ContactName` -FROM `Customers` AS `c` -WHERE SUBSTRING(`c`.`CustomerID`, 0 + 1, CHAR_LENGTH(`c`.`CustomerID`)) = 'ALFKI'"); - } - - [ConditionalTheory] - public override async Task Substring_with_one_arg_with_constant(bool async) - { - await base.Substring_with_one_arg_with_constant(async); - - AssertSql( - @"SELECT `c`.`ContactName` -FROM `Customers` AS `c` -WHERE SUBSTRING(`c`.`CustomerID`, 1 + 1, CHAR_LENGTH(`c`.`CustomerID`)) = 'LFKI'"); - } - - [ConditionalTheory] - public override async Task Substring_with_one_arg_with_closure(bool async) - { - await base.Substring_with_one_arg_with_closure(async); - - AssertSql( - @"@__start_0='2' - -SELECT `c`.`ContactName` -FROM `Customers` AS `c` -WHERE SUBSTRING(`c`.`CustomerID`, @__start_0 + 1, CHAR_LENGTH(`c`.`CustomerID`)) = 'FKI'"); - } - - [ConditionalTheory] - public override async Task Substring_with_two_args_with_zero_startindex(bool async) - { - await base.Substring_with_two_args_with_zero_startindex(async); - - AssertSql( - @"SELECT SUBSTRING(`c`.`ContactName`, 0 + 1, 3) -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'ALFKI'"); - } - - [ConditionalTheory] - public override async Task Substring_with_two_args_with_zero_length(bool async) - { - await base.Substring_with_two_args_with_zero_length(async); - - AssertSql( - @"SELECT SUBSTRING(`c`.`ContactName`, 2 + 1, 0) -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'ALFKI'"); - } - - [ConditionalTheory] - public override async Task Substring_with_two_args_with_constant(bool async) - { - await base.Substring_with_two_args_with_constant(async); - - AssertSql( - @"SELECT SUBSTRING(`c`.`ContactName`, 1 + 1, 3) -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'ALFKI'"); - } - - [ConditionalTheory] - public override async Task Substring_with_two_args_with_closure(bool async) - { - await base.Substring_with_two_args_with_closure(async); - - AssertSql( - @"@__start_0='2' - -SELECT SUBSTRING(`c`.`ContactName`, @__start_0 + 1, 3) -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'ALFKI'"); - } - - [ConditionalTheory] - public override async Task Substring_with_two_args_with_Index_of(bool async) - { - await base.Substring_with_two_args_with_Index_of(async); - - AssertSql( - @"SELECT SUBSTRING(`c`.`ContactName`, (LOCATE('a', `c`.`ContactName`) - 1) + 1, 3) -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'ALFKI'"); - } - - [ConditionalTheory] - public override async Task Regex_IsMatch_MethodCall(bool async) - { - await base.Regex_IsMatch_MethodCall(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` REGEXP '^T'"); - } - - [ConditionalTheory] - public override async Task Regex_IsMatch_MethodCall_constant_input(bool async) - { - await base.Regex_IsMatch_MethodCall_constant_input(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE 'ALFKI' REGEXP `c`.`CustomerID`"); - } - - [ConditionalTheory] - public override async Task Where_math_abs1(bool async) - { - await base.Where_math_abs1(async); - - AssertSql( - @"SELECT `p`.`ProductID`, `p`.`Discontinued`, `p`.`ProductName`, `p`.`SupplierID`, `p`.`UnitPrice`, `p`.`UnitsInStock` -FROM `Products` AS `p` -WHERE ABS(`p`.`ProductID`) > 10"); - } - - [ConditionalTheory] - public override async Task Where_math_abs2(bool async) - { - await base.Where_math_abs2(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`UnitPrice` < 7.0) AND (ABS(`o`.`Quantity`) > 10)"); - } - - [ConditionalTheory] - public override async Task Where_math_abs_uncorrelated(bool async) - { - await base.Where_math_abs_uncorrelated(async); - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`UnitPrice` < 7.0) AND (10 < `o`.`ProductID`) -"""); - } - - [ConditionalTheory] - public override async Task Select_math_round_int(bool async) - { - await base.Select_math_round_int(async); - - AssertSql( - $@"SELECT ROUND({MySqlTestHelpers.CastAsDouble("`o`.`OrderID`")}) AS `A` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` < 10250"); - } - - [ConditionalTheory] - public override async Task Where_math_min(bool async) - { - await base.Where_math_min(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (LEAST(`o`.`OrderID`, `o`.`ProductID`) = `o`.`ProductID`)"); - } - - [ConditionalTheory] - public override async Task Where_math_max(bool async) - { - await base.Where_math_max(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (GREATEST(`o`.`OrderID`, `o`.`ProductID`) = `o`.`OrderID`)"); - } - - [ConditionalTheory] - public override async Task Where_string_to_lower(bool async) - { - await base.Where_string_to_lower(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE LOWER(`c`.`CustomerID`) = 'alfki'"); - } - - [ConditionalTheory] - public override async Task Where_string_to_upper(bool async) - { - await base.Where_string_to_upper(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE UPPER(`c`.`CustomerID`) = 'ALFKI'"); - } - - [ConditionalTheory] - public override async Task TrimStart_without_arguments_in_predicate(bool async) - { - await base.TrimStart_without_arguments_in_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE TRIM(LEADING FROM `c`.`ContactTitle`) = 'Owner'"); - } - - [ConditionalTheory] - public override async Task TrimStart_with_char_argument_in_predicate(bool async) - { - await base.TrimStart_with_char_argument_in_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE TRIM(LEADING 'O' FROM `c`.`ContactTitle`) = 'wner'"); - } - - [ConditionalTheory] - public override Task TrimStart_with_char_array_argument_in_predicate(bool async) - { - // MySQL only supports a string (characters in fixed order) as the parameter specifying what should be trimmed. - // String.TrimStart has a different behavior, where any single character in any order will be trimmed. - // Therefore, calling String.TrimStart with more than one char to trim, triggers client eval. - return Assert.ThrowsAsync(() => base.TrimStart_with_char_array_argument_in_predicate(async)); - } - - [ConditionalTheory] - public override async Task TrimEnd_without_arguments_in_predicate(bool async) - { - await base.TrimEnd_without_arguments_in_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE TRIM(TRAILING FROM `c`.`ContactTitle`) = 'Owner'"); - } - - [ConditionalTheory] - public override async Task TrimEnd_with_char_argument_in_predicate(bool async) - { - await base.TrimEnd_with_char_argument_in_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE TRIM(TRAILING 'r' FROM `c`.`ContactTitle`) = 'Owne'"); - } - - [ConditionalTheory] - public override Task TrimEnd_with_char_array_argument_in_predicate(bool async) - { - // MySQL only supports a string (characters in fixed order) as the parameter specifying what should be trimmed. - // String.TrimEnd has a different behavior, where any single character in any order will be trimmed. - // Therefore, calling String.TrimEnd with more than one char to trim, triggers client eval. - return Assert.ThrowsAsync(() => base.TrimEnd_with_char_array_argument_in_predicate(async)); - } - - [ConditionalTheory] - public override async Task Trim_without_argument_in_predicate(bool async) - { - await base.Trim_without_argument_in_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE TRIM(`c`.`ContactTitle`) = 'Owner'"); - } - - [ConditionalTheory] - public override async Task Trim_with_char_argument_in_predicate(bool async) - { - await base.Trim_with_char_argument_in_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE TRIM('O' FROM `c`.`ContactTitle`) = 'wner'"); - } - - [ConditionalTheory] - public override Task Trim_with_char_array_argument_in_predicate(bool async) - { - // MySQL only supports a string (characters in fixed order) as the parameter specifying what should be trimmed. - // String.Trim has a different behavior, where any single character in any order will be trimmed. - // Therefore, calling String.Trim with more than one char to trim, triggers client eval. - return Assert.ThrowsAsync(() => base.Trim_with_char_array_argument_in_predicate(async)); - } - - public override async Task String_FirstOrDefault_MethodCall(bool async) - { - await base.String_FirstOrDefault_MethodCall(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE SUBSTRING(`c`.`ContactName`, 1, 1) = 'A'"); - } - - public override async Task String_Contains_constant_with_whitespace(bool async) - { - await base.String_Contains_constant_with_whitespace(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE '% %'"); - } - - public override async Task String_Contains_parameter_with_whitespace(bool async) - { - await base.String_Contains_parameter_with_whitespace(async); - - AssertSql( -""" -@__pattern_0_contains='% %' (Size = 30) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE @__pattern_0_contains -"""); - } - - public override async Task String_LastOrDefault_MethodCall(bool async) - { - await base.String_LastOrDefault_MethodCall(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE SUBSTRING(`c`.`ContactName`, CHAR_LENGTH(`c`.`ContactName`), 1) = 's'"); - } - - public override async Task Where_math_abs3(bool async) - { - await base.Where_math_abs3(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`Quantity` < 5) AND (ABS(`o`.`UnitPrice`) > 10.0)"); - } - - public override async Task Where_math_ceiling1(bool async) - { - await base.Where_math_ceiling1(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`UnitPrice` < 7.0) AND (CEILING({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 0.0)"); - } - - public override async Task Where_math_ceiling2(bool async) - { - await base.Where_math_ceiling2(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`Quantity` < 5) AND (CEILING(`o`.`UnitPrice`) > 10.0)"); - } - - public override async Task Where_math_floor(bool async) - { - await base.Where_math_floor(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`Quantity` < 5) AND (FLOOR(`o`.`UnitPrice`) > 10.0)"); - } - - public override async Task Where_math_power(bool async) - { - await base.Where_math_power(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE POWER({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}, 3.0) > 0.004999999888241291"); - } - - public override async Task Where_math_round(bool async) - { - await base.Where_math_round(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`Quantity` < 5) AND (ROUND(`o`.`UnitPrice`) > 10.0)"); - } - - public override async Task Select_math_truncate_int(bool async) - { - await base.Select_math_truncate_int(async); - - AssertSql( - $@"SELECT TRUNCATE({MySqlTestHelpers.CastAsDouble("`o`.`OrderID`")}, 0) AS `A` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` < 10250"); - } - - public override async Task Where_math_round2(bool async) - { - await base.Where_math_round2(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE ROUND(`o`.`UnitPrice`, 2) > 100.0"); - } - - public override async Task Where_math_truncate(bool async) - { - await base.Where_math_truncate(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`Quantity` < 5) AND (TRUNCATE(`o`.`UnitPrice`, 0) > 10.0)"); - } - - public override async Task Where_math_exp(bool async) - { - await base.Where_math_exp(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (EXP({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 1.0)"); - } - - public override async Task Where_math_log10(bool async) - { - await base.Where_math_log10(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE ((`o`.`OrderID` = 11077) AND (`o`.`Discount` > 0)) AND (LOG10({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) < 0.0)"); - } - - public override async Task Where_math_log(bool async) - { - await base.Where_math_log(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE ((`o`.`OrderID` = 11077) AND (`o`.`Discount` > 0)) AND (LOG({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) < 0.0)"); - } - - public override async Task Where_math_log_new_base(bool async) - { - await base.Where_math_log_new_base(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE ((`o`.`OrderID` = 11077) AND (`o`.`Discount` > 0)) AND (LOG(7.0, {MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) < -1.0)"); - } - - public override async Task Where_math_sqrt(bool async) - { - await base.Where_math_sqrt(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (SQRT({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 0.0)"); - } - - public override async Task Where_math_acos(bool async) - { - await base.Where_math_acos(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (ACOS({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 1.0)"); - } - - public override async Task Where_math_asin(bool async) - { - await base.Where_math_asin(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (ASIN({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 0.0)"); - } - - public override async Task Where_math_atan(bool async) - { - await base.Where_math_atan(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (ATAN({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 0.0)"); - } - - public override async Task Where_math_atan2(bool async) - { - await base.Where_math_atan2(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (ATAN2({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}, 1.0) > 0.0)"); - } - - public override async Task Where_math_cos(bool async) - { - await base.Where_math_cos(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (COS({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 0.0)"); - } - - public override async Task Where_math_sin(bool async) - { - await base.Where_math_sin(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (SIN({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 0.0)"); - } - - public override async Task Where_math_tan(bool async) - { - await base.Where_math_tan(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (TAN({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 0.0)"); - } - - public override async Task Where_math_sign(bool async) - { - await base.Where_math_sign(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (SIGN(`o`.`Discount`) > 0)"); - } - - public override async Task Where_guid_newguid(bool async) - { - await base.Where_guid_newguid(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE UUID() <> '00000000-0000-0000-0000-000000000000'"); - } - - public override async Task Where_functions_nested(bool async) - { - await base.Where_functions_nested(async); - - AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE POWER({MySqlTestHelpers.CastAsDouble("CHAR_LENGTH(`c`.`CustomerID`)")}, 2.0) = 25.0"); - } - - public override async Task IsNullOrEmpty_in_predicate(bool async) - { - await base.IsNullOrEmpty_in_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`Region` IS NULL OR (`c`.`Region` = '')"); - } - - public override async Task IsNullOrEmpty_in_projection(bool async) - { - await base.IsNullOrEmpty_in_projection(async); - } - - public override async Task IsNullOrEmpty_negated_in_projection(bool async) - { - await base.IsNullOrEmpty_negated_in_projection(async); - } - - public override async Task IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(bool async) - { - await base.IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE TRIM(`c`.`CustomerID`) = ''"); - } - - public override async Task Order_by_length_twice(bool async) - { - await base.Order_by_length_twice(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -ORDER BY CHAR_LENGTH(`c`.`CustomerID`), `c`.`CustomerID`"); - } - - public override async Task Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(bool async) - { - await base.Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Customers` AS `c` -LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` -ORDER BY CHAR_LENGTH(`c`.`CustomerID`), `c`.`CustomerID`"); - } - - public override async Task Static_string_equals_in_predicate(bool async) - { - await base.Static_string_equals_in_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'ANATR'"); - } - - public override async Task Static_equals_nullable_datetime_compared_to_non_nullable(bool async) - { - await base.Static_equals_nullable_datetime_compared_to_non_nullable(async); - - AssertSql( - @"@__arg_0='1996-07-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` = @__arg_0"); - } - - public override async Task Static_equals_int_compared_to_long(bool async) - { - await base.Static_equals_int_compared_to_long(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE FALSE"); - } - - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice(bool async) - { - await base.Projecting_Math_Truncate_and_ordering_by_it_twice(async); - - AssertSql( - $@"SELECT TRUNCATE({MySqlTestHelpers.CastAsDouble("`o`.`OrderID`")}, 0) AS `A` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` < 10250 -ORDER BY TRUNCATE({MySqlTestHelpers.CastAsDouble("`o`.`OrderID`")}, 0)"); - } - - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice2(bool async) - { - await base.Projecting_Math_Truncate_and_ordering_by_it_twice2(async); - - AssertSql( - $@"SELECT TRUNCATE({MySqlTestHelpers.CastAsDouble("`o`.`OrderID`")}, 0) AS `A` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` < 10250 -ORDER BY TRUNCATE({MySqlTestHelpers.CastAsDouble("`o`.`OrderID`")}, 0) DESC"); - } - - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bool async) - { - await base.Projecting_Math_Truncate_and_ordering_by_it_twice3(async); - - AssertSql( - $@"SELECT TRUNCATE({MySqlTestHelpers.CastAsDouble("`o`.`OrderID`")}, 0) AS `A` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` < 10250 -ORDER BY TRUNCATE({MySqlTestHelpers.CastAsDouble("`o`.`OrderID`")}, 0) DESC"); - } - - public override async Task String_Compare_simple_zero(bool async) - { - await base.String_Compare_simple_zero(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <> 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= 'AROUT' -"""); - } - - public override async Task String_Compare_simple_one(bool async) - { - await base.String_Compare_simple_one(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` < 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` >= 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` >= 'AROUT' -"""); - } - - public override async Task String_compare_with_parameter(bool async) - { - await base.String_compare_with_parameter(async); - - AssertSql( -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > @__customer_CustomerID_0 -""", - // -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` < @__customer_CustomerID_0 -""", - // -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= @__customer_CustomerID_0 -""", - // -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= @__customer_CustomerID_0 -""", - // -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` >= @__customer_CustomerID_0 -""", - // -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` >= @__customer_CustomerID_0 -"""); - } - - public override async Task String_Compare_simple_more_than_one(bool async) - { - await base.String_Compare_simple_more_than_one(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE CASE - WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 - WHEN `c`.`CustomerID` > 'ALFKI' THEN 1 - WHEN `c`.`CustomerID` < 'ALFKI' THEN -1 -END = 42", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE CASE - WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 - WHEN `c`.`CustomerID` > 'ALFKI' THEN 1 - WHEN `c`.`CustomerID` < 'ALFKI' THEN -1 -END > 42", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE 42 > CASE - WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 - WHEN `c`.`CustomerID` > 'ALFKI' THEN 1 - WHEN `c`.`CustomerID` < 'ALFKI' THEN -1 -END"); - } - - public override async Task String_Compare_nested(bool async) - { - await base.String_Compare_nested(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = (CONCAT('M', `c`.`CustomerID`))", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <> UPPER(`c`.`CustomerID`)", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > REPLACE('ALFKI', 'ALF', `c`.`CustomerID`)", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= (CONCAT('M', `c`.`CustomerID`))", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > UPPER(`c`.`CustomerID`)", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` < REPLACE('ALFKI', 'ALF', `c`.`CustomerID`)"); - } - - public override async Task String_Compare_multi_predicate(bool async) - { - await base.String_Compare_multi_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE (`c`.`CustomerID` >= 'ALFKI') AND (`c`.`CustomerID` < 'CACTU')", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE (`c`.`ContactTitle` = 'Owner') AND ((`c`.`Country` <> 'USA') OR `c`.`Country` IS NULL)"); - } - - public override async Task String_Compare_to_simple_zero(bool async) - { - await base.String_Compare_to_simple_zero(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <> 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= 'AROUT' -"""); - } - - public override async Task String_Compare_to_simple_one(bool async) - { - await base.String_Compare_to_simple_one(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` < 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` >= 'AROUT' -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` >= 'AROUT' -"""); - } - - public override async Task String_compare_to_with_parameter(bool async) - { - await base.String_compare_to_with_parameter(async); - - AssertSql( -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > @__customer_CustomerID_0 -""", - // -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` < @__customer_CustomerID_0 -""", - // -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= @__customer_CustomerID_0 -""", - // -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= @__customer_CustomerID_0 -""", - // -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` >= @__customer_CustomerID_0 -""", - // -""" -@__customer_CustomerID_0='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` >= @__customer_CustomerID_0 -"""); - } - - public override async Task String_Compare_to_simple_more_than_one(bool async) - { - await base.String_Compare_to_simple_more_than_one(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE CASE - WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 - WHEN `c`.`CustomerID` > 'ALFKI' THEN 1 - WHEN `c`.`CustomerID` < 'ALFKI' THEN -1 -END = 42", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE CASE - WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 - WHEN `c`.`CustomerID` > 'ALFKI' THEN 1 - WHEN `c`.`CustomerID` < 'ALFKI' THEN -1 -END > 42", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE 42 > CASE - WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 - WHEN `c`.`CustomerID` > 'ALFKI' THEN 1 - WHEN `c`.`CustomerID` < 'ALFKI' THEN -1 -END"); - } - - public override async Task String_Compare_to_nested(bool async) - { - await base.String_Compare_to_nested(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <> (CONCAT('M', `c`.`CustomerID`)) -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = UPPER(`c`.`CustomerID`) -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > REPLACE('AROUT', 'OUT', `c`.`CustomerID`) -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` <= (CONCAT('M', `c`.`CustomerID`)) -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` > UPPER(`c`.`CustomerID`) -""", - // -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` < REPLACE('AROUT', 'OUT', `c`.`CustomerID`) -"""); - } - - public override async Task String_Compare_to_multi_predicate(bool async) - { - await base.String_Compare_to_multi_predicate(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE (`c`.`CustomerID` >= 'ALFKI') AND (`c`.`CustomerID` < 'CACTU')", - // - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE (`c`.`ContactTitle` = 'Owner') AND ((`c`.`Country` <> 'USA') OR `c`.`Country` IS NULL)"); - } - - public override async Task DateTime_Compare_to_simple_zero(bool async, bool compareTo) - { - await base.DateTime_Compare_to_simple_zero(async, compareTo); - - AssertSql( - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` = @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`OrderDate` <> @__myDatetime_0) OR `o`.`OrderDate` IS NULL", - // - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` > @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` <= @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` > @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` <= @__myDatetime_0"); - } - - public override async Task TimeSpan_Compare_to_simple_zero(bool async, bool compareTo) - { - await base.TimeSpan_Compare_to_simple_zero(async, compareTo); - - AssertSql( - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` = @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`OrderDate` <> @__myDatetime_0) OR `o`.`OrderDate` IS NULL", - // - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` > @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` <= @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` > @__myDatetime_0", - // - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderDate` <= @__myDatetime_0"); - } - - public override async Task Int_Compare_to_simple_zero(bool async) - { - await base.Int_Compare_to_simple_zero(async); - - AssertSql( - @"@__orderId_0='10250' - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` = @__orderId_0", - // - @"@__orderId_0='10250' - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` <> @__orderId_0", - // - @"@__orderId_0='10250' - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` > @__orderId_0", - // - @"@__orderId_0='10250' - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` <= @__orderId_0", - // - @"@__orderId_0='10250' - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` > @__orderId_0", - // - @"@__orderId_0='10250' - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` <= @__orderId_0"); - } - - public override async Task Convert_ToBoolean(bool async) - { - await base.Convert_ToBoolean(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(CAST(`o`.`OrderID` % 3 AS unsigned) AS signed) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(CAST(`o`.`OrderID` % 3 AS decimal(65,30)) AS signed) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(CAST(`o`.`OrderID` % 3 AS double) AS signed) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(CAST(`o`.`OrderID` % 3 AS double) AS signed) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed) -"""); - } - - public override async Task Convert_ToByte(bool async) - { - await base.Convert_ToByte(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS unsigned) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS unsigned) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS unsigned) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS unsigned) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS unsigned) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS unsigned) >= 0) -"""); - } - - public override async Task Convert_ToDecimal(bool async) - { - await base.Convert_ToDecimal(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS decimal(65,30)) >= 0.0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS decimal(65,30)) >= 0.0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS decimal(65,30)) >= 0.0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS decimal(65,30)) >= 0.0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS decimal(65,30)) >= 0.0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS decimal(65,30)) >= 0.0) -"""); - } - - public override async Task Convert_ToDouble(bool async) - { - await base.Convert_ToDouble(async); - - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ({MySqlTestHelpers.CastAsDouble("CAST(`o`.`OrderID` % 1 AS signed)")} >= 0.0)", - // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ({MySqlTestHelpers.CastAsDouble("CAST(`o`.`OrderID` % 1 AS unsigned)")} >= 0.0)", - // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ({MySqlTestHelpers.CastAsDouble("CAST(`o`.`OrderID` % 1 AS decimal(65,30))")} >= 0.0)", - // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ({MySqlTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} >= 0.0)", - // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ({MySqlTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} >= 0.0)", - // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ({MySqlTestHelpers.CastAsDouble("CAST(`o`.`OrderID` % 1 AS signed)")} >= 0.0)", - // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ({MySqlTestHelpers.CastAsDouble("CAST(`o`.`OrderID` % 1 AS signed)")} >= 0.0)", - // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ({MySqlTestHelpers.CastAsDouble("CAST(`o`.`OrderID` % 1 AS signed)")} >= 0.0)", - // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ({MySqlTestHelpers.CastAsDouble("CAST(`o`.`OrderID` % 1 AS char)")} >= 0.0)", - // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ({MySqlTestHelpers.CastAsDouble("CAST(`o`.`OrderID` % 1 AS char)")} >= 0.0)"); - } - - public override async Task Convert_ToInt16(bool async) - { - await base.Convert_ToInt16(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) -"""); - } - - public override async Task Convert_ToInt32(bool async) - { - await base.Convert_ToInt32(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) -"""); - } - - public override async Task Convert_ToInt64(bool async) - { - await base.Convert_ToInt64(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) -"""); - } - - public override async Task Convert_ToString(bool async) - { - await base.Convert_ToString(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10') -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS char) <> '10') -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS char) <> '10') -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS char) <> '10') -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS double) AS char) <> '10') -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10') -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10') -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10') -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS char) <> '10') -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS char) <> '10') -""", - // - """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ((CAST(`o`.`OrderDate` AS char) LIKE '%1997%') OR (CAST(`o`.`OrderDate` AS char) LIKE '%1998%')) -"""); - } - - public override async Task String_StartsWith_Parameter(bool async) - { - await base.String_StartsWith_Parameter(async); - - AssertSql( -""" -@__pattern_0_startswith='M%' (Size = 30) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE @__pattern_0_startswith -"""); - } - - public override async Task String_EndsWith_Parameter(bool async) - { - await base.String_EndsWith_Parameter(async); - - AssertSql( -""" -@__pattern_0_endswith='%b' (Size = 30) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE @__pattern_0_endswith -"""); - } - - public override async Task String_Join_over_non_nullable_column(bool async) - { - await base.String_Join_over_non_nullable_column(async); - - AssertSql( -""" -SELECT `c1`.`City`, `c0`.`CustomerID` -FROM ( - SELECT `c`.`City` - FROM `Customers` AS `c` - GROUP BY `c`.`City` -) AS `c1` -LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` -ORDER BY `c1`.`City` -"""); - } - - public override async Task String_Join_with_predicate(bool async) - { - await base.String_Join_with_predicate(async); - - AssertSql( -""" -SELECT `c1`.`City`, `c2`.`CustomerID` -FROM ( - SELECT `c`.`City` - FROM `Customers` AS `c` - GROUP BY `c`.`City` -) AS `c1` -LEFT JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`City` - FROM `Customers` AS `c0` - WHERE CHAR_LENGTH(`c0`.`ContactName`) > 10 -) AS `c2` ON `c1`.`City` = `c2`.`City` -ORDER BY `c1`.`City` -"""); - } - - public override async Task String_Join_with_ordering(bool async) - { - await base.String_Join_with_ordering(async); - - AssertSql( -""" -SELECT `c1`.`City`, `c0`.`CustomerID` -FROM ( - SELECT `c`.`City` - FROM `Customers` AS `c` - GROUP BY `c`.`City` -) AS `c1` -LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` -ORDER BY `c1`.`City`, `c0`.`CustomerID` DESC -"""); - } - - public override async Task String_Join_over_nullable_column(bool async) - { - await base.String_Join_over_nullable_column(async); - - AssertSql( -""" -SELECT `c1`.`City`, `c0`.`Region`, `c0`.`CustomerID` -FROM ( - SELECT `c`.`City` - FROM `Customers` AS `c` - GROUP BY `c`.`City` -) AS `c1` -LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` -ORDER BY `c1`.`City` -"""); - } - - public override async Task String_Concat(bool async) - { - await base.String_Concat(async); - - AssertSql( -""" -SELECT `c1`.`City`, `c0`.`CustomerID` -FROM ( - SELECT `c`.`City` - FROM `Customers` AS `c` - GROUP BY `c`.`City` -) AS `c1` -LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` -ORDER BY `c1`.`City` -"""); - } - - public override async Task Where_math_square(bool async) - { - await base.Where_math_square(async); - - AssertSql( -$""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE POWER({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}, 2.0) > 0.05000000074505806 -"""); - } - - public override async Task Sum_over_round_works_correctly_in_projection(bool async) - { - await base.Sum_over_round_works_correctly_in_projection(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, ( - SELECT COALESCE(SUM(ROUND(`o0`.`UnitPrice`, 2)), 0.0) - FROM `Order Details` AS `o0` - WHERE `o`.`OrderID` = `o0`.`OrderID`) AS `Sum` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` < 10300 -"""); - } - - public override async Task Sum_over_round_works_correctly_in_projection_2(bool async) - { - await base.Sum_over_round_works_correctly_in_projection_2(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, ( - SELECT COALESCE(SUM(ROUND(`o0`.`UnitPrice` * `o0`.`UnitPrice`, 2)), 0.0) - FROM `Order Details` AS `o0` - WHERE `o`.`OrderID` = `o0`.`OrderID`) AS `Sum` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` < 10300 -"""); - } - - public override async Task Sum_over_truncate_works_correctly_in_projection(bool async) - { - await base.Sum_over_truncate_works_correctly_in_projection(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, ( - SELECT COALESCE(SUM(TRUNCATE(`o0`.`UnitPrice`, 0)), 0.0) - FROM `Order Details` AS `o0` - WHERE `o`.`OrderID` = `o0`.`OrderID`) AS `Sum` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` < 10300 -"""); - } - - public override async Task Sum_over_truncate_works_correctly_in_projection_2(bool async) - { - await base.Sum_over_truncate_works_correctly_in_projection_2(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, ( - SELECT COALESCE(SUM(TRUNCATE(`o0`.`UnitPrice` * `o0`.`UnitPrice`, 0)), 0.0) - FROM `Order Details` AS `o0` - WHERE `o`.`OrderID` = `o0`.`OrderID`) AS `Sum` -FROM `Orders` AS `o` -WHERE `o`.`OrderID` < 10300 -"""); - } - - public override async Task Where_math_degrees(bool async) - { - await base.Where_math_degrees(async); - - AssertSql( -$""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (DEGREES({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 0.0) -"""); - } - - public override async Task Where_math_radians(bool async) - { - await base.Where_math_radians(async); - - AssertSql( -$""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (RADIANS({MySqlTestHelpers.CastAsDouble("`o`.`Discount`")}) > 0.0) -"""); - } - - public override async Task Where_mathf_abs1(bool async) - { - await base.Where_mathf_abs1(async); - - AssertSql( -$""" -SELECT `p`.`ProductID`, `p`.`Discontinued`, `p`.`ProductName`, `p`.`SupplierID`, `p`.`UnitPrice`, `p`.`UnitsInStock` -FROM `Products` AS `p` -WHERE ABS({MySqlTestHelpers.CastAsDouble("`p`.`ProductID`")}) > 10 -"""); - } - - public override async Task Where_mathf_ceiling1(bool async) - { - await base.Where_mathf_ceiling1(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`UnitPrice` < 7.0) AND (CEILING(`o`.`Discount`) > 0) -"""); - } - - public override async Task Where_mathf_floor(bool async) - { - await base.Where_mathf_floor(async); - - AssertSql( -$""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`Quantity` < 5) AND (FLOOR({MySqlTestHelpers.CastAsDouble("`o`.`UnitPrice`")}) > 10) -"""); - } - - public override async Task Where_mathf_power(bool async) - { - await base.Where_mathf_power(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE POWER(`o`.`Discount`, 3) > 0.005 -"""); - } - - public override async Task Where_mathf_square(bool async) - { - await base.Where_mathf_square(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE POWER(`o`.`Discount`, 2) > 0.05 -"""); - } - - public override async Task Where_mathf_round2(bool async) - { - await base.Where_mathf_round2(async); - - AssertSql( -$""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE ROUND({MySqlTestHelpers.CastAsDouble("`o`.`UnitPrice`")}, 2) > 100 -"""); - } - - public override async Task Select_mathf_round(bool async) - { - await base.Select_mathf_round(async); - - AssertSql( -$""" -SELECT ROUND({MySqlTestHelpers.CastAsDouble("`o`.`OrderID`")}) -FROM `Orders` AS `o` -WHERE `o`.`OrderID` < 10250 -"""); - } - - public override async Task Select_mathf_round2(bool async) - { - await base.Select_mathf_round2(async); - - AssertSql( -$""" -SELECT ROUND({MySqlTestHelpers.CastAsDouble("`o`.`UnitPrice`")}, 2) -FROM `Order Details` AS `o` -WHERE `o`.`Quantity` < 5 -"""); - } - - public override async Task Where_mathf_truncate(bool async) - { - await base.Where_mathf_truncate(async); - - AssertSql( -$""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`Quantity` < 5) AND (TRUNCATE({MySqlTestHelpers.CastAsDouble("`o`.`UnitPrice`")}, 0) > 10) -"""); - } - - public override async Task Select_mathf_truncate(bool async) - { - await base.Select_mathf_truncate(async); - - AssertSql( -$""" -SELECT TRUNCATE({MySqlTestHelpers.CastAsDouble("`o`.`UnitPrice`")}, 0) -FROM `Order Details` AS `o` -WHERE `o`.`Quantity` < 5 -"""); - } - - public override async Task Where_mathf_exp(bool async) - { - await base.Where_mathf_exp(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (EXP(`o`.`Discount`) > 1) -"""); - } - - public override async Task Where_mathf_log10(bool async) - { - await base.Where_mathf_log10(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE ((`o`.`OrderID` = 11077) AND (`o`.`Discount` > 0)) AND (LOG10(`o`.`Discount`) < 0) -"""); - } - - public override async Task Where_mathf_log(bool async) - { - await base.Where_mathf_log(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE ((`o`.`OrderID` = 11077) AND (`o`.`Discount` > 0)) AND (LOG(`o`.`Discount`) < 0) -"""); - } - - public override async Task Where_mathf_log_new_base(bool async) - { - await base.Where_mathf_log_new_base(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE ((`o`.`OrderID` = 11077) AND (`o`.`Discount` > 0)) AND (LOG(7, `o`.`Discount`) < -1) -"""); - } - - public override async Task Where_mathf_sqrt(bool async) - { - await base.Where_mathf_sqrt(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (SQRT(`o`.`Discount`) > 0) -"""); - } - - public override async Task Where_mathf_acos(bool async) - { - await base.Where_mathf_acos(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (ACOS(`o`.`Discount`) > 1) -"""); - } - - public override async Task Where_mathf_asin(bool async) - { - await base.Where_mathf_asin(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (ASIN(`o`.`Discount`) > 0) -"""); - } - - public override async Task Where_mathf_atan(bool async) - { - await base.Where_mathf_atan(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (ATAN(`o`.`Discount`) > 0) -"""); - } - - public override async Task Where_mathf_atan2(bool async) - { - await base.Where_mathf_atan2(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (ATAN2(`o`.`Discount`, 1) > 0) -"""); - } - - public override async Task Where_mathf_cos(bool async) - { - await base.Where_mathf_cos(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (COS(`o`.`Discount`) > 0) -"""); - } - - public override async Task Where_mathf_sin(bool async) - { - await base.Where_mathf_sin(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (SIN(`o`.`Discount`) > 0) -"""); - } - - public override async Task Where_mathf_tan(bool async) - { - await base.Where_mathf_tan(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (TAN(`o`.`Discount`) > 0) -"""); - } - - public override async Task Where_mathf_sign(bool async) - { - await base.Where_mathf_sign(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (SIGN(`o`.`Discount`) > 0) -"""); - } - - public override async Task Where_mathf_degrees(bool async) - { - await base.Where_mathf_degrees(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (DEGREES(`o`.`Discount`) > 0) -"""); - } - - public override async Task Where_mathf_radians(bool async) - { - await base.Where_mathf_radians(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (RADIANS(`o`.`Discount`) > 0) -"""); - } - - public override async Task Indexof_with_one_constant_arg(bool async) - { - await base.Indexof_with_one_constant_arg(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE (LOCATE('a', `c`.`ContactName`) - 1) = 1 -"""); - } - - public override async Task Indexof_with_one_parameter_arg(bool async) - { - await base.Indexof_with_one_parameter_arg(async); - - AssertSql( -""" -@__pattern_0='a' (Size = 4000) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE (LOCATE(@__pattern_0, `c`.`ContactName`) - 1) = 1 -"""); - } - - public override async Task Indexof_with_constant_starting_position(bool async) + public override async Task Where_functions_nested(bool async) { - await base.Indexof_with_constant_starting_position(async); + await base.Where_functions_nested(async); AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE (LOCATE('a', `c`.`ContactName`, 3) - 1) = 4 -"""); +WHERE POWER({MySqlTestHelpers.CastAsDouble("CHAR_LENGTH(`c`.`CustomerID`)")}, 2.0) = 25.0"); } - public override async Task Indexof_with_parameter_starting_position(bool async) + public override async Task Order_by_length_twice(bool async) { - await base.Indexof_with_parameter_starting_position(async); + await base.Order_by_length_twice(async); AssertSql( -""" -@__start_0='2' - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE (LOCATE('a', `c`.`ContactName`, @__start_0 + 1) - 1) = 4 -"""); +ORDER BY CHAR_LENGTH(`c`.`CustomerID`), `c`.`CustomerID`"); } - public override async Task Replace_using_property_arguments(bool async) + public override async Task Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(bool async) { - await base.Replace_using_property_arguments(async); + await base.Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(async); AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Customers` AS `c` -WHERE REPLACE(`c`.`ContactName`, `c`.`ContactName`, `c`.`CustomerID`) = `c`.`CustomerID` -"""); +LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` +ORDER BY CHAR_LENGTH(`c`.`CustomerID`), `c`.`CustomerID`"); } - public override async Task IsNullOrEmpty_negated_in_predicate(bool async) + public override async Task Static_equals_nullable_datetime_compared_to_non_nullable(bool async) { - await base.IsNullOrEmpty_negated_in_predicate(async); + await base.Static_equals_nullable_datetime_compared_to_non_nullable(async); AssertSql( """ -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`Region` IS NOT NULL AND (`c`.`Region` <> '') -"""); - } +@arg='1996-07-04T00:00:00.0000000' (DbType = DateTime) - public override async Task Where_DateOnly_FromDateTime(bool async) - { - await base.Where_DateOnly_FromDateTime(async); - - AssertSql( -""" SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE `o`.`OrderDate` IS NOT NULL AND (DATE(`o`.`OrderDate`) = DATE '1996-09-16') -"""); - } - - public override async Task String_StartsWith_with_StringComparison_Ordinal(bool async) - { - await base.String_StartsWith_with_StringComparison_Ordinal(async); - - AssertSql(); - } - - public override async Task String_StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - { - await base.String_StartsWith_with_StringComparison_OrdinalIgnoreCase(async); - - AssertSql(); - } - - public override async Task String_EndsWith_with_StringComparison_Ordinal(bool async) - { - await base.String_EndsWith_with_StringComparison_Ordinal(async); - - AssertSql(); - } - - public override async Task String_EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - { - await base.String_EndsWith_with_StringComparison_OrdinalIgnoreCase(async); - - AssertSql(); - } - - public override async Task String_Contains_with_StringComparison_Ordinal(bool async) - { - await base.String_Contains_with_StringComparison_Ordinal(async); - - AssertSql(); - } - - public override async Task String_Contains_with_StringComparison_OrdinalIgnoreCase(bool async) - { - await base.String_Contains_with_StringComparison_OrdinalIgnoreCase(async); - - AssertSql(); - } - - public override async Task String_StartsWith_with_StringComparison_unsupported(bool async) - { - await base.String_StartsWith_with_StringComparison_unsupported(async); - - AssertSql(); - } - - public override async Task String_EndsWith_with_StringComparison_unsupported(bool async) - { - await base.String_EndsWith_with_StringComparison_unsupported(async); - - AssertSql(); - } - - public override async Task String_Contains_in_projection(bool async) - { - await base.String_Contains_in_projection(async); - - AssertSql( -""" -SELECT `c`.`CustomerID` AS `Id`, `c`.`ContactName` IS NOT NULL AND ((LOCATE(`c`.`ContactName`, `c`.`CompanyName`) > 0) OR (`c`.`ContactName` LIKE '')) AS `Value` -FROM `Customers` AS `c` -"""); - } - - public override async Task String_Contains_negated_in_predicate(bool async) - { - await base.String_Contains_negated_in_predicate(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactName` IS NULL OR ((LOCATE(`c`.`ContactName`, `c`.`CompanyName`) <= 0) AND `c`.`ContactName` NOT LIKE '') -"""); - } - - public override async Task String_Contains_negated_in_projection(bool async) - { - await base.String_Contains_negated_in_projection(async); - - AssertSql( -""" -SELECT `c`.`CustomerID` AS `Id`, `c`.`ContactName` IS NULL OR ((LOCATE(`c`.`ContactName`, `c`.`CompanyName`) <= 0) AND `c`.`ContactName` NOT LIKE '') AS `Value` -FROM `Customers` AS `c` -"""); - } - - public override async Task String_Contains_with_StringComparison_unsupported(bool async) - { - await base.String_Contains_with_StringComparison_unsupported(async); - - AssertSql(); - } - - public override async Task String_Join_non_aggregate(bool async) - { - await base.String_Join_non_aggregate(async); - - AssertSql( -""" -@__foo_0='foo' (Size = 4000) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE CONCAT_WS('|', `c`.`CompanyName`, @__foo_0, '', 'bar') = 'Around the Horn|foo||bar' -"""); - } - - public override async Task Where_math_max_nested(bool async) - { - await base.Where_math_max_nested(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (GREATEST(`o`.`OrderID`, `o`.`ProductID`, 1) = `o`.`OrderID`) +WHERE `o`.`OrderDate` = @arg """); } - public override async Task Where_math_max_nested_twice(bool async) + public override async Task Static_equals_int_compared_to_long(bool async) { - await base.Where_math_max_nested_twice(async); + await base.Static_equals_int_compared_to_long(async); AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (GREATEST(1, `o`.`OrderID`, 2, `o`.`ProductID`) = `o`.`OrderID`) -"""); + @"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE FALSE"); } - public override async Task Where_math_min_nested(bool async) + public override async Task Sum_over_round_works_correctly_in_projection(bool async) { - await base.Where_math_min_nested(async); + await base.Sum_over_round_works_correctly_in_projection(async); AssertSql( """ -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (LEAST(`o`.`OrderID`, `o`.`ProductID`, 99999) = `o`.`ProductID`) +SELECT `o`.`OrderID`, ( + SELECT COALESCE(SUM(ROUND(`o0`.`UnitPrice`, 2)), 0.0) + FROM `Order Details` AS `o0` + WHERE `o`.`OrderID` = `o0`.`OrderID`) AS `Sum` +FROM `Orders` AS `o` +WHERE `o`.`OrderID` < 10300 """); } - public override async Task Where_math_min_nested_twice(bool async) + public override async Task Sum_over_round_works_correctly_in_projection_2(bool async) { - await base.Where_math_min_nested_twice(async); + await base.Sum_over_round_works_correctly_in_projection_2(async); AssertSql( """ -SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` -FROM `Order Details` AS `o` -WHERE (`o`.`OrderID` = 11077) AND (LEAST(99999, `o`.`OrderID`, 99998, `o`.`ProductID`) = `o`.`ProductID`) +SELECT `o`.`OrderID`, ( + SELECT COALESCE(SUM(ROUND(`o0`.`UnitPrice` * `o0`.`UnitPrice`, 2)), 0.0) + FROM `Order Details` AS `o0` + WHERE `o`.`OrderID` = `o0`.`OrderID`) AS `Sum` +FROM `Orders` AS `o` +WHERE `o`.`OrderID` < 10300 """); } - public override async Task Select_ToString_IndexOf(bool async) + public override async Task Sum_over_truncate_works_correctly_in_projection(bool async) { - await base.Select_ToString_IndexOf(async); + await base.Sum_over_truncate_works_correctly_in_projection(async); AssertSql( """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `o`.`OrderID`, ( + SELECT COALESCE(SUM(TRUNCATE(`o0`.`UnitPrice`, 0)), 0.0) + FROM `Order Details` AS `o0` + WHERE `o`.`OrderID` = `o0`.`OrderID`) AS `Sum` FROM `Orders` AS `o` -WHERE (LOCATE('123', CAST(`o`.`OrderID` AS char)) - 1) = -1 +WHERE `o`.`OrderID` < 10300 """); } - public override async Task Select_IndexOf_ToString(bool async) + public override async Task Sum_over_truncate_works_correctly_in_projection_2(bool async) { - await base.Select_IndexOf_ToString(async); + await base.Sum_over_truncate_works_correctly_in_projection_2(async); AssertSql( """ -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `o`.`OrderID`, ( + SELECT COALESCE(SUM(TRUNCATE(`o0`.`UnitPrice` * `o0`.`UnitPrice`, 0)), 0.0) + FROM `Order Details` AS `o0` + WHERE `o`.`OrderID` = `o0`.`OrderID`) AS `Sum` FROM `Orders` AS `o` -WHERE (LOCATE(CAST(`o`.`OrderID` AS char), '123') - 1) = -1 +WHERE `o`.`OrderID` < 10300 """); } - public override Task Datetime_subtraction_TotalDays(bool async) - => AssertTranslationFailed(() => base.Datetime_subtraction_TotalDays(async)); - [ConditionalFact] public virtual void Check_all_tests_overridden() => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); diff --git a/test/EFCore.MySql.FunctionalTests/Query/NorthwindGroupByQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/NorthwindGroupByQueryMySqlTest.cs index b44d9f100..fcd7f35a3 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NorthwindGroupByQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NorthwindGroupByQueryMySqlTest.cs @@ -134,9 +134,11 @@ public override async Task GroupBy_group_Distinct_Select_Distinct_aggregate(bool await base.GroupBy_group_Distinct_Select_Distinct_aggregate(async); AssertSql( - @"SELECT `o`.`CustomerID` AS `Key`, MAX(DISTINCT (`o`.`OrderDate`)) AS `Max` +""" +SELECT `o`.`CustomerID` AS `Key`, MAX(`o`.`OrderDate`) AS `Max` FROM `Orders` AS `o` -GROUP BY `o`.`CustomerID`"); +GROUP BY `o`.`CustomerID` +"""); } public override async Task GroupBy_Property_Select_Average(bool async) @@ -1012,11 +1014,11 @@ public override async Task GroupBy_param_Select_Sum_Min_Key_Max_Avg(bool async) AssertSql( """ -@__a_0='2' +@a='2' SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum`, MIN(`o0`.`OrderID`) AS `Min`, `o0`.`Key`, MAX(`o0`.`OrderID`) AS `Max`, AVG(CAST(`o0`.`OrderID` AS double)) AS `Avg` FROM ( - SELECT `o`.`OrderID`, @__a_0 AS `Key` + SELECT `o`.`OrderID`, @a AS `Key` FROM `Orders` AS `o` ) AS `o0` GROUP BY `o0`.`Key` @@ -1029,11 +1031,11 @@ public override async Task GroupBy_param_with_element_selector_Select_Sum(bool a AssertSql( """ -@__a_0='2' +@a='2' SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum` FROM ( - SELECT `o`.`OrderID`, @__a_0 AS `Key` + SELECT `o`.`OrderID`, @a AS `Key` FROM `Orders` AS `o` ) AS `o0` GROUP BY `o0`.`Key` @@ -1046,11 +1048,11 @@ public override async Task GroupBy_param_with_element_selector_Select_Sum2(bool AssertSql( """ -@__a_0='2' +@a='2' SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum` FROM ( - SELECT `o`.`OrderID`, @__a_0 AS `Key` + SELECT `o`.`OrderID`, @a AS `Key` FROM `Orders` AS `o` ) AS `o0` GROUP BY `o0`.`Key` @@ -1063,11 +1065,11 @@ public override async Task GroupBy_param_with_element_selector_Select_Sum3(bool AssertSql( """ -@__a_0='2' +@a='2' SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum` FROM ( - SELECT `o`.`OrderID`, @__a_0 AS `Key` + SELECT `o`.`OrderID`, @a AS `Key` FROM `Orders` AS `o` ) AS `o0` GROUP BY `o0`.`Key` @@ -1080,11 +1082,11 @@ public override async Task GroupBy_param_with_element_selector_Select_Sum_Min_Ke AssertSql( """ -@__a_0='2' +@a='2' SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum`, `o0`.`Key` FROM ( - SELECT `o`.`OrderID`, @__a_0 AS `Key` + SELECT `o`.`OrderID`, @a AS `Key` FROM `Orders` AS `o` ) AS `o0` GROUP BY `o0`.`Key` @@ -1463,14 +1465,14 @@ public override async Task OrderBy_Skip_GroupBy_Aggregate(bool async) AssertSql( """ -@__p_0='80' +@p='80' SELECT AVG(CAST(`o0`.`OrderID` AS double)) FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID` FROM `Orders` AS `o` ORDER BY `o`.`OrderID` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `o0` GROUP BY `o0`.`CustomerID` """); @@ -1482,14 +1484,14 @@ public override async Task OrderBy_Take_GroupBy_Aggregate(bool async) AssertSql( """ -@__p_0='500' +@p='500' SELECT MIN(`o0`.`OrderID`) FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID` FROM `Orders` AS `o` ORDER BY `o`.`OrderID` - LIMIT @__p_0 + LIMIT @p ) AS `o0` GROUP BY `o0`.`CustomerID` """); @@ -1501,15 +1503,15 @@ public override async Task OrderBy_Skip_Take_GroupBy_Aggregate(bool async) AssertSql( """ -@__p_1='500' -@__p_0='80' +@p0='500' +@p='80' SELECT MAX(`o0`.`OrderID`) FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID` FROM `Orders` AS `o` ORDER BY `o`.`OrderID` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `o0` GROUP BY `o0`.`CustomerID` """); @@ -1590,9 +1592,9 @@ public override async Task Join_complex_GroupBy_Aggregate(bool async) AssertSql( """ -@__p_0='100' -@__p_2='50' -@__p_1='10' +@p='100' +@p1='50' +@p0='10' SELECT `c0`.`CustomerID` AS `Key`, AVG(CAST(`o0`.`OrderID` AS double)) AS `Count` FROM ( @@ -1600,14 +1602,14 @@ public override async Task Join_complex_GroupBy_Aggregate(bool async) FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10400 ORDER BY `o`.`OrderDate` - LIMIT @__p_0 + LIMIT @p ) AS `o0` INNER JOIN ( SELECT `c`.`CustomerID` FROM `Customers` AS `c` WHERE `c`.`CustomerID` NOT IN ('DRACD', 'FOLKO') ORDER BY `c`.`City` - LIMIT @__p_2 OFFSET @__p_1 + LIMIT @p1 OFFSET @p0 ) AS `c0` ON `o0`.`CustomerID` = `c0`.`CustomerID` GROUP BY `c0`.`CustomerID` """); @@ -1698,9 +1700,9 @@ public override async Task GroupJoin_complex_GroupBy_Aggregate(bool async) AssertSql( """ -@__p_1='50' -@__p_0='10' -@__p_2='100' +@p0='50' +@p='10' +@p1='100' SELECT `o0`.`CustomerID` AS `Key`, AVG(CAST(`o0`.`OrderID` AS double)) AS `Count` FROM ( @@ -1708,14 +1710,14 @@ public override async Task GroupJoin_complex_GroupBy_Aggregate(bool async) FROM `Customers` AS `c` WHERE `c`.`CustomerID` NOT IN ('DRACD', 'FOLKO') ORDER BY `c`.`City` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `c0` INNER JOIN ( SELECT `o`.`OrderID`, `o`.`CustomerID` FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10400 ORDER BY `o`.`OrderDate` - LIMIT @__p_2 + LIMIT @p1 ) AS `o0` ON `c0`.`CustomerID` = `o0`.`CustomerID` WHERE `o0`.`OrderID` > 10300 GROUP BY `o0`.`CustomerID` @@ -1918,8 +1920,8 @@ public override async Task GroupBy_aggregate_Pushdown(bool async) AssertSql( """ -@__p_0='20' -@__p_1='4' +@p='20' +@p0='4' SELECT `o0`.`CustomerID` FROM ( @@ -1928,10 +1930,10 @@ public override async Task GroupBy_aggregate_Pushdown(bool async) GROUP BY `o`.`CustomerID` HAVING COUNT(*) > 10 ORDER BY `o`.`CustomerID` - LIMIT @__p_0 + LIMIT @p ) AS `o0` ORDER BY `o0`.`CustomerID` -LIMIT 18446744073709551610 OFFSET @__p_1 +LIMIT 18446744073709551610 OFFSET @p0 """); } @@ -1941,8 +1943,8 @@ public override async Task GroupBy_aggregate_using_grouping_key_Pushdown(bool as AssertSql( """ -@__p_0='20' -@__p_1='4' +@p='20' +@p0='4' SELECT `o0`.`Key`, `o0`.`Max` FROM ( @@ -1951,10 +1953,10 @@ public override async Task GroupBy_aggregate_using_grouping_key_Pushdown(bool as GROUP BY `o`.`CustomerID` HAVING COUNT(*) > 10 ORDER BY `o`.`CustomerID` - LIMIT @__p_0 + LIMIT @p ) AS `o0` ORDER BY `o0`.`Key` -LIMIT 18446744073709551610 OFFSET @__p_1 +LIMIT 18446744073709551610 OFFSET @p0 """); } @@ -1964,8 +1966,8 @@ public override async Task GroupBy_aggregate_Pushdown_followed_by_projecting_Len AssertSql( """ -@__p_0='20' -@__p_1='4' +@p='20' +@p0='4' SELECT CHAR_LENGTH(`o0`.`CustomerID`) FROM ( @@ -1974,10 +1976,10 @@ SELECT CHAR_LENGTH(`o0`.`CustomerID`) GROUP BY `o`.`CustomerID` HAVING COUNT(*) > 10 ORDER BY `o`.`CustomerID` - LIMIT @__p_0 + LIMIT @p ) AS `o0` ORDER BY `o0`.`CustomerID` -LIMIT 18446744073709551610 OFFSET @__p_1 +LIMIT 18446744073709551610 OFFSET @p0 """); } @@ -1987,8 +1989,8 @@ public override async Task GroupBy_aggregate_Pushdown_followed_by_projecting_con AssertSql( """ -@__p_0='20' -@__p_1='4' +@p='20' +@p0='4' SELECT 5 FROM ( @@ -1997,10 +1999,10 @@ SELECT 5 GROUP BY `o`.`CustomerID` HAVING COUNT(*) > 10 ORDER BY `o`.`CustomerID` - LIMIT @__p_0 + LIMIT @p ) AS `o0` ORDER BY `o0`.`CustomerID` -LIMIT 18446744073709551610 OFFSET @__p_1 +LIMIT 18446744073709551610 OFFSET @p0 """); } @@ -2419,14 +2421,14 @@ public override async Task GroupBy_with_order_by_skip_and_another_order_by(bool AssertSql( """ -@__p_0='80' +@p='80' SELECT COALESCE(SUM(`o0`.`OrderID`), 0) FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID` FROM `Orders` AS `o` ORDER BY `o`.`CustomerID`, `o`.`OrderID` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `o0` GROUP BY `o0`.`CustomerID` """); @@ -2561,7 +2563,7 @@ public override async Task GroupBy_aggregate_from_right_side_of_join(bool async) AssertSql( """ -@__p_0='10' +@p='10' SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`Max` FROM `Customers` AS `c` @@ -2571,7 +2573,7 @@ INNER JOIN ( GROUP BY `o`.`CustomerID` ) AS `o0` ON `c`.`CustomerID` = `o0`.`Key` ORDER BY `o0`.`Max`, `c`.`CustomerID` -LIMIT @__p_0 OFFSET @__p_0 +LIMIT @p OFFSET @p """); } @@ -2877,7 +2879,7 @@ public override async Task GroupBy_Select_Distinct_aggregate(bool async) AssertSql( """ -SELECT `o`.`CustomerID` AS `Key`, AVG(DISTINCT (CAST(`o`.`OrderID` AS double))) AS `Average`, COUNT(DISTINCT (`o`.`EmployeeID`)) AS `Count`, COUNT(DISTINCT (`o`.`EmployeeID`)) AS `LongCount`, MAX(DISTINCT (`o`.`OrderDate`)) AS `Max`, MIN(DISTINCT (`o`.`OrderDate`)) AS `Min`, COALESCE(SUM(DISTINCT (`o`.`OrderID`)), 0) AS `Sum` +SELECT `o`.`CustomerID` AS `Key`, AVG(DISTINCT (CAST(`o`.`OrderID` AS double))) AS `Average`, COUNT(DISTINCT (`o`.`EmployeeID`)) AS `Count`, COUNT(DISTINCT (`o`.`EmployeeID`)) AS `LongCount`, MAX(`o`.`OrderDate`) AS `Max`, MIN(`o`.`OrderDate`) AS `Min`, COALESCE(SUM(DISTINCT (`o`.`OrderID`)), 0) AS `Sum` FROM `Orders` AS `o` GROUP BY `o`.`CustomerID` """); diff --git a/test/EFCore.MySql.FunctionalTests/Query/NorthwindMiscellaneousQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/NorthwindMiscellaneousQueryMySqlTest.cs index 5fe746fd6..27d8bc9b3 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NorthwindMiscellaneousQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NorthwindMiscellaneousQueryMySqlTest.cs @@ -8,13 +8,13 @@ using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; using MySqlConnector; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.Infrastructure; using Pomelo.EntityFrameworkCore.MySql.Internal; using Pomelo.EntityFrameworkCore.MySql.Tests; using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes; using Xunit; using Xunit.Abstractions; -using Xunit.Sdk; namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query { @@ -30,162 +30,6 @@ public NorthwindMiscellaneousQueryMySqlTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - public override async Task Select_bitwise_or(bool async) - { - await base.Select_bitwise_or(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`CustomerID` IN ('ALFKI', 'ANATR') AS `Value` -FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID` -"""); - } - - public override async Task Select_bitwise_or_multiple(bool async) - { - await base.Select_bitwise_or_multiple(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`CustomerID` IN ('ALFKI', 'ANATR', 'ANTON') AS `Value` -FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID` -"""); - } - - public override async Task Select_bitwise_and(bool async) - { - await base.Select_bitwise_and(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, FALSE AS `Value` -FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID` -"""); - } - - public override async Task Select_bitwise_and_or(bool async) - { - await base.Select_bitwise_and_or(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`CustomerID` = 'ANTON' AS `Value` -FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID` -"""); - } - - public override async Task Where_bitwise_or_with_logical_or(bool async) - { - await base.Where_bitwise_or_with_logical_or(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` IN ('ALFKI', 'ANATR', 'ANTON') -"""); - } - - public override async Task Where_bitwise_and_with_logical_and(bool async) - { - await base.Where_bitwise_and_with_logical_and(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE FALSE -"""); - } - - public override async Task Where_bitwise_or_with_logical_and(bool async) - { - await base.Where_bitwise_or_with_logical_and(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` IN ('ALFKI', 'ANATR') AND (`c`.`Country` = 'Germany') -"""); - } - - public override async Task Where_bitwise_and_with_logical_or(bool async) - { - await base.Where_bitwise_and_with_logical_or(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'ANTON' -"""); - } - - public override async Task Where_bitwise_binary_not(bool async) - { - await base.Where_bitwise_binary_not(async); - - AssertSql( - @"@__negatedId_0='-10249' - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE CAST(~`o`.`OrderID` AS signed) = @__negatedId_0"); - } - - public override async Task Where_bitwise_binary_and(bool async) - { - await base.Where_bitwise_binary_and(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE CAST(`o`.`OrderID` & 10248 AS signed) = 10248 -"""); - } - - public override async Task Where_bitwise_binary_or(bool async) - { - await base.Where_bitwise_binary_or(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE CAST(`o`.`OrderID` | 10248 AS signed) = 10248 -"""); - } - - public override async Task Select_bitwise_or_with_logical_or(bool async) - { - await base.Select_bitwise_or_with_logical_or(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`CustomerID` IN ('ALFKI', 'ANATR', 'ANTON') AS `Value` -FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID` -"""); - } - - public override async Task Select_bitwise_and_with_logical_and(bool async) - { - await base.Select_bitwise_and_with_logical_and(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, FALSE AS `Value` -FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID` -"""); - } - [ConditionalTheory] public override async Task Take_Skip(bool async) { @@ -193,18 +37,18 @@ public override async Task Take_Skip(bool async) AssertSql( """ -@__p_0='10' -@__p_1='5' +@p='10' +@p0='5' SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`ContactName` - LIMIT @__p_0 + LIMIT @p ) AS `c0` ORDER BY `c0`.`ContactName` -LIMIT 18446744073709551610 OFFSET @__p_1 +LIMIT 18446744073709551610 OFFSET @p0 """); } @@ -214,11 +58,13 @@ public override async Task Select_expression_references_are_updated_correctly_wi await base.Select_expression_references_are_updated_correctly_with_subquery(async); AssertSql( - @"@__nextYear_0='2017' +""" +@nextYear='2017' SELECT DISTINCT EXTRACT(year FROM `o`.`OrderDate`) FROM `Orders` AS `o` -WHERE `o`.`OrderDate` IS NOT NULL AND (EXTRACT(year FROM `o`.`OrderDate`) < @__nextYear_0)"); +WHERE `o`.`OrderDate` IS NOT NULL AND (EXTRACT(year FROM `o`.`OrderDate`) < @nextYear) +"""); } public override Task Entity_equality_orderby_subquery(bool async) @@ -272,7 +118,7 @@ await AssertQuery( AssertSql( """ -@__p_0='5' +@p='5' SELECT `o1`.`OrderID`, `o0`.`ProductID`, `o0`.`OrderID` FROM ( @@ -280,7 +126,7 @@ await AssertQuery( FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 ORDER BY `o`.`OrderID` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `o1` LEFT JOIN `Order Details` AS `o0` ON `o1`.`OrderID` = `o0`.`OrderID` ORDER BY `o1`.`OrderID`, `o0`.`ProductID` @@ -311,8 +157,8 @@ await AssertQuery( AssertSql( """ -@__p_1='10' -@__p_0='5' +@p0='10' +@p='5' SELECT `o1`.`OrderID`, `o0`.`ProductID`, `o0`.`OrderID` FROM ( @@ -320,7 +166,7 @@ await AssertQuery( FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 ORDER BY `o`.`OrderID` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `o1` LEFT JOIN `Order Details` AS `o0` ON `o1`.`OrderID` = `o0`.`OrderID` ORDER BY `o1`.`OrderID`, `o0`.`ProductID` @@ -350,7 +196,7 @@ await AssertQuery( AssertSql( """ -@__p_0='10' +@p='10' SELECT `o1`.`OrderID`, `o0`.`ProductID`, `o0`.`OrderID` FROM ( @@ -358,7 +204,7 @@ await AssertQuery( FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 ORDER BY `o`.`OrderID` - LIMIT @__p_0 + LIMIT @p ) AS `o1` LEFT JOIN `Order Details` AS `o0` ON `o1`.`OrderID` = `o0`.`OrderID` ORDER BY `o1`.`OrderID`, `o0`.`ProductID` @@ -510,6 +356,10 @@ public override Task DefaultIfEmpty_Sum_over_collection_navigation(bool async) return base.DefaultIfEmpty_Sum_over_collection_navigation(async); } + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.MySql.FunctionalTests/Query/NorthwindQueryFiltersQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/NorthwindQueryFiltersQueryMySqlTest.cs index 5c0c8e84d..f2216ce28 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NorthwindQueryFiltersQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NorthwindQueryFiltersQueryMySqlTest.cs @@ -22,11 +22,11 @@ public override async Task Count_query(bool async) AssertSql( """ -@__ef_filter__TenantPrefix_0_startswith='B%' (Size = 40) +@ef_filter__TenantPrefix_startswith='B%' (Size = 40) SELECT COUNT(*) FROM `Customers` AS `c` -WHERE `c`.`CompanyName` LIKE @__ef_filter__TenantPrefix_0_startswith +WHERE `c`.`CompanyName` LIKE @ef_filter__TenantPrefix_startswith """); } diff --git a/test/EFCore.MySql.FunctionalTests/Query/NorthwindSetOperationsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/NorthwindSetOperationsQueryMySqlTest.cs index 610bd82b5..250e1108c 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NorthwindSetOperationsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NorthwindSetOperationsQueryMySqlTest.cs @@ -142,17 +142,21 @@ public override async Task Except_nested(bool async) await base.Except_nested(async); AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`ContactTitle` = 'Owner' -EXCEPT -SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` -FROM `Customers` AS `c0` -WHERE `c0`.`City` = 'México D.F.' +""" +( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + WHERE `c`.`ContactTitle` = 'Owner' + EXCEPT + SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + FROM `Customers` AS `c0` + WHERE `c0`.`City` = 'México D.F.' +) EXCEPT SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region` FROM `Customers` AS `c1` -WHERE `c1`.`City` = 'Seattle'"); +WHERE `c1`.`City` = 'Seattle' +"""); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.ExceptIntercept))] diff --git a/test/EFCore.MySql.FunctionalTests/Query/NorthwindStringComparisonFunctionsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/NorthwindStringComparisonFunctionsQueryMySqlTest.cs index ad16ef30d..89babeedf 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NorthwindStringComparisonFunctionsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NorthwindStringComparisonFunctionsQueryMySqlTest.cs @@ -44,12 +44,12 @@ await AssertQuery( // When the comparison parameter is not a constant, we have to use a case // statement AssertSql( - $@"@__comparison_0='{comparison:D}' + $@"@comparison='{comparison:D}' SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE CASE - WHEN @__comparison_0 IN (4, 0, 2) THEN `c`.`CustomerID` = CONVERT('anton' USING utf8mb4) COLLATE utf8mb4_bin + WHEN @comparison IN (4, 0, 2) THEN `c`.`CustomerID` = CONVERT('anton' USING utf8mb4) COLLATE utf8mb4_bin ELSE LCASE(`c`.`CustomerID`) = CONVERT(LCASE('anton') USING utf8mb4) COLLATE utf8mb4_bin END"); } @@ -161,12 +161,12 @@ await AssertQuery( // When the comparison parameter is not a constant, we have to use a case // statement AssertSql( - $@"@__comparison_0='{comparison:D}' + $@"@comparison='{comparison:D}' SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE CASE - WHEN @__comparison_0 IN (4, 0, 2) THEN `c`.`CustomerID` = CONVERT('anton' USING utf8mb4) COLLATE utf8mb4_bin + WHEN @comparison IN (4, 0, 2) THEN `c`.`CustomerID` = CONVERT('anton' USING utf8mb4) COLLATE utf8mb4_bin ELSE LCASE(`c`.`CustomerID`) = CONVERT(LCASE('anton') USING utf8mb4) COLLATE utf8mb4_bin END"); } @@ -278,12 +278,12 @@ await AssertQuery( // When the comparison parameter is not a constant, we have to use a case // statement AssertSql( - $@"@__comparison_0='{comparison:D}' + $@"@comparison='{comparison:D}' SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE CASE - WHEN @__comparison_0 IN (4, 0, 2) THEN `c`.`CustomerID` LIKE CONVERT('%nto%' USING utf8mb4) COLLATE utf8mb4_bin + WHEN @comparison IN (4, 0, 2) THEN `c`.`CustomerID` LIKE CONVERT('%nto%' USING utf8mb4) COLLATE utf8mb4_bin ELSE LCASE(`c`.`CustomerID`) LIKE CONVERT(LCASE('%nto%') USING utf8mb4) COLLATE utf8mb4_bin END"); } @@ -398,12 +398,12 @@ await AssertQuery( // When the comparison parameter is not a constant, we have to use a case // statement AssertSql( - $@"@__comparison_0='{comparison:D}' + $@"@comparison='{comparison:D}' SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE CASE - WHEN @__comparison_0 IN (4, 0, 2) THEN `c`.`CustomerID` LIKE CONVERT('anto' USING utf8mb4) COLLATE utf8mb4_bin + WHEN @comparison IN (4, 0, 2) THEN `c`.`CustomerID` LIKE CONVERT('anto' USING utf8mb4) COLLATE utf8mb4_bin ELSE LCASE(`c`.`CustomerID`) LIKE CONVERT(LCASE('anto%') USING utf8mb4) COLLATE utf8mb4_bin END"); } @@ -516,12 +516,12 @@ await AssertQuery( assertEmpty: expected == 0); AssertSql( - $@"@__comparison_0='{comparison:D}' + $@"@comparison='{comparison:D}' SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE CASE - WHEN @__comparison_0 IN (4, 0, 2) THEN `c`.`CustomerID` LIKE CONVERT('%nton' USING utf8mb4) COLLATE utf8mb4_bin + WHEN @comparison IN (4, 0, 2) THEN `c`.`CustomerID` LIKE CONVERT('%nton' USING utf8mb4) COLLATE utf8mb4_bin ELSE LCASE(`c`.`CustomerID`) LIKE CONVERT(LCASE('%nton') USING utf8mb4) COLLATE utf8mb4_bin END"); } @@ -635,12 +635,12 @@ await AssertQuery( // When the comparison parameter is not a constant, we have to use a case // statement - AssertSql($"@__comparison_0='{comparison:D}'" + @" + AssertSql($"@comparison='{comparison:D}'" + @" SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE CASE - WHEN @__comparison_0 IN (4, 0, 2) THEN LOCATE(CONVERT('nt' USING utf8mb4) COLLATE utf8mb4_bin, `c`.`CustomerID`) - 1 + WHEN @comparison IN (4, 0, 2) THEN LOCATE(CONVERT('nt' USING utf8mb4) COLLATE utf8mb4_bin, `c`.`CustomerID`) - 1 ELSE LOCATE(CONVERT(LCASE('nt') USING utf8mb4) COLLATE utf8mb4_bin, LCASE(`c`.`CustomerID`)) - 1 END = 1"); } @@ -672,11 +672,11 @@ await AssertQuery( assertEmpty: expected == 0); AssertSql( - @$"@__startIndex_0='{startIndex}' + @$"@startIndex='{startIndex}' SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE (LOCATE(CONVERT(LCASE('nt') USING utf8mb4) COLLATE utf8mb4_bin, LCASE(`c`.`CustomerID`), @__startIndex_0 + 1) - 1) = 1"); +WHERE (LOCATE(CONVERT(LCASE('nt') USING utf8mb4) COLLATE utf8mb4_bin, LCASE(`c`.`CustomerID`), @startIndex + 1) - 1) = 1"); } [ConditionalTheory] diff --git a/test/EFCore.MySql.FunctionalTests/Query/NorthwindWhereQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/NorthwindWhereQueryMySqlTest.cs index 2c708a97a..8ef6c2df7 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NorthwindWhereQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NorthwindWhereQueryMySqlTest.cs @@ -1,10 +1,11 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes; using Xunit; using Xunit.Abstractions; @@ -23,195 +24,6 @@ public NorthwindWhereQueryMySqlTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - [ConditionalTheory] - public override async Task Where_datetime_now(bool async) - { - await base.Where_datetime_now(async); - - AssertSql( - @"@__myDatetime_0='2015-04-10T00:00:00.0000000' (DbType = DateTime) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE CURRENT_TIMESTAMP(6) <> @__myDatetime_0"); - } - - [ConditionalTheory] - public override async Task Where_datetime_utcnow(bool async) - { - await base.Where_datetime_utcnow(async); - - AssertSql( - @"@__myDatetime_0='2015-04-10T00:00:00.0000000' (DbType = DateTime) - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE UTC_TIMESTAMP(6) <> @__myDatetime_0"); - } - - [ConditionalTheory] - public override async Task Where_datetime_today(bool async) - { - await base.Where_datetime_today(async); - - AssertSql( - @"SELECT `e`.`EmployeeID`, `e`.`City`, `e`.`Country`, `e`.`FirstName`, `e`.`ReportsTo`, `e`.`Title` -FROM `Employees` AS `e` -WHERE CONVERT(CURRENT_TIMESTAMP(6), date) = CURDATE()"); - } - - [ConditionalTheory] - public override async Task Where_datetime_date_component(bool async) - { - await base.Where_datetime_date_component(async); - - AssertSql( - @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE CONVERT(`o`.`OrderDate`, date) = @__myDatetime_0"); - } - - [ConditionalTheory] - public override async Task Where_datetime_year_component(bool async) - { - await base.Where_datetime_year_component(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE EXTRACT(year FROM `o`.`OrderDate`) = 1998"); - } - - [ConditionalTheory] - public override async Task Where_datetime_month_component(bool async) - { - await base.Where_datetime_month_component(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE EXTRACT(month FROM `o`.`OrderDate`) = 4"); - } - - [ConditionalTheory] - public override async Task Where_datetime_dayOfYear_component(bool async) - { - await base.Where_datetime_dayOfYear_component(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE DAYOFYEAR(`o`.`OrderDate`) = 68"); - } - - [ConditionalTheory] - public override async Task Where_datetime_day_component(bool async) - { - await base.Where_datetime_day_component(async); - - AssertSql( - @"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE EXTRACT(day FROM `o`.`OrderDate`) = 4"); - } - - [ConditionalTheory] - public override async Task Where_datetime_hour_component(bool async) - { - await base.Where_datetime_hour_component(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE EXTRACT(hour FROM `o`.`OrderDate`) = 0 -"""); - } - - [ConditionalTheory] - public override async Task Where_datetime_minute_component(bool async) - { - await base.Where_datetime_minute_component(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE EXTRACT(minute FROM `o`.`OrderDate`) = 0 -"""); - } - - [ConditionalTheory] - public override async Task Where_datetime_second_component(bool async) - { - await base.Where_datetime_second_component(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE EXTRACT(second FROM `o`.`OrderDate`) = 0 -"""); - } - - [ConditionalTheory] - public override async Task Where_datetime_millisecond_component(bool async) - { - await base.Where_datetime_millisecond_component(async); - - AssertSql( -""" -SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Orders` AS `o` -WHERE (EXTRACT(microsecond FROM `o`.`OrderDate`)) DIV (1000) = 0 -"""); - } - - [ConditionalTheory] - public override async Task Where_string_length(bool async) - { - await base.Where_string_length(async); - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE CHAR_LENGTH(`c`.`City`) = 6"); - } - - [ConditionalTheory] - public override async Task Where_string_indexof(bool async) - { - await base.Where_string_indexof(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE ((LOCATE('Sea', `c`.`City`) - 1) <> -1) OR `c`.`City` IS NULL"); - } - - [ConditionalTheory] - public override async Task Where_string_replace(bool async) - { - await base.Where_string_replace(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE REPLACE(`c`.`City`, 'Sea', 'Rea') = 'Reattle'"); - } - - [ConditionalTheory] - public override async Task Where_string_substring(bool async) - { - await base.Where_string_substring(async); - - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE SUBSTRING(`c`.`City`, 1 + 1, 2) = 'ea'"); - } - [ConditionalTheory(Skip = "issue #573")] public override Task Where_as_queryable_expression(bool async) { @@ -269,42 +81,13 @@ await AssertQuery( ss => ss.Set().Where(c => guidParameter == Guid.NewGuid()), assertEmpty: true); - AssertSql( - @"@__guidParameter_0='4d68fe70-ddb0-47d7-b6db-437684fa3e1f' - -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE @__guidParameter_0 = UUID()"); - } - - public override async Task Where_string_concat_method_comparison_2(bool async) - { - await base.Where_string_concat_method_comparison_2(async); - AssertSql( """ -@__i_0='A' (Size = 4000) -@__j_1='B' (Size = 4000) +@guidParameter='4d68fe70-ddb0-47d7-b6db-437684fa3e1f' -SELECT `c`.`CustomerID` -FROM `Customers` AS `c` -WHERE CONCAT(@__i_0, @__j_1, `c`.`CustomerID`) = 'ABANATR' -"""); - } - - public override async Task Where_string_concat_method_comparison_3(bool async) - { - await base.Where_string_concat_method_comparison_3(async); - - AssertSql( -""" -@__i_0='A' (Size = 4000) -@__j_1='B' (Size = 4000) -@__k_2='C' (Size = 4000) - -SELECT `c`.`CustomerID` +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE CONCAT(@__i_0, @__j_1, @__k_2, `c`.`CustomerID`) = 'ABCANTON' +WHERE @guidParameter = UUID() """); } @@ -320,11 +103,13 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__Concat_0='1' (Size = 40) +""" +@Concat='1' (Size = 40) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE @__Concat_0 = `c`.`CompanyName`"); +WHERE @Concat = `c`.`CompanyName` +"""); } [ConditionalTheory] @@ -339,11 +124,13 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__i_0='1' (Size = 4000) +""" +@i='1' (Size = 4000) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE CONCAT(@__i_0, `c`.`CustomerID`) = `c`.`CompanyName`"); +WHERE CONCAT(@i, `c`.`CustomerID`) = `c`.`CompanyName` +"""); } [ConditionalTheory] @@ -359,12 +146,14 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__i_0='1' (Size = 4000) -@__j_1='2' (Size = 4000) +""" +@i='1' (Size = 4000) +@j='2' (Size = 4000) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE CONCAT(@__i_0, @__j_1, `c`.`CustomerID`) = `c`.`CompanyName`"); +WHERE CONCAT(@i, @j, `c`.`CustomerID`) = `c`.`CompanyName` +"""); } [ConditionalTheory] @@ -382,13 +171,13 @@ await AssertQuery( AssertSql( """ -@__i_0='1' (Size = 4000) -@__j_1='2' (Size = 4000) -@__k_2='3' (Size = 4000) +@i='1' (Size = 4000) +@j='2' (Size = 4000) +@k='3' (Size = 4000) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE CONCAT(@__i_0, @__j_1, @__k_2, `c`.`CustomerID`) = `c`.`CompanyName` +WHERE CONCAT(@i, @j, @k, `c`.`CustomerID`) = `c`.`CompanyName` """); } @@ -408,14 +197,14 @@ await AssertQuery( AssertSql( """ -@__i_0='A' (Size = 4000) -@__j_1='B' (Size = 4000) -@__k_2='C' (Size = 4000) -@__m_3='D' (Size = 4000) +@i='A' (Size = 4000) +@j='B' (Size = 4000) +@k='C' (Size = 4000) +@m='D' (Size = 4000) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE CONCAT(@__i_0, @__j_1, @__k_2, @__m_3, `c`.`CustomerID`) = `c`.`CompanyName` +WHERE CONCAT(@i, @j, @k, @m, `c`.`CustomerID`) = `c`.`CompanyName` """); } @@ -431,11 +220,13 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__Concat_0='ABCD' (Size = 40) +""" +@Concat='ABCD' (Size = 40) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE @__Concat_0 = `c`.`CompanyName`"); +WHERE @Concat = `c`.`CompanyName` +"""); } [ConditionalTheory] @@ -450,11 +241,13 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__Concat_0='A' (Size = 40) +""" +@Concat='A' (Size = 40) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE @__Concat_0 = `c`.`CompanyName`"); +WHERE @Concat = `c`.`CompanyName` +"""); } [ConditionalTheory] @@ -473,14 +266,14 @@ await AssertQuery( AssertSql( """ -@__i_0='1' (Size = 4000) -@__j_1='2' (Size = 4000) -@__k_2='3' (Size = 4000) -@__m_3='4' (Size = 4000) +@i='1' (Size = 4000) +@j='2' (Size = 4000) +@k='3' (Size = 4000) +@m='4' (Size = 4000) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE CONCAT(@__i_0, @__j_1, @__k_2, @__m_3, `c`.`CustomerID`) = `c`.`CompanyName` +WHERE CONCAT(@i, @j, @k, @m, `c`.`CustomerID`) = `c`.`CompanyName` """); } @@ -496,11 +289,13 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__Concat_0='1234' (Size = 40) +""" +@Concat='1234' (Size = 40) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE @__Concat_0 = `c`.`CompanyName`"); +WHERE @Concat = `c`.`CompanyName` +"""); } [ConditionalTheory] @@ -515,11 +310,13 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__Concat_0='1' (Size = 40) +""" +@Concat='1' (Size = 40) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE @__Concat_0 = `c`.`CompanyName`"); +WHERE @Concat = `c`.`CompanyName` +"""); } [ConditionalTheory] @@ -534,11 +331,13 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__Concat_0='ABCD' (Size = 40) +""" +@Concat='ABCD' (Size = 40) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE @__Concat_0 = `c`.`CompanyName`"); +WHERE @Concat = `c`.`CompanyName` +"""); } [ConditionalTheory] @@ -553,11 +352,13 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__Concat_0='A' (Size = 40) +""" +@Concat='A' (Size = 40) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE @__Concat_0 = `c`.`CompanyName`"); +WHERE @Concat = `c`.`CompanyName` +"""); } [ConditionalTheory] @@ -572,11 +373,13 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__Concat_0='1234' (Size = 40) +""" +@Concat='1234' (Size = 40) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE @__Concat_0 = `c`.`CompanyName`"); +WHERE @Concat = `c`.`CompanyName` +"""); } [ConditionalTheory] @@ -591,22 +394,12 @@ await AssertQuery( assertEmpty: true); AssertSql( - @"@__Concat_0='1' (Size = 40) +""" +@Concat='1' (Size = 40) SELECT `c`.`CustomerID` FROM `Customers` AS `c` -WHERE @__Concat_0 = `c`.`CompanyName`"); - } - - public override async Task Where_bitwise_xor(bool async) - { - await base.Where_bitwise_xor(async); - - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE (`c`.`CustomerID` = 'ALFKI') ^ TRUE +WHERE @Concat = `c`.`CompanyName` """); } @@ -619,74 +412,6 @@ We changed MariaDbServerVersion.DefaultUtf8CiCollation and MariaDbServerVersion. If we run the this test against a Ubuntu hosted MariaDB, the test always works. If we run the this test against a Windows hosted MariaDB, the test fails only on the first execution (when the database does not preexist). But it works on all consecutive runs. If we change MariaDbServerVersion.DefaultUtf8CiCollation and MariaDbServerVersion.DefaultUtf8CsCollation to use the new default collations only from 11.5.0, the Ubuntu/Windows behavior flips to Windows always working and Ubuntu not successfully executing the test on the first run. -The error is: - MySqlConnector.MySqlException : Illegal mix of collations (utf8mb4_bin,NONE) and (utf8mb4_general_ci,IMPLICIT) for operation '=' -""")] - public override Task Where_concat_string_int_comparison1(bool async) - { - return base.Where_concat_string_int_comparison1(async); - } - - // TODO: 9.0 - [SupportedServerVersionBetweenCondition("11.4.2-mariadb", "11.5.0-mariadb", Invert = true, Skip = -""" -There is some strange collation behavior with MariaDB 11.4.x and this test (seems fixed in 11.5). -The default utf8mb4 collation was changed in 11.4.2 from utf8mb4_general_ci to utf8mb4_uca1400_ai_ci. -We changed MariaDbServerVersion.DefaultUtf8CiCollation and MariaDbServerVersion.DefaultUtf8CsCollation accordingly. -If we run the this test against a Ubuntu hosted MariaDB, the test always works. -If we run the this test against a Windows hosted MariaDB, the test fails only on the first execution (when the database does not preexist). But it works on all consecutive runs. -If we change MariaDbServerVersion.DefaultUtf8CiCollation and MariaDbServerVersion.DefaultUtf8CsCollation to use the new default collations only from 11.5.0, the Ubuntu/Windows behavior flips to Windows always working and Ubuntu not successfully executing the test on the first run. -The error is: - MySqlConnector.MySqlException : Illegal mix of collations (utf8mb4_bin,NONE) and (utf8mb4_general_ci,IMPLICIT) for operation '=' -""")] - public override Task Where_concat_string_int_comparison2(bool async) - { - return base.Where_concat_string_int_comparison2(async); - } - - // TODO: 9.0 - [SupportedServerVersionBetweenCondition("11.4.2-mariadb", "11.5.0-mariadb", Invert = true, Skip = -""" -There is some strange collation behavior with MariaDB 11.4.x and this test (seems fixed in 11.5). -The default utf8mb4 collation was changed in 11.4.2 from utf8mb4_general_ci to utf8mb4_uca1400_ai_ci. -We changed MariaDbServerVersion.DefaultUtf8CiCollation and MariaDbServerVersion.DefaultUtf8CsCollation accordingly. -If we run the this test against a Ubuntu hosted MariaDB, the test always works. -If we run the this test against a Windows hosted MariaDB, the test fails only on the first execution (when the database does not preexist). But it works on all consecutive runs. -If we change MariaDbServerVersion.DefaultUtf8CiCollation and MariaDbServerVersion.DefaultUtf8CsCollation to use the new default collations only from 11.5.0, the Ubuntu/Windows behavior flips to Windows always working and Ubuntu not successfully executing the test on the first run. -The error is: - MySqlConnector.MySqlException : Illegal mix of collations (utf8mb4_bin,NONE) and (utf8mb4_general_ci,IMPLICIT) for operation '=' -""")] - public override Task Where_concat_string_int_comparison3(bool async) - { - return base.Where_concat_string_int_comparison3(async); - } - - // TODO: 9.0 - [SupportedServerVersionBetweenCondition("11.4.2-mariadb", "11.5.0-mariadb", Invert = true, Skip = -""" -There is some strange collation behavior with MariaDB 11.4.x and this test (seems fixed in 11.5). -The default utf8mb4 collation was changed in 11.4.2 from utf8mb4_general_ci to utf8mb4_uca1400_ai_ci. -We changed MariaDbServerVersion.DefaultUtf8CiCollation and MariaDbServerVersion.DefaultUtf8CsCollation accordingly. -If we run the this test against a Ubuntu hosted MariaDB, the test always works. -If we run the this test against a Windows hosted MariaDB, the test fails only on the first execution (when the database does not preexist). But it works on all consecutive runs. -If we change MariaDbServerVersion.DefaultUtf8CiCollation and MariaDbServerVersion.DefaultUtf8CsCollation to use the new default collations only from 11.5.0, the Ubuntu/Windows behavior flips to Windows always working and Ubuntu not successfully executing the test on the first run. -The error is: - MySqlConnector.MySqlException : Illegal mix of collations (utf8mb4_bin,NONE) and (utf8mb4_general_ci,IMPLICIT) for operation '=' -""")] - public override Task Where_concat_string_int_comparison4(bool async) - { - return base.Where_concat_string_int_comparison4(async); - } - - // TODO: 9.0 - [SupportedServerVersionBetweenCondition("11.4.2-mariadb", "11.5.0-mariadb", Invert = true, Skip = -""" -There is some strange collation behavior with MariaDB 11.4.x and this test (seems fixed in 11.5). -The default utf8mb4 collation was changed in 11.4.2 from utf8mb4_general_ci to utf8mb4_uca1400_ai_ci. -We changed MariaDbServerVersion.DefaultUtf8CiCollation and MariaDbServerVersion.DefaultUtf8CsCollation accordingly. -If we run the this test against a Ubuntu hosted MariaDB, the test always works. -If we run the this test against a Windows hosted MariaDB, the test fails only on the first execution (when the database does not preexist). But it works on all consecutive runs. -If we change MariaDbServerVersion.DefaultUtf8CiCollation and MariaDbServerVersion.DefaultUtf8CsCollation to use the new default collations only from 11.5.0, the Ubuntu/Windows behavior flips to Windows always working and Ubuntu not successfully executing the test on the first run. The error is: MySqlConnector.MySqlException : Illegal mix of collations (utf8mb4_bin,NONE) and (utf8mb4_uca1400_ai_ci,COERCIBLE) for operation '=' """)] @@ -767,6 +492,10 @@ public override async Task Where_compare_tuple_constructed_multi_value_not_equal AssertSql(); } + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.MySql.FunctionalTests/Query/NullSemanticsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/NullSemanticsQueryMySqlTest.cs index 31b6ee795..c48f315c8 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/NullSemanticsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/NullSemanticsQueryMySqlTest.cs @@ -52,11 +52,13 @@ await AssertQueryScalar( .Select(e => e.Id)); AssertSql( - @"@__prm_0='False' +""" +@prm='False' SELECT `e`.`Id` FROM `Entities1` AS `e` -WHERE @__prm_0 = (`e`.`NullableBoolC` IS NOT NULL)"); +WHERE @prm = (`e`.`NullableBoolC` IS NOT NULL) +"""); } protected override NullSemanticsContext CreateContext(bool useRelationalNulls = false) diff --git a/test/EFCore.MySql.FunctionalTests/Query/OperatorsProceduralMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/OperatorsProceduralMySqlTest.cs index e8b9f7eb0..358c78d82 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/OperatorsProceduralMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/OperatorsProceduralMySqlTest.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; @@ -6,6 +7,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class OperatorsProceduralMySqlTest : OperatorsProceduralQueryTestBase { + public OperatorsProceduralMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; } diff --git a/test/EFCore.MySql.FunctionalTests/Query/OperatorsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/OperatorsQueryMySqlTest.cs index c182b2838..468581df7 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/OperatorsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/OperatorsQueryMySqlTest.cs @@ -1,5 +1,7 @@ using System; using System.Threading.Tasks; +using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestModels.Operators; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -10,6 +12,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class OperatorsQueryMySqlTest : OperatorsQueryTestBase { + public OperatorsQueryMySqlTest([NotNull] NonSharedFixture fixture) + : base(fixture) + { + } + protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; diff --git a/test/EFCore.MySql.FunctionalTests/Query/OwnedEntityQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/OwnedEntityQueryMySqlTest.cs index 1f85720d7..c3437c046 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/OwnedEntityQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/OwnedEntityQueryMySqlTest.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; @@ -12,6 +11,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query { public class OwnedEntityQueryMySqlTest : OwnedEntityQueryRelationalTestBase { + public OwnedEntityQueryMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; public override async Task Multiple_single_result_in_projection_containing_owned_types(bool async) diff --git a/test/EFCore.MySql.FunctionalTests/Query/PrimitiveCollectionsQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/PrimitiveCollectionsQueryMySqlTest.cs index 8f2c4e74a..9c30ea606 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/PrimitiveCollectionsQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/PrimitiveCollectionsQueryMySqlTest.cs @@ -26,56 +26,57 @@ public PrimitiveCollectionsQueryMySqlTest(PrimitiveCollectionsQueryMySqlFixture Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - public override async Task Inline_collection_of_ints_Contains(bool async) + public override async Task Inline_collection_of_ints_Contains() { - await base.Inline_collection_of_ints_Contains(async); + await base.Inline_collection_of_ints_Contains(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Int` IN (10, 999) """); } - public override async Task Inline_collection_of_nullable_ints_Contains(bool async) + public override async Task Inline_collection_of_nullable_ints_Contains() { - await base.Inline_collection_of_nullable_ints_Contains(async); + await base.Inline_collection_of_nullable_ints_Contains(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`NullableInt` IN (10, 999) """); } - public override async Task Inline_collection_of_nullable_ints_Contains_null(bool async) + public override async Task Inline_collection_of_nullable_ints_Contains_null() { - await base.Inline_collection_of_nullable_ints_Contains_null(async); + await base.Inline_collection_of_nullable_ints_Contains_null(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`NullableInt` IS NULL OR (`p`.`NullableInt` = 999) """); } - public override async Task Inline_collection_Count_with_zero_values(bool async) + public override async Task Inline_collection_Count_with_zero_values() { - await base.Inline_collection_Count_with_zero_values(async); + await base.Inline_collection_Count_with_zero_values(); - AssertSql(); + AssertSql( +); } - public override async Task Inline_collection_Count_with_one_value(bool async) + public override async Task Inline_collection_Count_with_one_value() { - await base.Inline_collection_Count_with_one_value(async); + await base.Inline_collection_Count_with_one_value(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE ( SELECT COUNT(*) @@ -84,15 +85,15 @@ SELECT COUNT(*) """); } - public override async Task Inline_collection_Count_with_two_values(bool async) + public override async Task Inline_collection_Count_with_two_values() { - await base.Inline_collection_Count_with_two_values(async); + await base.Inline_collection_Count_with_two_values(); if (AppConfig.ServerVersion.Supports.ValuesWithRows) { AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE ( SELECT COUNT(*) @@ -118,15 +119,15 @@ SELECT COUNT(*) } } - public override async Task Inline_collection_Count_with_three_values(bool async) + public override async Task Inline_collection_Count_with_three_values() { - await base.Inline_collection_Count_with_three_values(async); + await base.Inline_collection_Count_with_three_values(); if (AppConfig.ServerVersion.Supports.ValuesWithRows) { AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE ( SELECT COUNT(*) @@ -151,130 +152,130 @@ SELECT COUNT(*) } } - public override async Task Inline_collection_Contains_with_zero_values(bool async) + public override async Task Inline_collection_Contains_with_zero_values() { - await base.Inline_collection_Contains_with_zero_values(async); + await base.Inline_collection_Contains_with_zero_values(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE FALSE """); } - public override async Task Inline_collection_Contains_with_one_value(bool async) + public override async Task Inline_collection_Contains_with_one_value() { - await base.Inline_collection_Contains_with_one_value(async); + await base.Inline_collection_Contains_with_one_value(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Id` = 2 """); } - public override async Task Inline_collection_Contains_with_two_values(bool async) + public override async Task Inline_collection_Contains_with_two_values() { - await base.Inline_collection_Contains_with_two_values(async); + await base.Inline_collection_Contains_with_two_values(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Id` IN (2, 999) """); } - public override async Task Inline_collection_Contains_with_three_values(bool async) + public override async Task Inline_collection_Contains_with_three_values() { - await base.Inline_collection_Contains_with_three_values(async); + await base.Inline_collection_Contains_with_three_values(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Id` IN (2, 999, 1000) """); } - public override async Task Inline_collection_Contains_with_all_parameters(bool async) + public override async Task Inline_collection_Contains_with_all_parameters() { - await base.Inline_collection_Contains_with_all_parameters(async); + await base.Inline_collection_Contains_with_all_parameters(); AssertSql( """ -@__i_0='2' -@__j_1='999' +@i='2' +@j='999' -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Id` IN (@__i_0, @__j_1) +WHERE `p`.`Id` IN (@i, @j) """); } - public override async Task Inline_collection_Contains_with_constant_and_parameter(bool async) + public override async Task Inline_collection_Contains_with_constant_and_parameter() { - await base.Inline_collection_Contains_with_constant_and_parameter(async); + await base.Inline_collection_Contains_with_constant_and_parameter(); AssertSql( """ -@__j_0='999' +@j='999' -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Id` IN (2, @__j_0) +WHERE `p`.`Id` IN (2, @j) """); } - public override async Task Inline_collection_Contains_with_mixed_value_types(bool async) + public override async Task Inline_collection_Contains_with_mixed_value_types() { - await base.Inline_collection_Contains_with_mixed_value_types(async); + await base.Inline_collection_Contains_with_mixed_value_types(); AssertSql( """ -@__i_0='11' +@i='11' -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Int` IN (999, @__i_0, `p`.`Id`, `p`.`Id` + `p`.`Int`) +WHERE `p`.`Int` IN (999, @i, `p`.`Id`, `p`.`Id` + `p`.`Int`) """); } - public override async Task Inline_collection_negated_Contains_as_All(bool async) + public override async Task Inline_collection_negated_Contains_as_All() { - await base.Inline_collection_negated_Contains_as_All(async); + await base.Inline_collection_negated_Contains_as_All(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Id` NOT IN (2, 999) """); } - public override async Task Parameter_collection_Count(bool async) + public override async Task Parameter_collection_Count() { - await base.Parameter_collection_Count(async); + await base.Parameter_collection_Count(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@ids1='2' +@ids2='999' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE ( SELECT COUNT(*) - FROM JSON_TABLE('[2,999]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` int PATH '$[0]' - )) AS `i` - WHERE `i`.`value` > `p`.`Id`) = 1 + FROM (SELECT @ids1 AS `Value` UNION ALL VALUES ROW(@ids2)) AS `i` + WHERE `i`.`Value` > `p`.`Id`) = 1 """); } - public override async Task Parameter_collection_of_nullable_ints_Contains_int(bool async) + public override async Task Parameter_collection_of_nullable_ints_Contains_int() { - await base.Parameter_collection_of_nullable_ints_Contains_int(async); + await base.Parameter_collection_of_nullable_ints_Contains_int(); if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -295,22 +296,28 @@ FROM JSON_TABLE('[10,999]', '$[*]' COLUMNS ( { AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@nullableInts1='10' +@nullableInts2='999' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Int` IN (10, 999) +WHERE `p`.`Int` IN (@nullableInts1, @nullableInts2) """, // """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@nullableInts1='10' +@nullableInts2='999' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Int` NOT IN (10, 999) +WHERE `p`.`Int` NOT IN (@nullableInts1, @nullableInts2) """); } } - public override async Task Parameter_collection_of_nullable_ints_Contains_nullable_int(bool async) + public override async Task Parameter_collection_of_nullable_ints_Contains_nullable_int() { - await base.Parameter_collection_of_nullable_ints_Contains_nullable_int(async); + await base.Parameter_collection_of_nullable_ints_Contains_nullable_int(); if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -331,22 +338,26 @@ FROM JSON_TABLE('[null,999]', '$[*]' COLUMNS ( { AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@nullableInts1='999' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`NullableInt` IS NULL OR (`p`.`NullableInt` = 999) +WHERE `p`.`NullableInt` IS NULL OR (`p`.`NullableInt` = @nullableInts1) """, // """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@nullableInts1='999' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`NullableInt` IS NOT NULL AND (`p`.`NullableInt` <> 999) +WHERE `p`.`NullableInt` IS NOT NULL AND (`p`.`NullableInt` <> @nullableInts1) """); } } - public override async Task Parameter_collection_of_strings_Contains_nullable_string(bool async) + public override async Task Parameter_collection_of_strings_Contains_nullable_string() { - await base.Parameter_collection_of_strings_Contains_nullable_string(async); + await base.Parameter_collection_of_strings_Contains_nullable_string(); if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -367,22 +378,28 @@ FROM JSON_TABLE('["999",null]', '$[*]' COLUMNS ( { AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@strings1='10' (Size = 4000) +@strings2='999' (Size = 4000) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`NullableString` IN ('10', '999') +WHERE `p`.`NullableString` IN (@strings1, @strings2) """, // """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@strings1='10' (Size = 4000) +@strings2='999' (Size = 4000) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`NullableString` NOT IN ('10', '999') OR (`p`.`NullableString` IS NULL) +WHERE `p`.`NullableString` NOT IN (@strings1, @strings2) OR (`p`.`NullableString` IS NULL) """); } } - public override async Task Parameter_collection_of_DateTimes_Contains(bool async) + public override async Task Parameter_collection_of_DateTimes_Contains() { - await base.Parameter_collection_of_DateTimes_Contains(async); + await base.Parameter_collection_of_DateTimes_Contains(); if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -403,16 +420,19 @@ FROM JSON_TABLE('["2020-01-10T12:30:00Z","9999-01-01T00:00:00Z"]', '$[*]' COLUMN { AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@dateTimes1='2020-01-10T12:30:00.0000000Z' (DbType = DateTime) +@dateTimes2='9999-01-01T00:00:00.0000000Z' (DbType = DateTime) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`DateTime` IN (TIMESTAMP '2020-01-10 12:30:00', TIMESTAMP '9999-01-01 00:00:00') +WHERE `p`.`DateTime` IN (@dateTimes1, @dateTimes2) """); } } - public override async Task Parameter_collection_of_bools_Contains(bool async) + public override async Task Parameter_collection_of_bools_Contains() { - await base.Parameter_collection_of_bools_Contains(async); + await base.Parameter_collection_of_bools_Contains(); if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -433,16 +453,18 @@ FROM JSON_TABLE('[true]', '$[*]' COLUMNS ( { AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@bools1='True' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Bool` +WHERE `p`.`Bool` = @bools1 """); } } - public override async Task Parameter_collection_of_enums_Contains(bool async) + public override async Task Parameter_collection_of_enums_Contains() { - await base.Parameter_collection_of_enums_Contains(async); + await base.Parameter_collection_of_enums_Contains(); if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -463,16 +485,19 @@ FROM JSON_TABLE('[0,3]', '$[*]' COLUMNS ( { AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@enums1='0' +@enums2='3' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Enum` IN (0, 3) +WHERE `p`.`Enum` IN (@enums1, @enums2) """); } } - public override async Task Parameter_collection_null_Contains(bool async) + public override async Task Parameter_collection_null_Contains() { - await base.Parameter_collection_null_Contains(async); + await base.Parameter_collection_null_Contains(); if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -493,7 +518,7 @@ FROM JSON_TABLE(NULL, '$[*]' COLUMNS ( { AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE FALSE """); @@ -501,9 +526,9 @@ WHERE FALSE } [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonTableImplementationWithoutMySqlBugs))] - public override async Task Column_collection_of_ints_Contains(bool async) + public override async Task Column_collection_of_ints_Contains() { - await base.Column_collection_of_ints_Contains(async); + await base.Column_collection_of_ints_Contains(); AssertSql( """ @@ -520,9 +545,9 @@ FROM JSON_TABLE(`p`.`Ints`, '$[*]' COLUMNS ( } [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonTableImplementationWithoutMySqlBugs))] - public override async Task Column_collection_of_nullable_ints_Contains(bool async) + public override async Task Column_collection_of_nullable_ints_Contains() { - await base.Column_collection_of_nullable_ints_Contains(async); + await base.Column_collection_of_nullable_ints_Contains(); AssertSql( """ @@ -539,9 +564,9 @@ FROM JSON_TABLE(`p`.`NullableInts`, '$[*]' COLUMNS ( } [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonTableImplementationWithoutMySqlBugs))] - public override async Task Column_collection_of_nullable_ints_Contains_null(bool async) + public override async Task Column_collection_of_nullable_ints_Contains_null() { - await base.Column_collection_of_nullable_ints_Contains_null(async); + await base.Column_collection_of_nullable_ints_Contains_null(); AssertSql( """ @@ -551,9 +576,9 @@ WHERE array_position(p."NullableInts", NULL) IS NOT NULL """); } - public override async Task Column_collection_of_strings_contains_null(bool async) + public override async Task Column_collection_of_strings_contains_null() { - await base.Column_collection_of_strings_contains_null(async); + await base.Column_collection_of_strings_contains_null(); AssertSql( """ @@ -564,9 +589,9 @@ WHERE FALSE } [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonTableImplementationWithoutMySqlBugs))] - public override async Task Column_collection_of_nullable_strings_contains_null(bool async) + public override async Task Column_collection_of_nullable_strings_contains_null() { - await base.Column_collection_of_nullable_strings_contains_null(async); + await base.Column_collection_of_nullable_strings_contains_null(); AssertSql( """ @@ -577,9 +602,9 @@ WHERE array_position(p."NullableStrings", NULL) IS NOT NULL } [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonTableImplementationWithoutMySqlBugs))] - public override async Task Column_collection_of_bools_Contains(bool async) + public override async Task Column_collection_of_bools_Contains() { - await base.Column_collection_of_bools_Contains(async); + await base.Column_collection_of_bools_Contains(); AssertSql( """ @@ -595,9 +620,9 @@ FROM JSON_TABLE(`p`.`Bools`, '$[*]' COLUMNS ( """); } - public override async Task Column_collection_Count_method(bool async) + public override async Task Column_collection_Count_method() { - await base.Column_collection_Count_method(async); + await base.Column_collection_Count_method(); AssertSql( """ @@ -612,9 +637,9 @@ FROM JSON_TABLE(`p`.`Ints`, '$[*]' COLUMNS ( """); } - public override async Task Column_collection_Length(bool async) + public override async Task Column_collection_Length() { - await base.Column_collection_Length(async); + await base.Column_collection_Length(); AssertSql( """ @@ -629,9 +654,9 @@ FROM JSON_TABLE(`p`.`Ints`, '$[*]' COLUMNS ( """); } - public override async Task Column_collection_index_int(bool async) + public override async Task Column_collection_index_int() { - await base.Column_collection_index_int(async); + await base.Column_collection_index_int(); if (AppConfig.ServerVersion.Supports.JsonValue) { @@ -653,9 +678,9 @@ WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(`p`.`Ints`, '$[1]')) AS signed) = 10 } } - public override async Task Column_collection_index_string(bool async) + public override async Task Column_collection_index_string() { - await base.Column_collection_index_string(async); + await base.Column_collection_index_string(); if (AppConfig.ServerVersion.Supports.JsonValue) { @@ -677,9 +702,9 @@ WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(`p`.`Strings`, '$[1]')) AS char) = '10' } } - public override async Task Column_collection_index_datetime(bool async) + public override async Task Column_collection_index_datetime() { - await base.Column_collection_index_datetime(async); + await base.Column_collection_index_datetime(); if (AppConfig.ServerVersion.Supports.JsonValue) { @@ -701,9 +726,9 @@ WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(`p`.`DateTimes`, '$[1]')) AS datetime(6)) = } } - public override async Task Column_collection_index_beyond_end(bool async) + public override async Task Column_collection_index_beyond_end() { - await base.Column_collection_index_beyond_end(async); + await base.Column_collection_index_beyond_end(); if (AppConfig.ServerVersion.Supports.JsonValue) { @@ -726,9 +751,9 @@ WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(`p`.`Ints`, '$[999]')) AS signed) = 10 } [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonValue), Skip = "TODO: Fix NULL handling of JSON_EXTRACT().")] - public override async Task Nullable_reference_column_collection_index_equals_nullable_column(bool async) + public override async Task Nullable_reference_column_collection_index_equals_nullable_column() { - await base.Nullable_reference_column_collection_index_equals_nullable_column(async); + await base.Nullable_reference_column_collection_index_equals_nullable_column(); AssertSql( """ @@ -738,9 +763,9 @@ public override async Task Nullable_reference_column_collection_index_equals_nul """); } - public override async Task Non_nullable_reference_column_collection_index_equals_nullable_column(bool async) + public override async Task Non_nullable_reference_column_collection_index_equals_nullable_column() { - await base.Non_nullable_reference_column_collection_index_equals_nullable_column(async); + await base.Non_nullable_reference_column_collection_index_equals_nullable_column(); if (AppConfig.ServerVersion.Supports.JsonValue) { @@ -763,9 +788,9 @@ public override async Task Non_nullable_reference_column_collection_index_equals } [SupportedServerVersionCondition(nameof(ServerVersionSupport.WhereSubqueryReferencesOuterQuery))] - public override async Task Inline_collection_index_Column(bool async) + public override async Task Inline_collection_index_Column() { - await base.Inline_collection_index_Column(async); + await base.Inline_collection_index_Column(); AssertSql( """ @@ -779,37 +804,37 @@ ORDER BY v._ord NULLS FIRST """); } - public override async Task Parameter_collection_index_Column_equal_Column(bool async) + public override async Task Parameter_collection_index_Column_equal_Column() { - await base.Parameter_collection_index_Column_equal_Column(async); + await base.Parameter_collection_index_Column_equal_Column(); AssertSql( """ -@__ints_0='[0,2,3]' (Size = 4000) +@ints='[0,2,3]' (Size = 4000) SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(@__ints_0, CONCAT('$[', CAST(`p`.`Int` AS char), ']'))) AS signed) = `p`.`Int` +WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(@ints, CONCAT('$[', CAST(`p`.`Int` AS char), ']'))) AS signed) = `p`.`Int` """); } - public override async Task Parameter_collection_index_Column_equal_constant(bool async) + public override async Task Parameter_collection_index_Column_equal_constant() { - await base.Parameter_collection_index_Column_equal_constant(async); + await base.Parameter_collection_index_Column_equal_constant(); AssertSql( """ -@__ints_0='[1,2,3]' (Size = 4000) +@ints='[1,2,3]' (Size = 4000) SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(@__ints_0, CONCAT('$[', CAST(`p`.`Int` AS char), ']'))) AS signed) = 1 +WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(@ints, CONCAT('$[', CAST(`p`.`Int` AS char), ']'))) AS signed) = 1 """); } - public override async Task Column_collection_ElementAt(bool async) + public override async Task Column_collection_ElementAt() { - await base.Column_collection_ElementAt(async); + await base.Column_collection_ElementAt(); if (AppConfig.ServerVersion.Supports.JsonValue) { @@ -831,9 +856,9 @@ WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(`p`.`Ints`, '$[1]')) AS signed) = 10 } } - public override async Task Column_collection_Skip(bool async) + public override async Task Column_collection_Skip() { - await base.Column_collection_Skip(async); + await base.Column_collection_Skip(); AssertSql( """ @@ -854,9 +879,9 @@ LIMIT 18446744073709551610 OFFSET 1 } [SupportedServerVersionCondition(nameof(ServerVersionSupport.LimitWithinInAllAnySomeSubquery))] - public override async Task Column_collection_Take(bool async) + public override async Task Column_collection_Take() { - await base.Column_collection_Take(async); + await base.Column_collection_Take(); AssertSql( """ @@ -867,9 +892,9 @@ public override async Task Column_collection_Take(bool async) } [SupportedServerVersionCondition(nameof(ServerVersionSupport.LimitWithinInAllAnySomeSubquery))] - public override async Task Column_collection_Skip_Take(bool async) + public override async Task Column_collection_Skip_Take() { - await base.Column_collection_Skip_Take(async); + await base.Column_collection_Skip_Take(); AssertSql( """ @@ -879,9 +904,9 @@ public override async Task Column_collection_Skip_Take(bool async) """); } - public override async Task Column_collection_OrderByDescending_ElementAt(bool async) + public override async Task Column_collection_OrderByDescending_ElementAt() { - await base.Column_collection_OrderByDescending_ElementAt(async); + await base.Column_collection_OrderByDescending_ElementAt(); AssertSql( """ @@ -898,9 +923,9 @@ ORDER BY `i`.`value` DESC """); } - public override async Task Column_collection_Any(bool async) + public override async Task Column_collection_Any() { - await base.Column_collection_Any(async); + await base.Column_collection_Any(); AssertSql( """ @@ -910,9 +935,9 @@ WHERE JSON_LENGTH(`p`.`Ints`) > 0 """); } - public override async Task Column_collection_Distinct(bool async) + public override async Task Column_collection_Distinct() { - await base.Column_collection_Distinct(async); + await base.Column_collection_Distinct(); AssertSql( """ @@ -930,9 +955,9 @@ FROM JSON_TABLE(`p`.`Ints`, '$[*]' COLUMNS ( """); } - public override async Task Column_collection_projection_from_top_level(bool async) + public override async Task Column_collection_projection_from_top_level() { - await base.Column_collection_projection_from_top_level(async); + await base.Column_collection_projection_from_top_level(); AssertSql( """ @@ -942,9 +967,9 @@ ORDER BY `p`.`Id` """); } - public override async Task Column_collection_Join_parameter_collection(bool async) + public override async Task Column_collection_Join_parameter_collection() { - await base.Column_collection_Join_parameter_collection(async); + await base.Column_collection_Join_parameter_collection(); AssertSql( """ @@ -963,9 +988,9 @@ INNER JOIN JSON_TABLE('[11,111]', '$[*]' COLUMNS ( """); } - public override async Task Inline_collection_Join_ordered_column_collection(bool async) + public override async Task Inline_collection_Join_ordered_column_collection() { - await base.Inline_collection_Join_ordered_column_collection(async); + await base.Inline_collection_Join_ordered_column_collection(); AssertSql( """ @@ -981,9 +1006,9 @@ INNER JOIN JSON_TABLE(`p`.`Ints`, '$[*]' COLUMNS ( """); } - public override async Task Parameter_collection_Concat_column_collection(bool async) + public override async Task Parameter_collection_Concat_column_collection() { - await base.Parameter_collection_Concat_column_collection(async); + await base.Parameter_collection_Concat_column_collection(); AssertSql( """ @@ -1007,9 +1032,9 @@ FROM JSON_TABLE(`p`.`Ints`, '$[*]' COLUMNS ( """); } - public override async Task Column_collection_Union_parameter_collection(bool async) + public override async Task Column_collection_Union_parameter_collection() { - await base.Column_collection_Union_parameter_collection(async); + await base.Column_collection_Union_parameter_collection(); AssertSql( """ @@ -1033,9 +1058,9 @@ FROM JSON_TABLE('[11,111]', '$[*]' COLUMNS ( """); } - public override async Task Column_collection_Intersect_inline_collection(bool async) + public override async Task Column_collection_Intersect_inline_collection() { - await base.Column_collection_Intersect_inline_collection(async); + await base.Column_collection_Intersect_inline_collection(); AssertSql( """ @@ -1052,9 +1077,9 @@ FROM unnest(p."Ints") AS i(value) """); } - public override async Task Inline_collection_Except_column_collection(bool async) + public override async Task Inline_collection_Except_column_collection() { - await base.Inline_collection_Except_column_collection(async); + await base.Inline_collection_Except_column_collection(); AssertSql( """ @@ -1073,42 +1098,43 @@ FROM unnest(p."Ints") AS i(value) """); } - public override async Task Column_collection_equality_parameter_collection(bool async) + public override async Task Column_collection_equality_parameter_collection() { - await base.Column_collection_equality_parameter_collection(async); + await base.Column_collection_equality_parameter_collection(); AssertSql( """ -@__ints_0='[1,10]' (Size = 4000) +@ints='[1,10]' (Size = 4000) -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Ints` = @__ints_0 +WHERE `p`.`Ints` = @ints """); } - public override async Task Column_collection_equality_inline_collection(bool async) + public override async Task Column_collection_equality_inline_collection() { - await base.Column_collection_equality_inline_collection(async); + await base.Column_collection_equality_inline_collection(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Ints` = '[1,10]' """); } - public override async Task Column_collection_equality_inline_collection_with_parameters(bool async) + public override async Task Column_collection_equality_inline_collection_with_parameters() { - await base.Column_collection_equality_inline_collection_with_parameters(async); + await base.Column_collection_equality_inline_collection_with_parameters(); - AssertSql(); + AssertSql( +); } - public override async Task Parameter_collection_in_subquery_Union_column_collection_as_compiled_query(bool async) + public override async Task Parameter_collection_in_subquery_Union_column_collection_as_compiled_query() { - await base.Parameter_collection_in_subquery_Union_column_collection_as_compiled_query(async); + await base.Parameter_collection_in_subquery_Union_column_collection_as_compiled_query(); AssertSql( """ @@ -1137,9 +1163,9 @@ FROM JSON_TABLE(`p`.`Ints`, '$[*]' COLUMNS ( """); } - public override async Task Parameter_collection_in_subquery_Union_column_collection(bool async) + public override async Task Parameter_collection_in_subquery_Union_column_collection() { - await base.Parameter_collection_in_subquery_Union_column_collection(async); + await base.Parameter_collection_in_subquery_Union_column_collection(); AssertSql( """ @@ -1163,9 +1189,9 @@ FROM JSON_TABLE(`p`.`Ints`, '$[*]' COLUMNS ( """); } - public override async Task Parameter_collection_in_subquery_Union_column_collection_nested(bool async) + public override async Task Parameter_collection_in_subquery_Union_column_collection_nested() { - await base.Parameter_collection_in_subquery_Union_column_collection_nested(async); + await base.Parameter_collection_in_subquery_Union_column_collection_nested(); AssertSql( """ @@ -1206,7 +1232,7 @@ public override void Parameter_collection_in_subquery_and_Convert_as_compiled_qu { // base.Parameter_collection_in_subquery_and_Convert_as_compiled_query(); // - // AssertSql(); + // AssertSql(""); // The array indexing is translated as a subquery over e.g. OPENJSON with LIMIT/OFFSET. // Since there's a CAST over that, the type mapping inference from the other side (p.String) doesn't propagate inside to the @@ -1230,10 +1256,10 @@ public override void Parameter_collection_in_subquery_and_Convert_as_compiled_qu } } - public override async Task Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(bool async) + public override async Task Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query() { var message = (await Assert.ThrowsAsync( - () => base.Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query(async))).Message; + () => base.Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query())).Message; if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -1241,32 +1267,32 @@ public override async Task Parameter_collection_in_subquery_Union_another_parame } } - public override async Task Parameter_collection_in_subquery_Count_as_compiled_query(bool async) + public override async Task Parameter_collection_in_subquery_Count_as_compiled_query() { - await base.Parameter_collection_in_subquery_Count_as_compiled_query(async); + await base.Parameter_collection_in_subquery_Count_as_compiled_query(); AssertSql( """ +@ints1='10' +@ints2='111' + SELECT COUNT(*) FROM `PrimitiveCollectionsEntity` AS `p` WHERE ( SELECT COUNT(*) FROM ( - SELECT `i`.`value`, `i`.`key`, `i`.`value` AS `value0` - FROM JSON_TABLE('[10,111]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` int PATH '$[0]' - )) AS `i` - ORDER BY `i`.`key` + SELECT `i`.`Value` AS `Value0` + FROM (SELECT 0 AS `_ord`, @ints1 AS `Value` UNION ALL VALUES ROW(1, @ints2)) AS `i` + ORDER BY `i`.`_ord` LIMIT 18446744073709551610 OFFSET 1 - ) AS `t` - WHERE `t`.`value0` > `p`.`Id`) = 1 + ) AS `i0` + WHERE `i0`.`Value0` > `p`.`Id`) = 1 """); } - public override async Task Column_collection_in_subquery_Union_parameter_collection(bool async) + public override async Task Column_collection_in_subquery_Union_parameter_collection() { - await base.Column_collection_in_subquery_Union_parameter_collection(async); + await base.Column_collection_in_subquery_Union_parameter_collection(); AssertSql( """ @@ -1295,9 +1321,9 @@ FROM JSON_TABLE('[10,111]', '$[*]' COLUMNS ( """); } - public override async Task Project_collection_of_ints_simple(bool async) + public override async Task Project_collection_of_ints_simple() { - await base.Project_collection_of_ints_simple(async); + await base.Project_collection_of_ints_simple(); AssertSql( """ @@ -1308,9 +1334,9 @@ ORDER BY `p`.`Id` } [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonTableImplementationStable))] - public override async Task Project_collection_of_ints_ordered(bool async) + public override async Task Project_collection_of_ints_ordered() { - await base.Project_collection_of_ints_ordered(async); + await base.Project_collection_of_ints_ordered(); AssertSql( """ @@ -1326,11 +1352,11 @@ LEFT JOIN JSON_TABLE(`p`.`Ints`, '$[*]' COLUMNS ( [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonTable))] [SupportedServerVersionCondition(nameof(ServerVersionSupport.OuterApply))] - public override async Task Project_collection_of_datetimes_filtered(bool async) + public override async Task Project_collection_of_datetimes_filtered() { if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { - await base.Project_collection_of_datetimes_filtered(async); + await base.Project_collection_of_datetimes_filtered(); AssertSql( """ @@ -1350,13 +1376,13 @@ FROM JSON_TABLE(`p`.`DateTimes`, '$[*]' COLUMNS ( else { await Assert.ThrowsAsync(() - => base.Project_collection_of_datetimes_filtered(async)); + => base.Project_collection_of_datetimes_filtered()); } } - public override async Task Project_collection_of_nullable_ints_with_paging(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging() { - await base.Project_collection_of_nullable_ints_with_paging(async); + await base.Project_collection_of_nullable_ints_with_paging(); if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -1389,11 +1415,11 @@ ORDER BY `p`.`Id` [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonTable))] [SupportedServerVersionCondition(nameof(ServerVersionSupport.OuterApply))] - public override async Task Project_collection_of_nullable_ints_with_paging2(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging2() { if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { - await base.Project_collection_of_nullable_ints_with_paging2(async); + await base.Project_collection_of_nullable_ints_with_paging2(); AssertSql( """ @@ -1414,13 +1440,13 @@ LIMIT 18446744073709551610 OFFSET 1 else { await Assert.ThrowsAsync(() - => base.Project_collection_of_nullable_ints_with_paging2(async)); + => base.Project_collection_of_nullable_ints_with_paging2()); } } - public override async Task Project_collection_of_nullable_ints_with_paging3(bool async) + public override async Task Project_collection_of_nullable_ints_with_paging3() { - await base.Project_collection_of_nullable_ints_with_paging3(async); + await base.Project_collection_of_nullable_ints_with_paging3(); if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -1451,9 +1477,9 @@ ORDER BY `p`.`Id` } } - public override async Task Project_collection_of_ints_with_distinct(bool async) + public override async Task Project_collection_of_ints_with_distinct() { - await base.Project_collection_of_ints_with_distinct(async); + await base.Project_collection_of_ints_with_distinct(); if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { @@ -1482,20 +1508,20 @@ ORDER BY `p`.`Id` } } - public override async Task Project_collection_of_nullable_ints_with_distinct(bool async) + public override async Task Project_collection_of_nullable_ints_with_distinct() { - await base.Project_collection_of_nullable_ints_with_distinct(async); + await base.Project_collection_of_nullable_ints_with_distinct(); - AssertSql(); + AssertSql(""); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonTable))] [SupportedServerVersionCondition(nameof(ServerVersionSupport.OuterApply))] - public override async Task Project_empty_collection_of_nullables_and_collection_only_containing_nulls(bool async) + public override async Task Project_empty_collection_of_nullables_and_collection_only_containing_nulls() { if (MySqlTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { - await base.Project_empty_collection_of_nullables_and_collection_only_containing_nulls(async); + await base.Project_empty_collection_of_nullables_and_collection_only_containing_nulls(); AssertSql( """ @@ -1523,16 +1549,15 @@ FROM JSON_TABLE(`p`.`NullableInts`, '$[*]' COLUMNS ( else { await Assert.ThrowsAsync(() - => base.Project_empty_collection_of_nullables_and_collection_only_containing_nulls(async)); + => base.Project_empty_collection_of_nullables_and_collection_only_containing_nulls()); } } [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonTableImplementationStable))] - public override async Task Project_multiple_collections(bool async) + public override async Task Project_multiple_collections() { // Base implementation currently uses an Unspecified DateTime in the query, but we require a Utc one. await AssertQuery( - async, ss => ss.Set().OrderBy(x => x.Id).Select(x => new { Ints = x.Ints.ToList(), @@ -1581,9 +1606,9 @@ FROM JSON_TABLE(`p`.`DateTimes`, '$[*]' COLUMNS ( """); } - public override async Task Project_primitive_collections_element(bool async) + public override async Task Project_primitive_collections_element() { - await base.Project_primitive_collections_element(async); + await base.Project_primitive_collections_element(); if (AppConfig.ServerVersion.Supports.JsonValue) { @@ -1607,101 +1632,116 @@ ORDER BY `p`.`Id` } } - public override async Task Inline_collection_Contains_as_Any_with_predicate(bool async) + public override async Task Inline_collection_Contains_as_Any_with_predicate() { - await base.Inline_collection_Contains_as_Any_with_predicate(async); + await base.Inline_collection_Contains_as_Any_with_predicate(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Id` IN (2, 999) """); } - public override async Task Column_collection_Concat_parameter_collection_equality_inline_collection(bool async) + public override async Task Column_collection_Concat_parameter_collection_equality_inline_collection() { - await base.Column_collection_Concat_parameter_collection_equality_inline_collection(async); + await base.Column_collection_Concat_parameter_collection_equality_inline_collection(); - AssertSql(); + AssertSql( +); } - public override async Task Nested_contains_with_Lists_and_no_inferred_type_mapping(bool async) + public override async Task Nested_contains_with_Lists_and_no_inferred_type_mapping() { - await base.Nested_contains_with_Lists_and_no_inferred_type_mapping(async); + await base.Nested_contains_with_Lists_and_no_inferred_type_mapping(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@ints1='1' +@ints2='2' +@ints3='3' +@strings1='one' (Size = 4000) +@strings2='two' (Size = 4000) +@strings3='three' (Size = 4000) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE CASE - WHEN `p`.`Int` IN (1, 2, 3) THEN 'one' + WHEN `p`.`Int` IN (@ints1, @ints2, @ints3) THEN 'one' ELSE 'two' -END IN ('one', 'two', 'three') +END IN (@strings1, @strings2, @strings3) """); } - public override async Task Nested_contains_with_arrays_and_no_inferred_type_mapping(bool async) + public override async Task Nested_contains_with_arrays_and_no_inferred_type_mapping() { - await base.Nested_contains_with_arrays_and_no_inferred_type_mapping(async); + await base.Nested_contains_with_arrays_and_no_inferred_type_mapping(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@ints1='1' +@ints2='2' +@ints3='3' +@strings1='one' (Size = 4000) +@strings2='two' (Size = 4000) +@strings3='three' (Size = 4000) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE CASE - WHEN `p`.`Int` IN (1, 2, 3) THEN 'one' + WHEN `p`.`Int` IN (@ints1, @ints2, @ints3) THEN 'one' ELSE 'two' -END IN ('one', 'two', 'three') +END IN (@strings1, @strings2, @strings3) """); } - public override async Task Inline_collection_with_single_parameter_element_Contains(bool async) + public override async Task Inline_collection_with_single_parameter_element_Contains() { - await base.Inline_collection_with_single_parameter_element_Contains(async); + await base.Inline_collection_with_single_parameter_element_Contains(); AssertSql( """ -@__i_0='2' +@i='2' -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Id` = @__i_0 +WHERE `p`.`Id` = @i """); } - public override async Task Inline_collection_with_single_parameter_element_Count(bool async) + public override async Task Inline_collection_with_single_parameter_element_Count() { - await base.Inline_collection_with_single_parameter_element_Count(async); + await base.Inline_collection_with_single_parameter_element_Count(); AssertSql( """ -@__i_0='2' +@i='2' -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE ( SELECT COUNT(*) - FROM (SELECT CAST(@__i_0 AS signed) AS `Value`) AS `v` + FROM (SELECT CAST(@i AS signed) AS `Value`) AS `v` WHERE `v`.`Value` > `p`.`Id`) = 1 """); } - public override async Task Parameter_collection_Contains_with_EF_Constant(bool async) + public override async Task Parameter_collection_Contains_with_EF_Constant() { - await base.Parameter_collection_Contains_with_EF_Constant(async); + await base.Parameter_collection_Contains_with_EF_Constant(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Id` IN (2, 999, 1000) """); } - public override async Task Parameter_collection_Where_with_EF_Constant_Where_Any(bool async) + public override async Task Parameter_collection_Where_with_EF_Constant_Where_Any() { - await base.Parameter_collection_Where_with_EF_Constant_Where_Any(async); + await base.Parameter_collection_Where_with_EF_Constant_Where_Any(); var rowSql = AppConfig.ServerVersion.Supports.ValuesWithRows ? "ROW" : string.Empty; @@ -1716,9 +1756,9 @@ SELECT 1 """); } - public override async Task Parameter_collection_Count_with_column_predicate_with_EF_Constant(bool async) + public override async Task Parameter_collection_Count_with_column_predicate_with_EF_Constant() { - await base.Parameter_collection_Count_with_column_predicate_with_EF_Constant(async); + await base.Parameter_collection_Count_with_column_predicate_with_EF_Constant(); var rowSql = AppConfig.ServerVersion.Supports.ValuesWithRows ? "ROW" : string.Empty; @@ -1733,158 +1773,184 @@ SELECT COUNT(*) """); } - public override async Task Inline_collection_Min_with_two_values(bool async) + public override async Task Inline_collection_Min_with_two_values() { - await base.Inline_collection_Min_with_two_values(async); + await base.Inline_collection_Min_with_two_values(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE LEAST(30, `p`.`Int`) = 30 """); } - public override async Task Inline_collection_Max_with_two_values(bool async) + public override async Task Inline_collection_Max_with_two_values() { - await base.Inline_collection_Max_with_two_values(async); + await base.Inline_collection_Max_with_two_values(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE GREATEST(30, `p`.`Int`) = 30 """); } - public override async Task Inline_collection_Min_with_three_values(bool async) + public override async Task Inline_collection_Min_with_three_values() { - await base.Inline_collection_Min_with_three_values(async); + await base.Inline_collection_Min_with_three_values(); AssertSql( """ -@__i_0='25' +@i='25' -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE LEAST(30, `p`.`Int`, @__i_0) = 25 +WHERE LEAST(30, `p`.`Int`, @i) = 25 """); } - public override async Task Inline_collection_Max_with_three_values(bool async) + public override async Task Inline_collection_Max_with_three_values() { - await base.Inline_collection_Max_with_three_values(async); + await base.Inline_collection_Max_with_three_values(); AssertSql( """ -@__i_0='35' +@i='35' -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE GREATEST(30, `p`.`Int`, @__i_0) = 35 +WHERE GREATEST(30, `p`.`Int`, @i) = 35 """); } - public override async Task Parameter_collection_of_ints_Contains_int(bool async) + public override async Task Parameter_collection_of_ints_Contains_int() { - await base.Parameter_collection_of_ints_Contains_int(async); + await base.Parameter_collection_of_ints_Contains_int(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@ints1='10' +@ints2='999' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Int` IN (10, 999) +WHERE `p`.`Int` IN (@ints1, @ints2) """, // """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@ints1='10' +@ints2='999' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Int` NOT IN (10, 999) +WHERE `p`.`Int` NOT IN (@ints1, @ints2) """); } - public override async Task Parameter_collection_of_ints_Contains_nullable_int(bool async) + public override async Task Parameter_collection_of_ints_Contains_nullable_int() { - await base.Parameter_collection_of_ints_Contains_nullable_int(async); + await base.Parameter_collection_of_ints_Contains_nullable_int(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@ints1='10' +@ints2='999' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`NullableInt` IN (10, 999) +WHERE `p`.`NullableInt` IN (@ints1, @ints2) """, // """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@ints1='10' +@ints2='999' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`NullableInt` NOT IN (10, 999) OR (`p`.`NullableInt` IS NULL) +WHERE `p`.`NullableInt` NOT IN (@ints1, @ints2) OR (`p`.`NullableInt` IS NULL) """); } - public override async Task Parameter_collection_of_strings_Contains_string(bool async) + public override async Task Parameter_collection_of_strings_Contains_string() { - await base.Parameter_collection_of_strings_Contains_string(async); + await base.Parameter_collection_of_strings_Contains_string(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@strings1='10' (Size = 4000) +@strings2='999' (Size = 4000) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`String` IN ('10', '999') +WHERE `p`.`String` IN (@strings1, @strings2) """, // """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@strings1='10' (Size = 4000) +@strings2='999' (Size = 4000) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`String` NOT IN ('10', '999') +WHERE `p`.`String` NOT IN (@strings1, @strings2) """); } - public override async Task Parameter_collection_of_nullable_strings_Contains_string(bool async) + public override async Task Parameter_collection_of_nullable_strings_Contains_string() { - await base.Parameter_collection_of_nullable_strings_Contains_string(async); + await base.Parameter_collection_of_nullable_strings_Contains_string(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@strings1='10' (Size = 4000) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`String` = '10' +WHERE `p`.`String` = @strings1 """, // """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@strings1='10' (Size = 4000) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`String` <> '10' +WHERE `p`.`String` <> @strings1 """); } - public override async Task Parameter_collection_of_nullable_strings_Contains_nullable_string(bool async) + public override async Task Parameter_collection_of_nullable_strings_Contains_nullable_string() { - await base.Parameter_collection_of_nullable_strings_Contains_nullable_string(async); + await base.Parameter_collection_of_nullable_strings_Contains_nullable_string(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@strings1='999' (Size = 4000) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`NullableString` IS NULL OR (`p`.`NullableString` = '999') +WHERE `p`.`NullableString` IS NULL OR (`p`.`NullableString` = @strings1) """, // """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +@strings1='999' (Size = 4000) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`NullableString` IS NOT NULL AND (`p`.`NullableString` <> '999') +WHERE `p`.`NullableString` IS NOT NULL AND (`p`.`NullableString` <> @strings1) """); } - public override async Task Column_collection_SelectMany(bool async) + public override async Task Column_collection_SelectMany() { - await base.Column_collection_SelectMany(async); + await base.Column_collection_SelectMany(); AssertSql(""); } - public override async Task Project_collection_of_ints_with_ToList_and_FirstOrDefault(bool async) + public override async Task Project_collection_of_ints_with_ToList_and_FirstOrDefault() { - await base.Project_collection_of_ints_with_ToList_and_FirstOrDefault(async); + await base.Project_collection_of_ints_with_ToList_and_FirstOrDefault(); AssertSql( """ @@ -1895,145 +1961,147 @@ LIMIT 1 """); } - public override async Task Project_inline_collection_with_Concat(bool async) + public override async Task Project_inline_collection_with_Concat() { - await base.Project_inline_collection_with_Concat(async); + await base.Project_inline_collection_with_Concat(); - AssertSql(); + AssertSql( +); } - public override async Task Column_collection_Where_equality_inline_collection(bool async) + public override async Task Column_collection_Where_equality_inline_collection() { - await base.Column_collection_Where_equality_inline_collection(async); + await base.Column_collection_Where_equality_inline_collection(); - AssertSql(); + AssertSql( +); } - public override async Task Inline_collection_List_Contains_with_mixed_value_types(bool async) + public override async Task Inline_collection_List_Contains_with_mixed_value_types() { - await base.Inline_collection_List_Contains_with_mixed_value_types(async); + await base.Inline_collection_List_Contains_with_mixed_value_types(); AssertSql( """ -@__i_0='11' +@i='11' -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Int` IN (999, @__i_0, `p`.`Id`, `p`.`Id` + `p`.`Int`) +WHERE `p`.`Int` IN (999, @i, `p`.`Id`, `p`.`Id` + `p`.`Int`) """); } - public override async Task Inline_collection_List_Min_with_two_values(bool async) + public override async Task Inline_collection_List_Min_with_two_values() { - await base.Inline_collection_List_Min_with_two_values(async); + await base.Inline_collection_List_Min_with_two_values(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE LEAST(30, `p`.`Int`) = 30 """); } - public override async Task Inline_collection_List_Max_with_two_values(bool async) + public override async Task Inline_collection_List_Max_with_two_values() { - await base.Inline_collection_List_Max_with_two_values(async); + await base.Inline_collection_List_Max_with_two_values(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE GREATEST(30, `p`.`Int`) = 30 """); } - public override async Task Inline_collection_List_Min_with_three_values(bool async) + public override async Task Inline_collection_List_Min_with_three_values() { - await base.Inline_collection_List_Min_with_three_values(async); + await base.Inline_collection_List_Min_with_three_values(); AssertSql( """ -@__i_0='25' +@i='25' -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE LEAST(30, `p`.`Int`, @__i_0) = 25 +WHERE LEAST(30, `p`.`Int`, @i) = 25 """); } - public override async Task Inline_collection_List_Max_with_three_values(bool async) + public override async Task Inline_collection_List_Max_with_three_values() { - await base.Inline_collection_List_Max_with_three_values(async); + await base.Inline_collection_List_Max_with_three_values(); AssertSql( """ -@__i_0='35' +@i='35' -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` -WHERE GREATEST(30, `p`.`Int`, @__i_0) = 35 +WHERE GREATEST(30, `p`.`Int`, @i) = 35 """); } - public override async Task Inline_collection_of_nullable_value_type_Min(bool async) + public override async Task Inline_collection_of_nullable_value_type_Min() { if (AppConfig.ServerVersion.Supports.FieldReferenceInTableValueConstructor) { - await base.Inline_collection_of_nullable_value_type_Min(async); + await base.Inline_collection_of_nullable_value_type_Min(); AssertSql( """ -@__i_0='25' (Nullable = true) +@i='25' (Nullable = true) -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE ( SELECT MIN(`v`.`Value`) - FROM (SELECT CAST(30 AS signed) AS `Value` UNION ALL VALUES ROW(`p`.`Int`), ROW(@__i_0)) AS `v`) = 25 + FROM (SELECT CAST(30 AS signed) AS `Value` UNION ALL VALUES ROW(`p`.`Int`), ROW(@i)) AS `v`) = 25 """); } else { - var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_Min(async)); + var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_Min()); Assert.True(exception.Message is "Field reference 'p.Int' can't be used in table value constructor" or "Unknown table 'p' in order clause"); } } - public override async Task Inline_collection_of_nullable_value_type_Max(bool async) + public override async Task Inline_collection_of_nullable_value_type_Max() { if (AppConfig.ServerVersion.Supports.FieldReferenceInTableValueConstructor) { - await base.Inline_collection_of_nullable_value_type_Max(async); + await base.Inline_collection_of_nullable_value_type_Max(); AssertSql( """ -@__i_0='35' (Nullable = true) +@i='35' (Nullable = true) -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE ( SELECT MAX(`v`.`Value`) - FROM (SELECT CAST(30 AS signed) AS `Value` UNION ALL VALUES ROW(`p`.`Int`), ROW(@__i_0)) AS `v`) = 35 + FROM (SELECT CAST(30 AS signed) AS `Value` UNION ALL VALUES ROW(`p`.`Int`), ROW(@i)) AS `v`) = 35 """); } else { - var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_Max(async)); + var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_Max()); Assert.True(exception.Message is "Field reference 'p.Int' can't be used in table value constructor" or "Unknown table 'p' in order clause"); } } - public override async Task Inline_collection_of_nullable_value_type_with_null_Min(bool async) + public override async Task Inline_collection_of_nullable_value_type_with_null_Min() { if (AppConfig.ServerVersion.Supports.FieldReferenceInTableValueConstructor) { - await base.Inline_collection_of_nullable_value_type_with_null_Min(async); + await base.Inline_collection_of_nullable_value_type_with_null_Min(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE ( SELECT MIN(`v`.`Value`) @@ -2042,21 +2110,21 @@ SELECT MIN(`v`.`Value`) } else { - var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_with_null_Min(async)); + var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_with_null_Min()); Assert.True(exception.Message is "Field reference 'p.NullableInt' can't be used in table value constructor" or "Unknown table 'p' in order clause"); } } - public override async Task Inline_collection_of_nullable_value_type_with_null_Max(bool async) + public override async Task Inline_collection_of_nullable_value_type_with_null_Max() { if (AppConfig.ServerVersion.Supports.FieldReferenceInTableValueConstructor) { - await base.Inline_collection_of_nullable_value_type_with_null_Max(async); + await base.Inline_collection_of_nullable_value_type_with_null_Max(); AssertSql( """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` FROM `PrimitiveCollectionsEntity` AS `p` WHERE ( SELECT MAX(`v`.`Value`) @@ -2065,157 +2133,174 @@ SELECT MAX(`v`.`Value`) } else { - var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_with_null_Max(async)); + var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_with_null_Max()); Assert.True(exception.Message is "Field reference 'p.NullableInt' can't be used in table value constructor" or "Unknown table 'p' in order clause"); } } - public override async Task Inline_collection_Contains_with_EF_Parameter(bool async) + public override async Task Inline_collection_Contains_with_EF_Parameter() { - await base.Inline_collection_Contains_with_EF_Parameter(async); + await base.Inline_collection_Contains_with_EF_Parameter(); - AssertSql(); + AssertSql(""); } - public override async Task Inline_collection_Count_with_column_predicate_with_EF_Parameter(bool async) + public override async Task Inline_collection_Count_with_column_predicate_with_EF_Parameter() { - await base.Inline_collection_Count_with_column_predicate_with_EF_Parameter(async); + await base.Inline_collection_Count_with_column_predicate_with_EF_Parameter(); - AssertSql(); + AssertSql(""); } - public override async Task Parameter_collection_HashSet_of_ints_Contains_int(bool async) + public override async Task Parameter_collection_HashSet_of_ints_Contains_int() { - await base.Parameter_collection_HashSet_of_ints_Contains_int(async); + await base.Parameter_collection_HashSet_of_ints_Contains_int(); + + AssertSql( +""" +@ints1='10' +@ints2='999' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE `p`.`Int` IN (@ints1, @ints2) +""", + // + """ +@ints1='10' +@ints2='999' - AssertSql(); +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`NullableWrappedId`, `p`.`NullableWrappedIdWithNullableComparer`, `p`.`String`, `p`.`Strings`, `p`.`WrappedId` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE `p`.`Int` NOT IN (@ints1, @ints2) +"""); } - public override async Task Column_collection_Count_with_predicate(bool async) + public override async Task Column_collection_Count_with_predicate() { - await base.Column_collection_Count_with_predicate(async); + await base.Column_collection_Count_with_predicate(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_Where_Count(bool async) + public override async Task Column_collection_Where_Count() { - await base.Column_collection_Where_Count(async); + await base.Column_collection_Where_Count(); - AssertSql(); + AssertSql(""); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.WhereSubqueryReferencesOuterQuery))] - public override async Task Inline_collection_value_index_Column(bool async) + public override async Task Inline_collection_value_index_Column() { - await base.Inline_collection_value_index_Column(async); + await base.Inline_collection_value_index_Column(); - AssertSql(); + AssertSql(""); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.WhereSubqueryReferencesOuterQuery))] - public override async Task Inline_collection_List_value_index_Column(bool async) + public override async Task Inline_collection_List_value_index_Column() { - await base.Inline_collection_List_value_index_Column(async); + await base.Inline_collection_List_value_index_Column(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_First(bool async) + public override async Task Column_collection_First() { - await base.Column_collection_First(async); + await base.Column_collection_First(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_FirstOrDefault(bool async) + public override async Task Column_collection_FirstOrDefault() { - await base.Column_collection_FirstOrDefault(async); + await base.Column_collection_FirstOrDefault(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_Single(bool async) + public override async Task Column_collection_Single() { - await base.Column_collection_Single(async); + await base.Column_collection_Single(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_SingleOrDefault(bool async) + public override async Task Column_collection_SingleOrDefault() { - await base.Column_collection_SingleOrDefault(async); + await base.Column_collection_SingleOrDefault(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_Where_Skip(bool async) + public override async Task Column_collection_Where_Skip() { - await base.Column_collection_Where_Skip(async); + await base.Column_collection_Where_Skip(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_Where_Take(bool async) + public override async Task Column_collection_Where_Take() { - await base.Column_collection_Where_Take(async); + await base.Column_collection_Where_Take(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_Where_Skip_Take(bool async) + public override async Task Column_collection_Where_Skip_Take() { - await base.Column_collection_Where_Skip_Take(async); + await base.Column_collection_Where_Skip_Take(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_Contains_over_subquery(bool async) + public override async Task Column_collection_Contains_over_subquery() { - await base.Column_collection_Contains_over_subquery(async); + await base.Column_collection_Contains_over_subquery(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_Where_ElementAt(bool async) + public override async Task Column_collection_Where_ElementAt() { - await base.Column_collection_Where_ElementAt(async); + await base.Column_collection_Where_ElementAt(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_SelectMany_with_filter(bool async) + public override async Task Column_collection_SelectMany_with_filter() { - await base.Column_collection_SelectMany_with_filter(async); + await base.Column_collection_SelectMany_with_filter(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_SelectMany_with_Select_to_anonymous_type(bool async) + public override async Task Column_collection_SelectMany_with_Select_to_anonymous_type() { - await base.Column_collection_SelectMany_with_Select_to_anonymous_type(async); + await base.Column_collection_SelectMany_with_Select_to_anonymous_type(); - AssertSql(); + AssertSql(""); } - public override async Task Parameter_collection_with_type_inference_for_JsonScalarExpression(bool async) + public override async Task Parameter_collection_with_type_inference_for_JsonScalarExpression() { - await base.Parameter_collection_with_type_inference_for_JsonScalarExpression(async); + await base.Parameter_collection_with_type_inference_for_JsonScalarExpression(); - AssertSql(); + AssertSql(""); } - public override async Task Column_collection_Where_Union(bool async) + public override async Task Column_collection_Where_Union() { - await base.Column_collection_Where_Union(async); + await base.Column_collection_Where_Union(); - AssertSql(); + AssertSql(""); } - public override async Task Project_inline_collection(bool async) + public override async Task Project_inline_collection() { - await base.Project_inline_collection(async); + await base.Project_inline_collection(); AssertSql( """ @@ -2224,9 +2309,9 @@ public override async Task Project_inline_collection(bool async) """); } - public override async Task Project_inline_collection_with_Union(bool async) + public override async Task Project_inline_collection_with_Union() { - await base.Project_inline_collection_with_Union(async); + await base.Project_inline_collection_with_Union(); AssertSql( """ diff --git a/test/EFCore.MySql.FunctionalTests/Query/QueryFilterFuncletizationMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/QueryFilterFuncletizationMySqlTest.cs index 4b0c35a78..7fac0712a 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/QueryFilterFuncletizationMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/QueryFilterFuncletizationMySqlTest.cs @@ -92,15 +92,20 @@ WHERE FALSE """, // """ +@ef_filter__TenantIds1='1' + SELECT `l`.`Id`, `l`.`Tenant` FROM `ListFilter` AS `l` -WHERE `l`.`Tenant` = 1 +WHERE `l`.`Tenant` = @ef_filter__TenantIds1 """, // """ +@ef_filter__TenantIds1='2' +@ef_filter__TenantIds2='3' + SELECT `l`.`Id`, `l`.`Tenant` FROM `ListFilter` AS `l` -WHERE `l`.`Tenant` IN (2, 3) +WHERE `l`.`Tenant` IN (@ef_filter__TenantIds1, @ef_filter__TenantIds2) """); } } diff --git a/test/EFCore.MySql.FunctionalTests/Query/SharedTypeQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/SharedTypeQueryMySqlTest.cs index 4371982cc..c52d7a059 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/SharedTypeQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/SharedTypeQueryMySqlTest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; @@ -10,6 +11,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query { public class SharedTypeQueryMySqlTest : SharedTypeQueryRelationalTestBase { + public SharedTypeQueryMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; public override async Task Can_use_shared_type_entity_type_in_query_filter(bool async) diff --git a/test/EFCore.MySql.FunctionalTests/Query/SpatialQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/SpatialQueryMySqlTest.cs index 58f859f65..a110cffb2 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/SpatialQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/SpatialQueryMySqlTest.cs @@ -213,9 +213,9 @@ public override async Task Contains(bool async) AssertSql( """ -@__point_0='0x000000000101000000000000000000D03F000000000000D03F' (DbType = Binary) +@point='0x000000000101000000000000000000D03F000000000000D03F' (DbType = Binary) -SELECT `p`.`Id`, ST_Contains(`p`.`Polygon`, @__point_0) AS `Contains` +SELECT `p`.`Id`, ST_Contains(`p`.`Polygon`, @point) AS `Contains` FROM `PolygonEntity` AS `p` """); } @@ -270,9 +270,9 @@ public override async Task Crosses(bool async) AssertSql( """ -@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +@lineString='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) -SELECT `l`.`Id`, ST_Crosses(`l`.`LineString`, @__lineString_0) AS `Crosses` +SELECT `l`.`Id`, ST_Crosses(`l`.`LineString`, @lineString) AS `Crosses` FROM `LineStringEntity` AS `l` """); } @@ -283,9 +283,9 @@ public override async Task Difference(bool async) AssertSql( """ -@__polygon_0='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) +@polygon='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) -SELECT `p`.`Id`, ST_Difference(`p`.`Polygon`, @__polygon_0) AS `Difference` +SELECT `p`.`Id`, ST_Difference(`p`.`Polygon`, @polygon) AS `Difference` FROM `PolygonEntity` AS `p` """); } @@ -307,9 +307,9 @@ public override async Task Disjoint_with_cast_to_nullable(bool async) AssertSql( """ -@__point_0='0x000000000101000000000000000000F03F000000000000F03F' (DbType = Binary) +@point='0x000000000101000000000000000000F03F000000000000F03F' (DbType = Binary) -SELECT `p`.`Id`, ST_Disjoint(`p`.`Polygon`, @__point_0) AS `Disjoint` +SELECT `p`.`Id`, ST_Disjoint(`p`.`Polygon`, @point) AS `Disjoint` FROM `PolygonEntity` AS `p` """); } @@ -320,11 +320,11 @@ public override async Task Disjoint_with_null_check(bool async) AssertSql( """ -@__point_0='0x000000000101000000000000000000F03F000000000000F03F' (DbType = Binary) +@point='0x000000000101000000000000000000F03F000000000000F03F' (DbType = Binary) SELECT `p`.`Id`, CASE WHEN `p`.`Polygon` IS NULL THEN NULL - ELSE ST_Disjoint(`p`.`Polygon`, @__point_0) + ELSE ST_Disjoint(`p`.`Polygon`, @point) END AS `Disjoint` FROM `PolygonEntity` AS `p` """); @@ -337,23 +337,23 @@ public override async Task Distance_with_null_check(bool async) AssertSql( AppConfig.ServerVersion.Supports.SpatialDistanceSphereFunction ? """ -@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +@point='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) SELECT `p`.`Id`, CASE - WHEN ST_SRID(`p`.`Point`) = 4326 THEN ST_Distance_Sphere(`p`.`Point`, @__point_0) - ELSE ST_Distance(`p`.`Point`, @__point_0) + WHEN ST_SRID(`p`.`Point`) = 4326 THEN ST_Distance_Sphere(`p`.`Point`, @point) + ELSE ST_Distance(`p`.`Point`, @point) END AS `Distance` FROM `PointEntity` AS `p` """ : """ -@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +@point='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) SELECT `p`.`Id`, CASE WHEN ST_SRID(`p`.`Point`) = 4326 THEN CASE - WHEN (((((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 - ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) + WHEN (((((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 + ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2))))) END - ELSE ST_Distance(`p`.`Point`, @__point_0) + ELSE ST_Distance(`p`.`Point`, @point) END AS `Distance` FROM `PointEntity` AS `p` """); @@ -366,23 +366,23 @@ public override async Task Distance_with_cast_to_nullable(bool async) AssertSql( AppConfig.ServerVersion.Supports.SpatialDistanceSphereFunction ? """ -@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +@point='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) SELECT `p`.`Id`, CASE - WHEN ST_SRID(`p`.`Point`) = 4326 THEN ST_Distance_Sphere(`p`.`Point`, @__point_0) - ELSE ST_Distance(`p`.`Point`, @__point_0) + WHEN ST_SRID(`p`.`Point`) = 4326 THEN ST_Distance_Sphere(`p`.`Point`, @point) + ELSE ST_Distance(`p`.`Point`, @point) END AS `Distance` FROM `PointEntity` AS `p` """ : """ -@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +@point='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) SELECT `p`.`Id`, CASE WHEN ST_SRID(`p`.`Point`) = 4326 THEN CASE - WHEN (((((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 - ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) + WHEN (((((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 + ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2))))) END - ELSE ST_Distance(`p`.`Point`, @__point_0) + ELSE ST_Distance(`p`.`Point`, @point) END AS `Distance` FROM `PointEntity` AS `p` """); @@ -395,23 +395,23 @@ public override async Task Distance_geometry(bool async) AssertSql( AppConfig.ServerVersion.Supports.SpatialDistanceSphereFunction ? """ -@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +@point='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) SELECT `p`.`Id`, CASE - WHEN ST_SRID(`p`.`Geometry`) = 4326 THEN ST_Distance_Sphere(`p`.`Geometry`, @__point_0) - ELSE ST_Distance(`p`.`Geometry`, @__point_0) + WHEN ST_SRID(`p`.`Geometry`) = 4326 THEN ST_Distance_Sphere(`p`.`Geometry`, @point) + ELSE ST_Distance(`p`.`Geometry`, @point) END AS `Distance` FROM `PointEntity` AS `p` """ : """ -@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +@point='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) SELECT `p`.`Id`, CASE WHEN ST_SRID(`p`.`Geometry`) = 4326 THEN CASE - WHEN (((((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 - ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) + WHEN (((((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 + ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2))))) END - ELSE ST_Distance(`p`.`Geometry`, @__point_0) + ELSE ST_Distance(`p`.`Geometry`, @point) END AS `Distance` FROM `PointEntity` AS `p` """); @@ -539,9 +539,9 @@ public override async Task EqualsTopologically(bool async) AssertSql( """ -@__point_0='0x00000000010100000000000000000000000000000000000000' (DbType = Binary) +@point='0x00000000010100000000000000000000000000000000000000' (DbType = Binary) -SELECT `p`.`Id`, ST_Equals(`p`.`Point`, @__point_0) AS `EqualsTopologically` +SELECT `p`.`Id`, ST_Equals(`p`.`Point`, @point) AS `EqualsTopologically` FROM `PointEntity` AS `p` """); } @@ -613,9 +613,9 @@ public override async Task Intersection(bool async) AssertSql( """ -@__polygon_0='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) +@polygon='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) -SELECT `p`.`Id`, ST_Intersection(`p`.`Polygon`, @__polygon_0) AS `Intersection` +SELECT `p`.`Id`, ST_Intersection(`p`.`Polygon`, @polygon) AS `Intersection` FROM `PolygonEntity` AS `p` """); } @@ -626,9 +626,9 @@ public override async Task Intersects(bool async) AssertSql( """ -@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +@lineString='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) -SELECT `l`.`Id`, ST_Intersects(`l`.`LineString`, @__lineString_0) AS `Intersects` +SELECT `l`.`Id`, ST_Intersects(`l`.`LineString`, @lineString) AS `Intersects` FROM `LineStringEntity` AS `l` """); } @@ -718,27 +718,27 @@ public override async Task IsWithinDistance(bool async) AssertSql( AppConfig.ServerVersion.Supports.SpatialDistanceSphereFunction ? """ -@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +@point='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) SELECT `p`.`Id`, CASE WHEN CASE - WHEN ST_SRID(`p`.`Point`) = 4326 THEN ST_Distance_Sphere(`p`.`Point`, @__point_0) - ELSE ST_Distance(`p`.`Point`, @__point_0) + WHEN ST_SRID(`p`.`Point`) = 4326 THEN ST_Distance_Sphere(`p`.`Point`, @point) + ELSE ST_Distance(`p`.`Point`, @point) END <= 1.0 THEN TRUE ELSE FALSE END AS `IsWithinDistance` FROM `PointEntity` AS `p` """ : """ -@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +@point='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) SELECT `p`.`Id`, CASE WHEN CASE WHEN ST_SRID(`p`.`Point`) = 4326 THEN CASE - WHEN (((((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 - ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) + WHEN (((((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 + ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@point) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@point) * PI()) / 180.0)) / 2.0), 2))))) END - ELSE ST_Distance(`p`.`Point`, @__point_0) + ELSE ST_Distance(`p`.`Point`, @point) END <= 1.0 THEN TRUE ELSE FALSE END AS `IsWithinDistance` @@ -829,9 +829,9 @@ public override async Task Overlaps(bool async) AssertSql( """ -@__polygon_0='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) +@polygon='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) -SELECT `p`.`Id`, ST_Overlaps(`p`.`Polygon`, @__polygon_0) AS `Overlaps` +SELECT `p`.`Id`, ST_Overlaps(`p`.`Polygon`, @polygon) AS `Overlaps` FROM `PolygonEntity` AS `p` """); } @@ -875,9 +875,9 @@ public override async Task SymmetricDifference(bool async) AssertSql( """ -@__polygon_0='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) +@polygon='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) -SELECT `p`.`Id`, ST_SymDifference(`p`.`Polygon`, @__polygon_0) AS `SymmetricDifference` +SELECT `p`.`Id`, ST_SymDifference(`p`.`Polygon`, @polygon) AS `SymmetricDifference` FROM `PolygonEntity` AS `p` """); } @@ -910,9 +910,9 @@ public override async Task Touches(bool async) AssertSql( """ -@__polygon_0='0x00000000010300000001000000040000000000000000000000000000000000F0...' (DbType = Binary) +@polygon='0x00000000010300000001000000040000000000000000000000000000000000F0...' (DbType = Binary) -SELECT `p`.`Id`, ST_Touches(`p`.`Polygon`, @__polygon_0) AS `Touches` +SELECT `p`.`Id`, ST_Touches(`p`.`Polygon`, @polygon) AS `Touches` FROM `PolygonEntity` AS `p` """); } @@ -923,9 +923,9 @@ public override async Task Union(bool async) AssertSql( """ -@__polygon_0='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) +@polygon='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) -SELECT `p`.`Id`, ST_Union(`p`.`Polygon`, @__polygon_0) AS `Union` +SELECT `p`.`Id`, ST_Union(`p`.`Polygon`, @polygon) AS `Union` FROM `PolygonEntity` AS `p` """); } @@ -958,9 +958,9 @@ public override async Task Within(bool async) AssertSql( """ -@__polygon_0='0x0000000001030000000100000005000000000000000000F0BF000000000000F0...' (DbType = Binary) +@polygon='0x0000000001030000000100000005000000000000000000F0BF000000000000F0...' (DbType = Binary) -SELECT `p`.`Id`, ST_Within(`p`.`Point`, @__polygon_0) AS `Within` +SELECT `p`.`Id`, ST_Within(`p`.`Point`, @polygon) AS `Within` FROM `PointEntity` AS `p` """); } @@ -1041,19 +1041,19 @@ public override async Task Intersects_equal_to_null(bool async) AssertSql( """ -@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +@lineString='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) SELECT `l`.`Id` FROM `LineStringEntity` AS `l` -WHERE ST_Intersects(`l`.`LineString`, @__lineString_0) IS NULL +WHERE ST_Intersects(`l`.`LineString`, @lineString) IS NULL """, // """ -@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +@lineString='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) SELECT `l`.`Id` FROM `LineStringEntity` AS `l` -WHERE ST_Intersects(@__lineString_0, `l`.`LineString`) IS NULL +WHERE ST_Intersects(@lineString, `l`.`LineString`) IS NULL """); } @@ -1063,19 +1063,19 @@ public override async Task Intersects_not_equal_to_null(bool async) AssertSql( """ -@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +@lineString='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) SELECT `l`.`Id` FROM `LineStringEntity` AS `l` -WHERE ST_Intersects(`l`.`LineString`, @__lineString_0) IS NOT NULL +WHERE ST_Intersects(`l`.`LineString`, @lineString) IS NOT NULL """, // """ -@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +@lineString='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) SELECT `l`.`Id` FROM `LineStringEntity` AS `l` -WHERE ST_Intersects(@__lineString_0, `l`.`LineString`) IS NOT NULL +WHERE ST_Intersects(@lineString, `l`.`LineString`) IS NOT NULL """); } diff --git a/test/EFCore.MySql.FunctionalTests/Query/SqlQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/SqlQueryMySqlTest.cs index 3927e3cf4..5223905c8 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/SqlQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/SqlQueryMySqlTest.cs @@ -283,13 +283,13 @@ public override async Task SqlQueryRaw_queryable_with_parameters_and_clo AssertSql( """ p0='London' (Size = 4000) -@__contactTitle_1='Sales Representative' (Size = 30) +@contactTitle='Sales Representative' (Size = 30) SELECT `m`.`Address`, `m`.`City`, `m`.`CompanyName`, `m`.`ContactName`, `m`.`ContactTitle`, `m`.`Country`, `m`.`CustomerID`, `m`.`Fax`, `m`.`Phone`, `m`.`Region`, `m`.`PostalCode` FROM ( SELECT * FROM `Customers` WHERE `City` = @p0 ) AS `m` -WHERE `m`.`ContactTitle` = @__contactTitle_1 +WHERE `m`.`ContactTitle` = @contactTitle """); return null; @@ -434,9 +434,9 @@ public override async Task SqlQueryRaw_with_dbParameter_mixed(bool async) // """ @city='London' (Nullable = false) -p1='Sales Representative' (Size = 4000) +p0='Sales Representative' (Size = 4000) -SELECT * FROM `Customers` WHERE `City` = @city AND `ContactTitle` = @p1 +SELECT * FROM `Customers` WHERE `City` = @city AND `ContactTitle` = @p0 """); } @@ -497,14 +497,14 @@ public override async Task SqlQuery_parameterization_issue_12213(bool async) """, // """ -@__max_1='10400' +@max='10400' p0='10300' SELECT `m`.`OrderID` FROM ( SELECT * FROM `Orders` ) AS `m` -WHERE (`m`.`OrderID` <= @__max_1) AND `m`.`OrderID` IN ( +WHERE (`m`.`OrderID` <= @max) AND `m`.`OrderID` IN ( SELECT `m0`.`OrderID` FROM ( SELECT * FROM `Orders` WHERE `OrderID` >= @p0 @@ -513,14 +513,14 @@ public override async Task SqlQuery_parameterization_issue_12213(bool async) """, // """ -@__max_1='10400' +@max='10400' p0='10300' SELECT `m`.`OrderID` FROM ( SELECT * FROM `Orders` ) AS `m` -WHERE (`m`.`OrderID` <= @__max_1) AND `m`.`OrderID` IN ( +WHERE (`m`.`OrderID` <= @max) AND `m`.`OrderID` IN ( SELECT `m0`.`OrderID` FROM ( SELECT * FROM `Orders` WHERE `OrderID` >= @p0 @@ -660,7 +660,7 @@ public override async Task SqlQueryRaw_with_dbParameter_mixed_in_subquery(bool a // """ @city='London' (Nullable = false) -p1='Sales Representative' (Size = 4000) +p0='Sales Representative' (Size = 4000) SELECT `m`.`CustomerID`, `m`.`EmployeeID`, `m`.`Freight`, `m`.`OrderDate`, `m`.`OrderID`, `m`.`RequiredDate`, `m`.`ShipAddress`, `m`.`ShipCity`, `m`.`ShipCountry`, `m`.`ShipName`, `m`.`ShipPostalCode`, `m`.`ShipRegion`, `m`.`ShipVia`, `m`.`ShippedDate` FROM ( @@ -669,32 +669,12 @@ public override async Task SqlQueryRaw_with_dbParameter_mixed_in_subquery(bool a WHERE `m`.`CustomerID` IN ( SELECT `m0`.`CustomerID` FROM ( - SELECT * FROM `Customers` WHERE `City` = @city AND `ContactTitle` = @p1 + SELECT * FROM `Customers` WHERE `City` = @city AND `ContactTitle` = @p0 ) AS `m0` ) """); } - public override async Task Multiple_occurrences_of_SqlQuery_with_db_parameter_adds_parameter_only_once(bool async) - { - await base.Multiple_occurrences_of_SqlQuery_with_db_parameter_adds_parameter_only_once(async); - - AssertSql( -""" -city='Seattle' (Nullable = false) - -SELECT `m`.`Address`, `m`.`City`, `m`.`CompanyName`, `m`.`ContactName`, `m`.`ContactTitle`, `m`.`Country`, `m`.`CustomerID`, `m`.`Fax`, `m`.`Phone`, `m`.`Region`, `m`.`PostalCode` -FROM ( - SELECT * FROM `Customers` WHERE `City` = @city -) AS `m` -INTERSECT -SELECT `m0`.`Address`, `m0`.`City`, `m0`.`CompanyName`, `m0`.`ContactName`, `m0`.`ContactTitle`, `m0`.`Country`, `m0`.`CustomerID`, `m0`.`Fax`, `m0`.`Phone`, `m0`.`Region`, `m0`.`PostalCode` -FROM ( - SELECT * FROM `Customers` WHERE `City` = @city -) AS `m0` -"""); - } - public override async Task Bad_data_error_handling_invalid_cast_key(bool async) { await base.Bad_data_error_handling_invalid_cast_key(async); diff --git a/test/EFCore.MySql.FunctionalTests/Query/TPCFiltersInheritanceQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/TPCFiltersInheritanceQueryMySqlTest.cs index 51e87d75b..4339e633e 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/TPCFiltersInheritanceQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/TPCFiltersInheritanceQueryMySqlTest.cs @@ -207,11 +207,11 @@ LIMIT 2 """, // """ -@__p_0='2' +@p='2' SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group` FROM `Eagle` AS `e` -WHERE `e`.`Id` = @__p_0 +WHERE `e`.`Id` = @p LIMIT 1 """); } diff --git a/test/EFCore.MySql.FunctionalTests/Query/TPCGearsOfWarQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/TPCGearsOfWarQueryMySqlTest.cs index e94bd2631..4fd507da6 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/TPCGearsOfWarQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/TPCGearsOfWarQueryMySqlTest.cs @@ -1,14 +1,10 @@ using System; using System.Linq; -using System.Linq.Expressions; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel; -using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.Infrastructure; -using Pomelo.EntityFrameworkCore.MySql.Tests; using Pomelo.EntityFrameworkCore.MySql.Tests.TestUtilities.Attributes; using Xunit; using Xunit.Abstractions; @@ -24,10 +20,6 @@ public TPCGearsOfWarQueryMySqlTest(TPCGearsOfWarQueryMySqlFixture fixture, ITest //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - [ConditionalFact] - public virtual void Check_all_tests_overridden() - => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); - public override async Task Entity_equality_empty(bool async) { await base.Entity_equality_empty(async); @@ -339,6 +331,17 @@ FROM JSON_TABLE('["b39a6fba-9026-4d69-828e-fd7068673e57","70534e05-782c-4052-872 """, // """ +@tags1='b39a6fba-9026-4d69-828e-fd7068673e57' +@tags2='70534e05-782c-4052-8720-c2c54481ce5f' +@tags3='a8ad98f9-e023-4e2a-9a70-c2728455bd34' +@tags4='df36f493-463f-4123-83f9-6b135deeb7ba' +@tags5='34c8d86e-a4ac-4be5-827f-584dda348a07' +@tags6='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags7='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags8='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags9='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags10='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -348,7 +351,7 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) -WHERE `t`.`Id` IS NOT NULL AND `t`.`Id` IN ('b39a6fba-9026-4d69-828e-fd7068673e57', '70534e05-782c-4052-8720-c2c54481ce5f', 'a8ad98f9-e023-4e2a-9a70-c2728455bd34', 'df36f493-463f-4123-83f9-6b135deeb7ba', '34c8d86e-a4ac-4be5-827f-584dda348a07', 'a7be028a-0cf2-448f-ab55-ce8bc5d8cf69') +WHERE `t`.`Id` IS NOT NULL AND `t`.`Id` IN (@tags1, @tags2, @tags3, @tags4, @tags5, @tags6, @tags7, @tags8, @tags9, @tags10) """); } } @@ -394,6 +397,17 @@ FROM JSON_TABLE('["b39a6fba-9026-4d69-828e-fd7068673e57","70534e05-782c-4052-872 """, // """ +@tags1='b39a6fba-9026-4d69-828e-fd7068673e57' +@tags2='70534e05-782c-4052-8720-c2c54481ce5f' +@tags3='a8ad98f9-e023-4e2a-9a70-c2728455bd34' +@tags4='df36f493-463f-4123-83f9-6b135deeb7ba' +@tags5='34c8d86e-a4ac-4be5-827f-584dda348a07' +@tags6='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags7='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags8='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags9='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags10='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -404,7 +418,7 @@ UNION ALL ) AS `u` INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) -WHERE `c`.`Location` IS NOT NULL AND `t`.`Id` IN ('b39a6fba-9026-4d69-828e-fd7068673e57', '70534e05-782c-4052-8720-c2c54481ce5f', 'a8ad98f9-e023-4e2a-9a70-c2728455bd34', 'df36f493-463f-4123-83f9-6b135deeb7ba', '34c8d86e-a4ac-4be5-827f-584dda348a07', 'a7be028a-0cf2-448f-ab55-ce8bc5d8cf69') +WHERE `c`.`Location` IS NOT NULL AND `t`.`Id` IN (@tags1, @tags2, @tags3, @tags4, @tags5, @tags6, @tags7, @tags8, @tags9, @tags10) """); } } @@ -449,6 +463,17 @@ FROM JSON_TABLE('["b39a6fba-9026-4d69-828e-fd7068673e57","70534e05-782c-4052-872 """, // """ +@tags1='b39a6fba-9026-4d69-828e-fd7068673e57' +@tags2='70534e05-782c-4052-8720-c2c54481ce5f' +@tags3='a8ad98f9-e023-4e2a-9a70-c2728455bd34' +@tags4='df36f493-463f-4123-83f9-6b135deeb7ba' +@tags5='34c8d86e-a4ac-4be5-827f-584dda348a07' +@tags6='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags7='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags8='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags9='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' +@tags10='a7be028a-0cf2-448f-ab55-ce8bc5d8cf69' + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -458,7 +483,7 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) -WHERE `t`.`Id` IS NOT NULL AND `t`.`Id` IN ('b39a6fba-9026-4d69-828e-fd7068673e57', '70534e05-782c-4052-8720-c2c54481ce5f', 'a8ad98f9-e023-4e2a-9a70-c2728455bd34', 'df36f493-463f-4123-83f9-6b135deeb7ba', '34c8d86e-a4ac-4be5-827f-584dda348a07', 'a7be028a-0cf2-448f-ab55-ce8bc5d8cf69') +WHERE `t`.`Id` IS NOT NULL AND `t`.`Id` IN (@tags1, @tags2, @tags3, @tags4, @tags5, @tags6, @tags7, @tags8, @tags9, @tags10) """); } } @@ -548,621 +573,45 @@ public override async Task Include_with_join_and_inheritance2(bool async) public override async Task Include_with_join_and_inheritance3(bool async) { - await base.Include_with_join_and_inheritance3(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` -FROM `Tags` AS `t` -INNER JOIN ( - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` ON (`t`.`GearSquadId` = `u`.`SquadId`) AND (`t`.`GearNickName` = `u`.`Nickname`) -LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o0` -) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) -ORDER BY `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` -"""); - } - - public override async Task Include_with_nested_navigation_in_order_by(bool async) - { - await base.Include_with_nested_navigation_in_order_by(async); - - AssertSql( -""" -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM `Weapons` AS `w` -LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` ON `w`.`OwnerFullName` = `u`.`FullName` -LEFT JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` -WHERE (`u`.`Nickname` <> 'Paduk') OR `u`.`Nickname` IS NULL -ORDER BY `c`.`Name`, `w`.`Id` -"""); - } - - public override async Task Where_enum(bool async) - { - await base.Where_enum(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE `u`.`Rank` = 4 -"""); - } - - public override async Task Where_nullable_enum_with_constant(bool async) - { - await base.Where_nullable_enum_with_constant(async); - - AssertSql( -""" -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE `w`.`AmmunitionType` = 1 -"""); - } - - public override async Task Where_nullable_enum_with_null_constant(bool async) - { - await base.Where_nullable_enum_with_null_constant(async); - - AssertSql( -""" -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE `w`.`AmmunitionType` IS NULL -"""); - } - - public override async Task Where_nullable_enum_with_non_nullable_parameter(bool async) - { - await base.Where_nullable_enum_with_non_nullable_parameter(async); - - AssertSql( -""" -@__ammunitionType_0='1' - -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE `w`.`AmmunitionType` = @__ammunitionType_0 -"""); - } - - public override async Task Where_nullable_enum_with_nullable_parameter(bool async) - { - await base.Where_nullable_enum_with_nullable_parameter(async); - - AssertSql( -""" -@__ammunitionType_0='1' (Nullable = true) - -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE `w`.`AmmunitionType` = @__ammunitionType_0 -""", - // - """ -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE `w`.`AmmunitionType` IS NULL -"""); - } - - public override async Task Where_bitwise_and_enum(bool async) - { - await base.Where_bitwise_and_enum(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & 2 AS signed) > 0 -""", - // - """ -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & 2 AS signed) = 2 -"""); - } - - public override async Task Where_bitwise_and_integral(bool async) - { - await base.Where_bitwise_and_integral(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & 1 AS signed) = 1 -""", - // - """ -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(CAST(`u`.`Rank` AS signed) & 1 AS signed) = 1 -""", - // - """ -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(CAST(`u`.`Rank` AS signed) & 1 AS signed) = 1 -"""); - } - - public override async Task Where_bitwise_and_nullable_enum_with_constant(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_constant(async); - - AssertSql( -""" -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE CAST(`w`.`AmmunitionType` & 1 AS signed) > 0 -"""); - } - - public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_null_constant(async); - - AssertSql( -""" -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE CAST(`w`.`AmmunitionType` & NULL AS signed) > 0 -"""); - } - - public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(async); - - AssertSql( -""" -@__ammunitionType_0='1' - -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE CAST(`w`.`AmmunitionType` & @__ammunitionType_0 AS signed) > 0 -"""); - } - - public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(async); - - AssertSql( -""" -@__ammunitionType_0='1' (Nullable = true) - -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE CAST(`w`.`AmmunitionType` & @__ammunitionType_0 AS signed) > 0 -""", - // - """ -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE CAST(`w`.`AmmunitionType` & NULL AS signed) > 0 -"""); - } - - public override async Task Where_bitwise_or_enum(bool async) - { - await base.Where_bitwise_or_enum(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` | 2 AS signed) > 0 -"""); - } - - public override async Task Bitwise_projects_values_in_select(bool async) - { - await base.Bitwise_projects_values_in_select(async); - - AssertSql( -""" -SELECT CAST(`u`.`Rank` & 2 AS signed) = 2 AS `BitwiseTrue`, CAST(`u`.`Rank` & 2 AS signed) = 4 AS `BitwiseFalse`, CAST(`u`.`Rank` & 2 AS signed) AS `BitwiseValue` -FROM ( - SELECT `g`.`Rank` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Rank` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & 2 AS signed) = 2 -LIMIT 1 -"""); - } - - public override async Task Where_enum_has_flag(bool async) - { - await base.Where_enum_has_flag(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & 2 AS signed) = 2 -""", - // - """ -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & 18 AS signed) = 18 -""", - // - """ -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & 1 AS signed) = 1 -""", - // - """ -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & 1 AS signed) = 1 -""", - // - """ -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(2 & `u`.`Rank` AS signed) = `u`.`Rank` -"""); - } - - public override async Task Where_enum_has_flag_subquery(bool async) - { - await base.Where_enum_has_flag_subquery(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & COALESCE(( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1), 0) AS signed) = COALESCE(( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1), 0) -""", - // - """ -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(2 & COALESCE(( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1), 0) AS signed) = COALESCE(( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1), 0) -"""); - } - - public override async Task Where_enum_has_flag_subquery_with_pushdown(bool async) - { - await base.Where_enum_has_flag_subquery_with_pushdown(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE (CAST(`u`.`Rank` & ( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1) AS signed) = ( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1)) OR ( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1) IS NULL -""", - // - """ -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE (CAST(2 & ( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1) AS signed) = ( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1)) OR ( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1) IS NULL -"""); - } - - public override async Task Where_enum_has_flag_subquery_client_eval(bool async) - { - await base.Where_enum_has_flag_subquery_client_eval(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE (CAST(`u`.`Rank` & ( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1) AS signed) = ( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1)) OR ( - SELECT `u0`.`Rank` - FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` - UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` - FROM `Officers` AS `o0` - ) AS `u0` - ORDER BY `u0`.`Nickname`, `u0`.`SquadId` - LIMIT 1) IS NULL -"""); - } - - public override async Task Where_enum_has_flag_with_non_nullable_parameter(bool async) - { - await base.Where_enum_has_flag_with_non_nullable_parameter(async); - - AssertSql( -""" -@__parameter_0='2' - -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & @__parameter_0 AS signed) = @__parameter_0 -"""); - } - - public override async Task Where_has_flag_with_nullable_parameter(bool async) - { - await base.Where_has_flag_with_nullable_parameter(async); + await base.Include_with_join_and_inheritance3(async); AssertSql( """ -@__parameter_0='2' (Nullable = true) - -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` +FROM `Tags` AS `t` +INNER JOIN ( + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` ON (`t`.`GearSquadId` = `u`.`SquadId`) AND (`t`.`GearNickName` = `u`.`Nickname`) +LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & @__parameter_0 AS signed) = @__parameter_0 + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o0` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } - public override async Task Select_enum_has_flag(bool async) + public override async Task Include_with_nested_navigation_in_order_by(bool async) { - await base.Select_enum_has_flag(async); + await base.Include_with_nested_navigation_in_order_by(async); AssertSql( """ -SELECT CAST(`u`.`Rank` & 2 AS signed) = 2 AS `hasFlagTrue`, CAST(`u`.`Rank` & 4 AS signed) = 4 AS `hasFlagFalse` -FROM ( - SELECT `g`.`Rank` +SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM `Weapons` AS `w` +LEFT JOIN ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Rank` + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `u` -WHERE CAST(`u`.`Rank` & 2 AS signed) = 2 -LIMIT 1 +) AS `u` ON `w`.`OwnerFullName` = `u`.`FullName` +LEFT JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` +WHERE (`u`.`Nickname` <> 'Paduk') OR `u`.`Nickname` IS NULL +ORDER BY `c`.`Name`, `w`.`Id` """); } @@ -1226,11 +675,11 @@ public override async Task Select_comparison_with_null(bool async) AssertSql( """ -@__ammunitionType_0='1' (Nullable = true) +@ammunitionType='1' (Nullable = true) -SELECT `w`.`Id`, (`w`.`AmmunitionType` = @__ammunitionType_0) AND `w`.`AmmunitionType` IS NOT NULL AS `Cartridge` +SELECT `w`.`Id`, (`w`.`AmmunitionType` = @ammunitionType) AND `w`.`AmmunitionType` IS NOT NULL AS `Cartridge` FROM `Weapons` AS `w` -WHERE `w`.`AmmunitionType` = @__ammunitionType_0 +WHERE `w`.`AmmunitionType` = @ammunitionType """, // """ @@ -1246,9 +695,9 @@ public override async Task Select_null_parameter(bool async) AssertSql( """ -@__ammunitionType_0='1' (Nullable = true) +@ammunitionType='1' (Nullable = true) -SELECT `w`.`Id`, @__ammunitionType_0 AS `AmmoType` +SELECT `w`.`Id`, @ammunitionType AS `AmmoType` FROM `Weapons` AS `w` """, // @@ -1258,9 +707,9 @@ public override async Task Select_null_parameter(bool async) """, // """ -@__ammunitionType_0='2' (Nullable = true) +@ammunitionType='2' (Nullable = true) -SELECT `w`.`Id`, @__ammunitionType_0 AS `AmmoType` +SELECT `w`.`Id`, @ammunitionType AS `AmmoType` FROM `Weapons` AS `w` """, // @@ -2289,7 +1738,7 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` WHERE (`u`.`HasSoulPatch` = TRUE) AND COALESCE(( - SELECT DISTINCT `w`.`IsAutomatic` + SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') LIMIT 1), FALSE) @@ -2963,11 +2412,11 @@ public override async Task Non_unicode_parameter_is_used_for_non_unicode_column( AssertSql( """ -@__value_0='Unknown' (Size = 4000) +@value='Unknown' (Size = 4000) SELECT `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM `Cities` AS `c` -WHERE `c`.`Location` = @__value_0 +WHERE `c`.`Location` = @value """); } @@ -2994,9 +2443,13 @@ FROM JSON_TABLE('["Unknown","Jacinto\\u0027s location","Ephyra\\u0027s location" { AssertSql( """ +@cities1='Unknown' (Size = 4000) +@cities2='Jacinto's location' (Size = 4000) +@cities3='Ephyra's location' (Size = 4000) + SELECT `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM `Cities` AS `c` -WHERE `c`.`Location` IN ('Unknown', 'Jacinto''s location', 'Ephyra''s location') +WHERE `c`.`Location` IN (@cities1, @cities2, @cities3) """); } } @@ -3724,345 +3177,116 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `u` ON `t`.`GearNickName` = `u`.`Nickname` -ORDER BY `t`.`Note`, `t`.`Id`, `u`.`Nickname` -"""); - } - - public override async Task Join_predicate_value_equals_condition(bool async) - { - await base.Join_predicate_value_equals_condition(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -INNER JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL -"""); - } - - public override async Task Join_predicate_value(bool async) - { - await base.Join_predicate_value(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -INNER JOIN `Weapons` AS `w` ON `u`.`HasSoulPatch` = TRUE -"""); - } - - public override async Task Join_predicate_condition_equals_condition(bool async) - { - await base.Join_predicate_condition_equals_condition(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -INNER JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL -"""); - } - - public override async Task Left_join_predicate_value_equals_condition(bool async) - { - await base.Left_join_predicate_value_equals_condition(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -LEFT JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL -"""); - } - - public override async Task Left_join_predicate_value(bool async) - { - await base.Left_join_predicate_value(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -LEFT JOIN `Weapons` AS `w` ON `u`.`HasSoulPatch` = TRUE -"""); - } - - public override async Task Left_join_predicate_condition_equals_condition(bool async) - { - await base.Left_join_predicate_condition_equals_condition(async); - - AssertSql( -""" -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -LEFT JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL -"""); - } - - public override async Task Where_datetimeoffset_now(bool async) - { - await base.Where_datetimeoffset_now(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE `m`.`Timeline` <> UTC_TIMESTAMP(6) -"""); - } - - public override async Task Where_datetimeoffset_utcnow(bool async) - { - await base.Where_datetimeoffset_utcnow(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE `m`.`Timeline` <> UTC_TIMESTAMP(6) -"""); - } - - public override async Task Where_datetimeoffset_date_component(bool async) - { - await base.Where_datetimeoffset_date_component(async); - - AssertSql( -""" -@__Date_0='0001-01-01T00:00:00.0000000' (DbType = DateTime) - -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE CONVERT(`m`.`Timeline`, date) > @__Date_0 -"""); - } - - public override async Task Where_datetimeoffset_year_component(bool async) - { - await base.Where_datetimeoffset_year_component(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(year FROM `m`.`Timeline`) = 2 -"""); - } - - public override async Task Where_datetimeoffset_month_component(bool async) - { - await base.Where_datetimeoffset_month_component(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(month FROM `m`.`Timeline`) = 1 -"""); - } - - public override async Task Where_datetimeoffset_dayofyear_component(bool async) - { - await base.Where_datetimeoffset_dayofyear_component(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE DAYOFYEAR(`m`.`Timeline`) = 2 -"""); - } - - public override async Task Where_datetimeoffset_day_component(bool async) - { - await base.Where_datetimeoffset_day_component(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(day FROM `m`.`Timeline`) = 2 -"""); - } - - public override async Task Where_datetimeoffset_hour_component(bool async) - { - await AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Hour == /* 10 */ 8 - select m); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(hour FROM `m`.`Timeline`) = 8 -"""); - } - - public override async Task Where_datetimeoffset_minute_component(bool async) - { - await base.Where_datetimeoffset_minute_component(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(minute FROM `m`.`Timeline`) = 0 -"""); - } - - public override async Task Where_datetimeoffset_second_component(bool async) - { - await base.Where_datetimeoffset_second_component(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(second FROM `m`.`Timeline`) = 0 -"""); - } - - public override async Task Where_datetimeoffset_millisecond_component(bool async) - { - await base.Where_datetimeoffset_millisecond_component(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE (EXTRACT(microsecond FROM `m`.`Timeline`)) DIV (1000) = 0 -"""); - } - - public override async Task DateTimeOffset_DateAdd_AddMonths(bool async) - { - await base.DateTimeOffset_DateAdd_AddMonths(async); - - AssertSql( -""" -SELECT DATE_ADD(`m`.`Timeline`, INTERVAL CAST(1 AS signed) month) -FROM `Missions` AS `m` +) AS `u` ON `t`.`GearNickName` = `u`.`Nickname` +ORDER BY `t`.`Note`, `t`.`Id`, `u`.`Nickname` """); } - public override async Task DateTimeOffset_DateAdd_AddDays(bool async) + public override async Task Join_predicate_value_equals_condition(bool async) { - await base.DateTimeOffset_DateAdd_AddDays(async); + await base.Join_predicate_value_equals_condition(async); AssertSql( """ -SELECT DATE_ADD(`m`.`Timeline`, INTERVAL CAST(1.0 AS signed) day) -FROM `Missions` AS `m` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +INNER JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL """); } - public override async Task DateTimeOffset_DateAdd_AddHours(bool async) + public override async Task Join_predicate_value(bool async) { - await base.DateTimeOffset_DateAdd_AddHours(async); + await base.Join_predicate_value(async); AssertSql( """ -SELECT DATE_ADD(`m`.`Timeline`, INTERVAL CAST(1.0 AS signed) hour) -FROM `Missions` AS `m` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +INNER JOIN `Weapons` AS `w` ON `u`.`HasSoulPatch` = TRUE """); } - public override async Task DateTimeOffset_DateAdd_AddMinutes(bool async) + public override async Task Join_predicate_condition_equals_condition(bool async) { - await base.DateTimeOffset_DateAdd_AddMinutes(async); + await base.Join_predicate_condition_equals_condition(async); AssertSql( """ -SELECT DATE_ADD(`m`.`Timeline`, INTERVAL CAST(1.0 AS signed) minute) -FROM `Missions` AS `m` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +INNER JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL """); } - public override async Task DateTimeOffset_DateAdd_AddSeconds(bool async) + public override async Task Left_join_predicate_value_equals_condition(bool async) { - await base.DateTimeOffset_DateAdd_AddSeconds(async); + await base.Left_join_predicate_value_equals_condition(async); AssertSql( """ -SELECT DATE_ADD(`m`.`Timeline`, INTERVAL CAST(1.0 AS signed) second) -FROM `Missions` AS `m` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL """); } - public override async Task DateTimeOffset_DateAdd_AddMilliseconds(bool async) + public override async Task Left_join_predicate_value(bool async) { - await base.DateTimeOffset_DateAdd_AddMilliseconds(async); + await base.Left_join_predicate_value(async); AssertSql( """ -SELECT DATE_ADD(`m`.`Timeline`, INTERVAL 1000 * CAST(300.0 AS signed) microsecond) -FROM `Missions` AS `m` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `u`.`HasSoulPatch` = TRUE """); } - public override async Task Where_datetimeoffset_milliseconds_parameter_and_constant(bool async) + public override async Task Left_join_predicate_condition_equals_condition(bool async) { - var dateTimeOffset = MySqlTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0))); - - // Literal where clause - var p = Expression.Parameter(typeof(Mission), "i"); - var dynamicWhere = Expression.Lambda>( - Expression.Equal( - Expression.Property(p, "Timeline"), - Expression.Constant(dateTimeOffset) - ), p); - - await AssertCount( - async, - ss => ss.Set().Where(dynamicWhere), - ss => ss.Set().Where(m => m.Timeline == dateTimeOffset)); + await base.Left_join_predicate_condition_equals_condition(async); AssertSql( """ -SELECT COUNT(*) -FROM `Missions` AS `m` -WHERE `m`.`Timeline` = TIMESTAMP '1902-01-02 08:30:00.123456' +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL """); } @@ -4235,9 +3459,13 @@ FROM JSON_TABLE('["d2c26679-562b-44d1-ab96-23d1775e0926","23cbcf9b-ce14-45cf-aaf { AssertSql( """ +@ids1='df36f493-463f-4123-83f9-6b135deeb7ba' +@ids2='23cbcf9b-ce14-45cf-aafa-2c2667ebfdd3' +@ids3='ab1b82d7-88db-42bd-a132-7eef9aa68af4' + SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` FROM `Tags` AS `t` -WHERE `t`.`Id` IN ('df36f493-463f-4123-83f9-6b135deeb7ba', '23cbcf9b-ce14-45cf-aafa-2c2667ebfdd3', 'ab1b82d7-88db-42bd-a132-7eef9aa68af4') +WHERE `t`.`Id` IN (@ids1, @ids2, @ids3) """); } } @@ -4479,7 +3707,7 @@ public override async Task Subquery_with_result_operator_is_not_lifted(bool asyn AssertSql( """ -@__p_0='2' +@p='2' SELECT `u0`.`FullName` FROM ( @@ -4493,7 +3721,7 @@ UNION ALL ) AS `u` WHERE `u`.`HasSoulPatch` = FALSE ORDER BY `u`.`FullName` - LIMIT @__p_0 + LIMIT @p ) AS `u0` ORDER BY `u0`.`Rank` """); @@ -4505,7 +3733,7 @@ public override async Task Skip_with_orderby_followed_by_orderBy_is_pushed_down( AssertSql( """ -@__p_0='1' +@p='1' SELECT `u0`.`FullName` FROM ( @@ -4519,7 +3747,7 @@ UNION ALL ) AS `u` WHERE `u`.`HasSoulPatch` = FALSE ORDER BY `u`.`FullName` - LIMIT 18446744073709551610 OFFSET @__p_0 + LIMIT 18446744073709551610 OFFSET @p ) AS `u0` ORDER BY `u0`.`Rank` """); @@ -4639,7 +3867,7 @@ public override async Task Member_access_on_derived_materialized_entity_using_ca AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated` FROM `LocustHordes` AS `l` ORDER BY `l`.`Name` """); @@ -4688,7 +3916,7 @@ public override async Task Navigation_access_on_derived_materialized_entity_usin AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l0`.`ThreatLevel` AS `Threat` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated`, `l0`.`ThreatLevel` AS `Threat` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` ORDER BY `l`.`Name` @@ -4767,7 +3995,7 @@ public override async Task Include_on_derived_entity_using_OfType(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` LEFT JOIN ( @@ -4915,6 +4143,8 @@ FROM JSON_TABLE('["Ephyra",null]', '$[*]' COLUMNS ( { AssertSql( """ +@cities1='Ephyra' (Size = 255) + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -4924,7 +4154,7 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` LEFT JOIN `Cities` AS `c` ON `u`.`AssignedCityName` = `c`.`Name` -WHERE (`u`.`SquadId` < 2) AND (`c`.`Name` IS NULL OR (`c`.`Name` = 'Ephyra')) +WHERE (`u`.`SquadId` < 2) AND (`c`.`Name` IS NULL OR (`c`.`Name` = @cities1)) """); } } @@ -5336,7 +4566,7 @@ public override async Task ThenInclude_collection_on_derived_after_derived_refer AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` LEFT JOIN ( @@ -5398,7 +4628,7 @@ public override async Task ThenInclude_reference_on_derived_after_derived_collec AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `s`.`Name`, `s`.`LocustHordeId`, `s`.`ThreatLevel`, `s`.`ThreatLevelByte`, `s`.`ThreatLevelNullableByte`, `s`.`DefeatedByNickname`, `s`.`DefeatedBySquadId`, `s`.`HighCommandId`, `s`.`Discriminator`, `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator0` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated`, `s`.`Name`, `s`.`LocustHordeId`, `s`.`ThreatLevel`, `s`.`ThreatLevelByte`, `s`.`ThreatLevelNullableByte`, `s`.`DefeatedByNickname`, `s`.`DefeatedBySquadId`, `s`.`HighCommandId`, `s`.`Discriminator`, `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator0` FROM `LocustHordes` AS `l` LEFT JOIN ( SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` AS `Discriminator0` @@ -5427,7 +4657,7 @@ public override async Task Multiple_derived_included_on_one_method(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` LEFT JOIN ( @@ -6939,7 +6169,7 @@ public override async Task Null_semantics_on_nullable_bool_from_inner_join_subqu AssertSql( """ -SELECT `l2`.`Id`, `l2`.`CapitalName`, `l2`.`Name`, `l2`.`ServerAddress`, `l2`.`CommanderName`, `l2`.`Eradicated` +SELECT `l2`.`Id`, `l2`.`CapitalName`, `l2`.`Name`, `l2`.`ServerAddress`, `l2`.`CommanderName`, `l2`.`DeputyCommanderName`, `l2`.`Eradicated` FROM ( SELECT `l`.`Name` FROM `LocustLeaders` AS `l` @@ -6948,11 +6178,11 @@ UNION ALL FROM `LocustCommanders` AS `l0` ) AS `u` INNER JOIN ( - SELECT `l1`.`Id`, `l1`.`CapitalName`, `l1`.`Name`, `l1`.`ServerAddress`, `l1`.`CommanderName`, `l1`.`Eradicated` + SELECT `l1`.`Id`, `l1`.`CapitalName`, `l1`.`Name`, `l1`.`ServerAddress`, `l1`.`CommanderName`, `l1`.`DeputyCommanderName`, `l1`.`Eradicated` FROM `LocustHordes` AS `l1` WHERE `l1`.`Name` = 'Swarm' ) AS `l2` ON `u`.`Name` = `l2`.`CommanderName` -WHERE (`l2`.`Eradicated` = FALSE) OR (`l2`.`Eradicated` IS NULL) +WHERE (`l2`.`Eradicated` <> TRUE) OR (`l2`.`Eradicated` IS NULL) """); } @@ -6962,7 +6192,7 @@ public override async Task Null_semantics_on_nullable_bool_from_left_join_subque AssertSql( """ -SELECT `l2`.`Id`, `l2`.`CapitalName`, `l2`.`Name`, `l2`.`ServerAddress`, `l2`.`CommanderName`, `l2`.`Eradicated` +SELECT `l2`.`Id`, `l2`.`CapitalName`, `l2`.`Name`, `l2`.`ServerAddress`, `l2`.`CommanderName`, `l2`.`DeputyCommanderName`, `l2`.`Eradicated` FROM ( SELECT `l`.`Name` FROM `LocustLeaders` AS `l` @@ -6971,11 +6201,11 @@ UNION ALL FROM `LocustCommanders` AS `l0` ) AS `u` LEFT JOIN ( - SELECT `l1`.`Id`, `l1`.`CapitalName`, `l1`.`Name`, `l1`.`ServerAddress`, `l1`.`CommanderName`, `l1`.`Eradicated` + SELECT `l1`.`Id`, `l1`.`CapitalName`, `l1`.`Name`, `l1`.`ServerAddress`, `l1`.`CommanderName`, `l1`.`DeputyCommanderName`, `l1`.`Eradicated` FROM `LocustHordes` AS `l1` WHERE `l1`.`Name` = 'Swarm' ) AS `l2` ON `u`.`Name` = `l2`.`CommanderName` -WHERE (`l2`.`Eradicated` = FALSE) OR (`l2`.`Eradicated` IS NULL) +WHERE (`l2`.`Eradicated` <> TRUE) OR (`l2`.`Eradicated` IS NULL) """); } @@ -6985,7 +6215,7 @@ public override async Task Include_on_derived_type_with_order_by_and_paging(bool AssertSql( """ -@__p_0='10' +@p='10' SELECT `s`.`Name`, `s`.`LocustHordeId`, `s`.`ThreatLevel`, `s`.`ThreatLevelByte`, `s`.`ThreatLevelNullableByte`, `s`.`DefeatedByNickname`, `s`.`DefeatedBySquadId`, `s`.`HighCommandId`, `s`.`Discriminator`, `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator0` AS `Discriminator`, `s`.`Id`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( @@ -7006,7 +6236,7 @@ UNION ALL ) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) LEFT JOIN `Tags` AS `t` ON ((`u0`.`Nickname` = `t`.`GearNickName`) OR (`u0`.`Nickname` IS NULL AND (`t`.`GearNickName` IS NULL))) AND ((`u0`.`SquadId` = `t`.`GearSquadId`) OR (`u0`.`SquadId` IS NULL AND (`t`.`GearSquadId` IS NULL))) ORDER BY `t`.`Note` - LIMIT @__p_0 + LIMIT @p ) AS `s` LEFT JOIN `Weapons` AS `w` ON `s`.`FullName` = `w`.`OwnerFullName` ORDER BY `s`.`Note`, `s`.`Name`, `s`.`Nickname`, `s`.`SquadId`, `s`.`Id` @@ -8107,7 +7337,7 @@ public override async Task Select_subquery_distinct_singleordefault_boolean2(boo AssertSql( """ SELECT COALESCE(( - SELECT DISTINCT `w`.`IsAutomatic` + SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') LIMIT 1), FALSE) @@ -8181,7 +7411,7 @@ public override async Task Select_subquery_distinct_singleordefault_boolean_empt AssertSql( """ SELECT COALESCE(( - SELECT DISTINCT `w`.`IsAutomatic` + SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') LIMIT 1), FALSE) @@ -8440,17 +7670,6 @@ CROSS JOIN `Missions` AS `m` """); } - public override async Task Time_of_day_datetimeoffset(bool async) - { - await base.Time_of_day_datetimeoffset(async); - - AssertSql( -""" -SELECT CAST(`m`.`Timeline` AS time(6)) -FROM `Missions` AS `m` -"""); - } - public override async Task GroupBy_Property_Include_Select_Average(bool async) { await base.GroupBy_Property_Include_Select_Average(async); @@ -8746,8 +7965,9 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` ORDER BY CASE - WHEN `u`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`u`.`Nickname`) = 5 -END IS NOT NULL + WHEN `u`.`LeaderNickname` IS NOT NULL THEN TRUE + ELSE FALSE +END """); } @@ -8909,25 +8129,6 @@ UNION ALL """); } - public override async Task Filter_with_new_Guid(bool async) - { - await base.Filter_with_new_Guid(async); - - AssertSql( -""" -SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` -FROM `Tags` AS `t` -WHERE `t`.`Id` = 'df36f493-463f-4123-83f9-6b135deeb7ba' -"""); - } - - public override async Task Filter_with_new_Guid_closure(bool async) - { - await base.Filter_with_new_Guid_closure(async); - - AssertSql(); - } - public override async Task OfTypeNav1(bool async) { await base.OfTypeNav1(async); @@ -9014,7 +8215,7 @@ public override async Task Nav_rewrite_with_convert2(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated` FROM `LocustHordes` AS `l` LEFT JOIN `Cities` AS `c` ON `l`.`CapitalName` = `c`.`Name` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` @@ -9028,7 +8229,7 @@ public override async Task Nav_rewrite_with_convert3(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated` FROM `LocustHordes` AS `l` LEFT JOIN `Cities` AS `c` ON `l`.`CapitalName` = `c`.`Name` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` @@ -9095,7 +8296,7 @@ public override async Task Anonymous_projection_take_followed_by_projecting_sing AssertSql( """ -@__p_0='25' +@p='25' SELECT `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId` FROM ( @@ -9107,7 +8308,7 @@ UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` ) AS `u` - LIMIT @__p_0 + LIMIT @p ) AS `u0` LEFT JOIN ( SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` @@ -9176,12 +8377,13 @@ FROM JSON_TABLE('["1902-01-02T10:00:00.1234567+01:30"]', '$[*]' COLUMNS ( { AssertSql( """ -@__start_0='1902-01-01T08:30:00.1234560+00:00' -@__end_1='1902-01-03T08:30:00.1234560+00:00' +@start='1902-01-01T08:30:00.1234560+00:00' +@end='1902-01-03T08:30:00.1234560+00:00' +@dates1='1902-01-02T08:30:00.1234560+00:00' -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` -WHERE ((@__start_0 <= CONVERT(`m`.`Timeline`, date)) AND (`m`.`Timeline` < @__end_1)) AND (`m`.`Timeline` = TIMESTAMP '1902-01-02 08:30:00.123456') +WHERE ((@start <= CONVERT(`m`.`Timeline`, date)) AND (`m`.`Timeline` < @end)) AND (`m`.`Timeline` = @dates1) """); } } @@ -9351,7 +8553,7 @@ public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_th AssertSql( """ -@__isAutomatic_0='True' +@isAutomatic='True' SELECT `u`.`Nickname`, `u`.`FullName`, `w0`.`Id` IS NOT NULL AS `Collection` FROM ( @@ -9364,7 +8566,7 @@ UNION ALL LEFT JOIN ( SELECT `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` - WHERE `w`.`IsAutomatic` = @__isAutomatic_0 + WHERE `w`.`IsAutomatic` = @isAutomatic ) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` """); } @@ -9423,7 +8625,7 @@ public override async Task Navigation_based_on_complex_expression1(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` WHERE `l0`.`Name` IS NOT NULL @@ -9436,7 +8638,7 @@ public override async Task Navigation_based_on_complex_expression2(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` WHERE `l0`.`Name` IS NOT NULL @@ -9655,7 +8857,7 @@ public override async Task Query_reusing_parameter_doesnt_declare_duplicate_para AssertSql( """ -@__prm_Inner_Nickname_0='Marcus' (Size = 255) +@prm_Inner_Nickname='Marcus' (Size = 255) SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( @@ -9667,7 +8869,7 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` - WHERE `u`.`Nickname` <> @__prm_Inner_Nickname_0 + WHERE `u`.`Nickname` <> @prm_Inner_Nickname ) AS `u0` ORDER BY `u0`.`FullName` """); @@ -9679,7 +8881,7 @@ public override async Task Query_reusing_parameter_with_inner_query_doesnt_decla AssertSql( """ -@__squadId_0='1' +@squadId='1' SELECT `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM ( @@ -9695,7 +8897,7 @@ UNION ALL WHERE `s`.`Id` IN ( SELECT `s0`.`Id` FROM `Squads` AS `s0` - WHERE `s0`.`Id` = @__squadId_0 + WHERE `s0`.`Id` = @squadId ) UNION ALL SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` @@ -9710,7 +8912,7 @@ UNION ALL WHERE `s1`.`Id` IN ( SELECT `s2`.`Id` FROM `Squads` AS `s2` - WHERE `s2`.`Id` = @__squadId_0 + WHERE `s2`.`Id` = @squadId ) ) AS `u1` ORDER BY `u1`.`FullName` @@ -9723,7 +8925,7 @@ public override async Task Query_reusing_parameter_with_inner_query_expression_d AssertSql( """ -@__gearId_0='1' +@gearId='1' SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` FROM `Squads` AS `s` @@ -9736,7 +8938,7 @@ UNION ALL SELECT `o`.`SquadId` FROM `Officers` AS `o` ) AS `u` - WHERE ((`s`.`Id` = `u`.`SquadId`) AND (`u`.`SquadId` = @__gearId_0)) AND (`u`.`SquadId` = @__gearId_0)) + WHERE ((`s`.`Id` = `u`.`SquadId`) AND (`u`.`SquadId` = @gearId)) AND (`u`.`SquadId` = @gearId)) """); } @@ -9746,7 +8948,7 @@ public override async Task Query_reusing_parameter_doesnt_declare_duplicate_para AssertSql( """ -@__entity_equality_prm_Inner_Squad_0_Id='1' (Nullable = true) +@entity_equality_prm_Inner_Squad_Id='1' (Nullable = true) SELECT `s1`.`Nickname`, `s1`.`SquadId`, `s1`.`AssignedCityName`, `s1`.`CityOfBirthName`, `s1`.`FullName`, `s1`.`HasSoulPatch`, `s1`.`LeaderNickname`, `s1`.`LeaderSquadId`, `s1`.`Rank`, `s1`.`Discriminator` FROM ( @@ -9759,10 +8961,10 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` - WHERE `s`.`Id` = @__entity_equality_prm_Inner_Squad_0_Id + WHERE `s`.`Id` = @entity_equality_prm_Inner_Squad_Id ) AS `s1` INNER JOIN `Squads` AS `s0` ON `s1`.`SquadId` = `s0`.`Id` -WHERE `s0`.`Id` = @__entity_equality_prm_Inner_Squad_0_Id +WHERE `s0`.`Id` = @entity_equality_prm_Inner_Squad_Id ORDER BY `s1`.`FullName` """); } @@ -9989,9 +9191,9 @@ public override async Task Select_null_parameter_is_not_null(bool async) AssertSql( """ -@__p_0='False' +@p='False' -SELECT @__p_0 +SELECT @p FROM ( SELECT 1 FROM `Gears` AS `g` @@ -10008,7 +9210,7 @@ public override async Task Where_null_parameter_is_not_null(bool async) AssertSql( """ -@__p_0='False' +@p='False' SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -10018,7 +9220,7 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` -WHERE @__p_0 +WHERE @p """); } @@ -10087,7 +9289,7 @@ public override async Task Where_with_enum_flags_parameter(bool async) AssertSql( """ -@__rank_0='1' (Nullable = true) +@rank='1' (Nullable = true) SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -10097,7 +9299,7 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` -WHERE CAST(`u`.`Rank` & @__rank_0 AS signed) = @__rank_0 +WHERE CAST(`u`.`Rank` & @rank AS signed) = @rank """, // """ @@ -10112,7 +9314,7 @@ UNION ALL """, // """ -@__rank_0='2' (Nullable = true) +@rank='2' (Nullable = true) SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -10122,7 +9324,7 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` -WHERE CAST(`u`.`Rank` | @__rank_0 AS signed) <> @__rank_0 +WHERE CAST(`u`.`Rank` | @rank AS signed) <> @rank """, // """ @@ -10185,7 +9387,7 @@ public override async Task Bitwise_operation_with_non_null_parameter_optimizes_n AssertSql( """ -@__ranks_0='134' +@ranks='134' SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -10195,13 +9397,13 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` -WHERE CAST(`u`.`Rank` & @__ranks_0 AS signed) <> 0 +WHERE CAST(`u`.`Rank` & @ranks AS signed) <> 0 """, // """ -@__ranks_0='134' +@ranks='134' -SELECT CAST(`u`.`Rank` | @__ranks_0 AS signed) = @__ranks_0 +SELECT CAST(`u`.`Rank` | @ranks AS signed) = @ranks FROM ( SELECT `g`.`Rank` FROM `Gears` AS `g` @@ -10212,9 +9414,9 @@ UNION ALL """, // """ -@__ranks_0='134' +@ranks='134' -SELECT CAST(`u`.`Rank` | CAST(`u`.`Rank` | CAST(@__ranks_0 | CAST(`u`.`Rank` | @__ranks_0 AS signed) AS signed) AS signed) AS signed) = @__ranks_0 +SELECT CAST(`u`.`Rank` | CAST(`u`.`Rank` | CAST(@ranks | CAST(`u`.`Rank` | @ranks AS signed) AS signed) AS signed) AS signed) = @ranks FROM ( SELECT `g`.`Rank` FROM `Gears` AS `g` @@ -10254,19 +9456,19 @@ public override async Task Bitwise_operation_with_null_arguments(bool async) """, // """ -@__prm_0='2' (Nullable = true) +@prm='2' (Nullable = true) SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE (CAST(`w`.`AmmunitionType` & @__prm_0 AS signed) <> 0) OR `w`.`AmmunitionType` IS NULL +WHERE (CAST(`w`.`AmmunitionType` & @prm AS signed) <> 0) OR `w`.`AmmunitionType` IS NULL """, // """ -@__prm_0='1' (Nullable = true) +@prm='1' (Nullable = true) SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE CAST(`w`.`AmmunitionType` & @__prm_0 AS signed) = @__prm_0 +WHERE CAST(`w`.`AmmunitionType` & @prm AS signed) = @prm """); } @@ -10276,7 +9478,7 @@ public override async Task Logical_operation_with_non_null_parameter_optimizes_n AssertSql( """ -@__prm_0='True' +@prm='True' SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -10286,11 +9488,11 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` -WHERE `u`.`HasSoulPatch` <> @__prm_0 +WHERE `u`.`HasSoulPatch` <> @prm """, // """ -@__prm_0='False' +@prm='False' SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -10300,7 +9502,7 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` -WHERE `u`.`HasSoulPatch` <> @__prm_0 +WHERE `u`.`HasSoulPatch` <> @prm """); } @@ -10334,78 +9536,12 @@ UNION ALL INNER JOIN `LocustHordes` AS `l1` ON `u`.`Name` = `l1`.`CommanderName` WHERE (CASE WHEN `l1`.`Name` = 'Locust' THEN TRUE -END = FALSE) OR (CASE +END <> TRUE) OR (CASE WHEN `l1`.`Name` = 'Locust' THEN TRUE END IS NULL) """); } - public override async Task Byte_array_contains_literal(bool async) - { - await base.Byte_array_contains_literal(async); - - AssertSql( -""" -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` -FROM `Squads` AS `s` -WHERE LOCATE(0x01, `s`.`Banner`) > 0 -"""); - } - - public override async Task Byte_array_filter_by_length_literal(bool async) - { - await base.Byte_array_filter_by_length_literal(async); - - AssertSql( -""" -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` -FROM `Squads` AS `s` -WHERE LENGTH(`s`.`Banner`) = 2 -"""); - } - - public override async Task Byte_array_filter_by_length_parameter(bool async) - { - await base.Byte_array_filter_by_length_parameter(async); - - AssertSql( -""" -@__p_0='2' - -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` -FROM `Squads` AS `s` -WHERE LENGTH(`s`.`Banner`) = @__p_0 -"""); - } - - public override void Byte_array_filter_by_length_parameter_compiled() - { - base.Byte_array_filter_by_length_parameter_compiled(); - - AssertSql( -""" -@__byteArrayParam='0x2A80' (Size = 8000) - -SELECT COUNT(*) -FROM `Squads` AS `s` -WHERE LENGTH(`s`.`Banner`) = LENGTH(@__byteArrayParam) -"""); - } - - public override async Task Byte_array_contains_parameter(bool async) - { - await base.Byte_array_contains_parameter(async); - - AssertSql( -""" -@__someByte_0='1' - -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` -FROM `Squads` AS `s` -WHERE LOCATE(UNHEX(HEX(@__someByte_0)), `s`.`Banner`) > 0 -"""); - } - public override async Task Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(bool async) { await base.Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(async); @@ -10424,7 +9560,7 @@ public override async Task Conditional_expression_with_test_being_simplified_to_ AssertSql( """ -@__prm_0='True' +@prm='True' SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -10435,7 +9571,7 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` WHERE CASE - WHEN `u`.`HasSoulPatch` = @__prm_0 THEN TRUE + WHEN `u`.`HasSoulPatch` = @prm THEN TRUE ELSE FALSE END """); @@ -10447,8 +9583,8 @@ public override async Task Conditional_expression_with_test_being_simplified_to_ AssertSql( """ -@__prm_0='True' -@__prm2_1='Marcus' Lancer' (Size = 4000) +@prm='True' +@prm2='Marcus' Lancer' (Size = 4000) SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -10459,11 +9595,11 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` WHERE CASE - WHEN `u`.`HasSoulPatch` = @__prm_0 THEN ( + WHEN `u`.`HasSoulPatch` = @prm THEN ( SELECT `w`.`Name` FROM `Weapons` AS `w` WHERE `w`.`Id` = `u`.`SquadId` - LIMIT 1) = @__prm2_1 + LIMIT 1) = @prm2 ELSE FALSE END """); @@ -10488,11 +9624,11 @@ public override async Task DateTimeOffset_Date_returns_datetime(bool async) AssertSql( """ -@__dateTimeOffset_Date_0='0002-03-01T00:00:00.0000000' (DbType = DateTime) +@dateTimeOffset_Date='0002-03-01T00:00:00.0000000' (DbType = DateTime) SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` -WHERE CONVERT(`m`.`Timeline`, date) >= @__dateTimeOffset_Date_0 +WHERE CONVERT(`m`.`Timeline`, date) >= @dateTimeOffset_Date """); } @@ -10547,20 +9683,6 @@ UNION ALL """); } - public override async Task Byte_array_filter_by_SequenceEqual(bool isAsync) - { - await base.Byte_array_filter_by_SequenceEqual(isAsync); - - AssertSql( -""" -@__byteArrayParam_0='0x0405060708' (Size = 5) - -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` -FROM `Squads` AS `s` -WHERE `s`.`Banner5` = @__byteArrayParam_0 -"""); - } - public override async Task Group_by_nullable_property_HasValue_and_project_the_grouping_key(bool async) { await base.Group_by_nullable_property_HasValue_and_project_the_grouping_key(async); @@ -10596,123 +9718,31 @@ public override async Task Checked_context_with_cast_does_not_fail(bool isAsync) """ SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( - SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` - FROM `LocustLeaders` AS `l` - UNION ALL - SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` - FROM `LocustCommanders` AS `l0` -) AS `u` -WHERE CAST(`u`.`ThreatLevel` AS unsigned) >= 5 -"""); - } - - public override async Task Checked_context_with_addition_does_not_fail(bool isAsync) - { - await base.Checked_context_with_addition_does_not_fail(isAsync); - - AssertSql( -""" -SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` -FROM ( - SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` - FROM `LocustLeaders` AS `l` - UNION ALL - SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` - FROM `LocustCommanders` AS `l0` -) AS `u` -WHERE CAST(`u`.`ThreatLevel` AS signed) <= (5 + CAST(`u`.`ThreatLevel` AS signed)) -"""); - } - - public override async Task TimeSpan_Hours(bool async) - { - await base.TimeSpan_Hours(async); - - AssertSql( -""" -SELECT EXTRACT(hour FROM `m`.`Duration`) -FROM `Missions` AS `m` -"""); - } - - public override async Task TimeSpan_Minutes(bool async) - { - await base.TimeSpan_Minutes(async); - - AssertSql( -""" -SELECT EXTRACT(minute FROM `m`.`Duration`) -FROM `Missions` AS `m` -"""); - } - - public override async Task TimeSpan_Seconds(bool async) - { - await base.TimeSpan_Seconds(async); - - AssertSql( -""" -SELECT EXTRACT(second FROM `m`.`Duration`) -FROM `Missions` AS `m` -"""); - } - - public override async Task TimeSpan_Milliseconds(bool async) - { - await base.TimeSpan_Milliseconds(async); - - AssertSql( -""" -SELECT (EXTRACT(microsecond FROM `m`.`Duration`)) DIV (1000) -FROM `Missions` AS `m` -"""); - } - - public override async Task Where_TimeSpan_Hours(bool async) - { - await base.Where_TimeSpan_Hours(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(hour FROM `m`.`Duration`) = 1 -"""); - } - - public override async Task Where_TimeSpan_Minutes(bool async) - { - await base.Where_TimeSpan_Minutes(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(minute FROM `m`.`Duration`) = 2 -"""); - } - - public override async Task Where_TimeSpan_Seconds(bool async) - { - await base.Where_TimeSpan_Seconds(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(second FROM `m`.`Duration`) = 3 + SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` + FROM `LocustLeaders` AS `l` + UNION ALL + SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` + FROM `LocustCommanders` AS `l0` +) AS `u` +WHERE CAST(`u`.`ThreatLevel` AS unsigned) >= 5 """); } - public override async Task Where_TimeSpan_Milliseconds(bool async) + public override async Task Checked_context_with_addition_does_not_fail(bool isAsync) { - await base.Where_TimeSpan_Milliseconds(async); + await base.Checked_context_with_addition_does_not_fail(isAsync); AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE (EXTRACT(microsecond FROM `m`.`Duration`)) DIV (1000) = 456 +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` +FROM ( + SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` + FROM `LocustLeaders` AS `l` + UNION ALL + SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` + FROM `LocustCommanders` AS `l0` +) AS `u` +WHERE CAST(`u`.`ThreatLevel` AS signed) <= (5 + CAST(`u`.`ThreatLevel` AS signed)) """); } @@ -10821,25 +9851,6 @@ UNION ALL """); } - public override async Task Contains_on_byte_array_property_using_byte_column(bool async) - { - await base.Contains_on_byte_array_property_using_byte_column(async); - - AssertSql( -""" -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` -FROM `Squads` AS `s` -CROSS JOIN ( - SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` - FROM `LocustLeaders` AS `l` - UNION ALL - SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` - FROM `LocustCommanders` AS `l0` -) AS `u` -WHERE LOCATE(UNHEX(HEX(`u`.`ThreatLevelByte`)), `s`.`Banner`) > 0 -"""); - } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion( bool async) { @@ -10990,11 +10001,11 @@ public override async Task Enum_closure_typed_as_underlying_type_generates_corre AssertSql( """ -@__prm_0='1' (Nullable = true) +@prm='1' (Nullable = true) SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE @__prm_0 = `w`.`AmmunitionType` +WHERE @prm = `w`.`AmmunitionType` """); } @@ -11004,7 +10015,7 @@ public override async Task Enum_flags_closure_typed_as_underlying_type_generates AssertSql( """ -@__prm_0='133' +@prm='133' SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -11014,7 +10025,7 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` -WHERE CAST(@__prm_0 & `u`.`Rank` AS signed) = `u`.`Rank` +WHERE CAST(@prm & `u`.`Rank` AS signed) = `u`.`Rank` """); } @@ -11024,7 +10035,7 @@ public override async Task Enum_flags_closure_typed_as_different_type_generates_ AssertSql( """ -@__prm_0='5' +@prm='5' SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -11034,7 +10045,7 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` -WHERE CAST(@__prm_0 & CAST(`u`.`Rank` AS signed) AS signed) = CAST(`u`.`Rank` AS signed) +WHERE CAST(@prm & CAST(`u`.`Rank` AS signed) AS signed) = CAST(`u`.`Rank` AS signed) """); } @@ -11044,7 +10055,7 @@ public override async Task Constant_enum_with_same_underlying_value_as_previousl AssertSql( """ -@__p_0='1' +@p='1' SELECT CAST(`u`.`Rank` & 1 AS signed) FROM ( @@ -11055,7 +10066,7 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` ORDER BY `u`.`Nickname` -LIMIT @__p_0 +LIMIT @p """); } @@ -11083,10 +10094,12 @@ FROM JSON_TABLE('[null,1]', '$[*]' COLUMNS ( { AssertSql( """ +@types1='1' + SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` LEFT JOIN `Weapons` AS `w0` ON `w`.`SynergyWithId` = `w0`.`Id` -WHERE `w0`.`Id` IS NOT NULL AND (`w0`.`AmmunitionType` IS NULL OR (`w0`.`AmmunitionType` = 1)) +WHERE `w0`.`Id` IS NOT NULL AND (`w0`.`AmmunitionType` IS NULL OR (`w0`.`AmmunitionType` = @types1)) """); } } @@ -11429,30 +10442,6 @@ LEFT JOIN ( """); } - public override async Task First_on_byte_array(bool async) - { - await base.First_on_byte_array(async); - - AssertSql( -""" -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` -FROM `Squads` AS `s` -WHERE ASCII(`s`.`Banner`) = 2 -"""); - } - - public override async Task Array_access_on_byte_array(bool async) - { - await base.Array_access_on_byte_array(async); - - AssertSql( -""" -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` -FROM `Squads` AS `s` -WHERE ASCII(SUBSTRING(`s`.`Banner5`, 2 + 1, 1)) = 6 -"""); - } - public override async Task Project_shadow_properties(bool async) { await base.Project_shadow_properties(async); @@ -11761,286 +10750,82 @@ SELECT CASE LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId` - FROM `Officers` AS `o` -) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) -WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` -END IS NOT NULL -ORDER BY `t`.`Note` -"""); - } - - public override async Task Projecting_property_converted_to_nullable_into_unary(bool async) - { - await base.Projecting_property_converted_to_nullable_into_unary(async); - - AssertSql( -""" -SELECT `t`.`Note` -FROM `Tags` AS `t` -LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` - FROM `Officers` AS `o` -) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) -WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` -END IS NOT NULL AND NOT (CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`HasSoulPatch` -END) -ORDER BY `t`.`Note` -"""); - } - - public override async Task Projecting_property_converted_to_nullable_into_member_access(bool async) - { - await base.Projecting_property_converted_to_nullable_into_member_access(async); - - AssertSql( -""" -SELECT `u`.`Nickname` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`CityOfBirthName` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`CityOfBirthName` - FROM `Officers` AS `o` -) AS `u` -LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) -WHERE (EXTRACT(month FROM `t`.`IssueDate`) <> 5) OR EXTRACT(month FROM `t`.`IssueDate`) IS NULL -ORDER BY `u`.`Nickname` -"""); - } - - public override async Task Projecting_property_converted_to_nullable_and_use_it_in_order_by(bool async) - { - await base.Projecting_property_converted_to_nullable_and_use_it_in_order_by(async); - - AssertSql( -""" -SELECT `t`.`Note`, `t`.`GearNickName` IS NOT NULL, `u`.`Nickname`, `u`.`SquadId`, `u`.`HasSoulPatch` -FROM `Tags` AS `t` -LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` - FROM `Officers` AS `o` -) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) -WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` -END IS NOT NULL -ORDER BY CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` -END, `t`.`Note` -"""); - } - - public override async Task Where_DateOnly_Year(bool async) - { - await base.Where_DateOnly_Year(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(year FROM `m`.`Date`) = 1990 -"""); - } - - public override async Task Where_DateOnly_Month(bool async) - { - await base.Where_DateOnly_Month(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(month FROM `m`.`Date`) = 11 -"""); - } - - public override async Task Where_DateOnly_Day(bool async) - { - await base.Where_DateOnly_Day(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(day FROM `m`.`Date`) = 10 -"""); - } - - public override async Task Where_DateOnly_DayOfYear(bool async) - { - await base.Where_DateOnly_DayOfYear(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE DAYOFYEAR(`m`.`Date`) = 314 -"""); - } - - public override async Task Where_DateOnly_DayOfWeek(bool async) - { - await base.Where_DateOnly_DayOfWeek(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE (DAYOFWEEK(`m`.`Date`) - 1) = 6 -"""); - } - - public override async Task Where_DateOnly_AddYears(bool async) - { - await base.Where_DateOnly_AddYears(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE DATE_ADD(`m`.`Date`, INTERVAL CAST(3 AS signed) year) = DATE '1993-11-10' -"""); - } - - public override async Task Where_DateOnly_AddMonths(bool async) - { - await base.Where_DateOnly_AddMonths(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE DATE_ADD(`m`.`Date`, INTERVAL CAST(3 AS signed) month) = DATE '1991-02-10' -"""); - } - - public override async Task Where_DateOnly_AddDays(bool async) - { - await base.Where_DateOnly_AddDays(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE DATE_ADD(`m`.`Date`, INTERVAL CAST(3 AS signed) day) = DATE '1990-11-13' -"""); - } - - public override async Task Where_TimeOnly_Hour(bool async) - { - await base.Where_TimeOnly_Hour(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(hour FROM `m`.`Time`) = 10 -"""); - } - - public override async Task Where_TimeOnly_Minute(bool async) - { - await base.Where_TimeOnly_Minute(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(minute FROM `m`.`Time`) = 15 -"""); - } - - public override async Task Where_TimeOnly_Second(bool async) - { - await base.Where_TimeOnly_Second(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(second FROM `m`.`Time`) = 50 -"""); - } - - public override async Task Where_TimeOnly_Millisecond(bool async) - { - await base.Where_TimeOnly_Millisecond(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE (EXTRACT(microsecond FROM `m`.`Time`)) DIV (1000) = 500 -"""); - } - - public override async Task Where_TimeOnly_AddHours(bool async) - { - await base.Where_TimeOnly_AddHours(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE DATE_ADD(`m`.`Time`, INTERVAL CAST(3.0 AS signed) hour) = TIME '13:15:50.5' -"""); - } - - public override async Task Where_TimeOnly_AddMinutes(bool async) - { - await base.Where_TimeOnly_AddMinutes(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE DATE_ADD(`m`.`Time`, INTERVAL CAST(3.0 AS signed) minute) = TIME '10:18:50.5' + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId` + FROM `Officers` AS `o` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE CASE + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` +END IS NOT NULL +ORDER BY `t`.`Note` """); } - public override async Task Where_TimeOnly_Add_TimeSpan(bool async) + public override async Task Projecting_property_converted_to_nullable_into_unary(bool async) { - await base.Where_TimeOnly_Add_TimeSpan(async); + await base.Projecting_property_converted_to_nullable_into_unary(async); AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE (`m`.`Time` + TIME '03:00:00') = TIME '13:15:50.5' +SELECT `t`.`Note` +FROM `Tags` AS `t` +LEFT JOIN ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` + FROM `Officers` AS `o` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE CASE + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` +END IS NOT NULL AND NOT (CASE + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`HasSoulPatch` +END) +ORDER BY `t`.`Note` """); } - public override async Task Where_TimeOnly_IsBetween(bool async) + public override async Task Projecting_property_converted_to_nullable_into_member_access(bool async) { - await base.Where_TimeOnly_IsBetween(async); + await base.Projecting_property_converted_to_nullable_into_member_access(async); AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE (`m`.`Time` >= TIME '10:00:00') & (`m`.`Time` < TIME '11:00:00') +SELECT `u`.`Nickname` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`CityOfBirthName` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`CityOfBirthName` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +WHERE (EXTRACT(month FROM `t`.`IssueDate`) <> 5) OR EXTRACT(month FROM `t`.`IssueDate`) IS NULL +ORDER BY `u`.`Nickname` """); } - public override async Task Where_TimeOnly_subtract_TimeOnly(bool async) + public override async Task Projecting_property_converted_to_nullable_and_use_it_in_order_by(bool async) { - await base.Where_TimeOnly_subtract_TimeOnly(async); + await base.Projecting_property_converted_to_nullable_and_use_it_in_order_by(async); AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE (`m`.`Time` - TIME '10:00:00') = TIME '00:15:50.5' +SELECT `t`.`Note`, `t`.`GearNickName` IS NOT NULL, `u`.`Nickname`, `u`.`SquadId`, `u`.`HasSoulPatch` +FROM `Tags` AS `t` +LEFT JOIN ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` + FROM `Officers` AS `o` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE CASE + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` +END IS NOT NULL +ORDER BY CASE + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` +END, `t`.`Note` """); } @@ -12070,7 +10855,7 @@ public override async Task Project_navigation_defined_on_derived_from_entity_wit AssertSql( """ -SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u0`.`Nickname` IS NULL OR (`u0`.`SquadId` IS NULL) AS `IsNull`, `l1`.`Id`, `l1`.`CapitalName`, `l1`.`Name`, `l1`.`ServerAddress`, `l1`.`CommanderName`, `l1`.`Eradicated`, `l1`.`Id` IS NULL AS `IsNull`, `l2`.`Id`, `l2`.`IsOperational`, `l2`.`Name`, `l2`.`Id` IS NULL AS `IsNull` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u0`.`Nickname` IS NULL OR (`u0`.`SquadId` IS NULL) AS `IsNull`, `l1`.`Id`, `l1`.`CapitalName`, `l1`.`Name`, `l1`.`ServerAddress`, `l1`.`CommanderName`, `l1`.`DeputyCommanderName`, `l1`.`Eradicated`, `l1`.`Id` IS NULL AS `IsNull`, `l2`.`Id`, `l2`.`IsOperational`, `l2`.`Name`, `l2`.`Id` IS NULL AS `IsNull` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` @@ -12096,8 +10881,8 @@ public override async Task Join_entity_with_itself_grouped_by_key_followed_by_in AssertSql( """ -@__p_1='10' -@__p_0='0' +@p0='10' +@p='0' SELECT `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator`, `s`.`HasSoulPatch0`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( @@ -12122,7 +10907,7 @@ UNION ALL GROUP BY `u0`.`HasSoulPatch` ) AS `u1` ON CHAR_LENGTH(`u`.`Nickname`) = `u1`.`c` ORDER BY `u`.`Nickname` - LIMIT @__p_1 OFFSET @__p_0 + LIMIT @p0 OFFSET @p ) AS `s` LEFT JOIN `Weapons` AS `w` ON `s`.`FullName` = `w`.`OwnerFullName` ORDER BY `s`.`Nickname`, `s`.`SquadId`, `s`.`HasSoulPatch0` @@ -12158,6 +10943,9 @@ FROM JSON_TABLE('[false,true]', '$[*]' COLUMNS ( { AssertSql( """ +@values1='False' +@values2='True' + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -12166,7 +10954,7 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` -WHERE (`u`.`HasSoulPatch` = TRUE) AND `u`.`HasSoulPatch` IN (FALSE, TRUE) +WHERE (`u`.`HasSoulPatch` = TRUE) AND `u`.`HasSoulPatch` IN (@values1, @values2) """); } } @@ -12200,6 +10988,9 @@ FROM JSON_TABLE('[false,true]', '$[*]' COLUMNS ( { AssertSql( """ +@values1='False' +@values2='True' + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -12208,7 +10999,7 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `u` -WHERE (`u`.`HasSoulPatch` = TRUE) AND `u`.`HasSoulPatch` IN (FALSE, TRUE) +WHERE (`u`.`HasSoulPatch` = TRUE) AND `u`.`HasSoulPatch` IN (@values1, @values2) """); } } @@ -12219,11 +11010,11 @@ public override async Task Parameter_used_multiple_times_take_appropriate_inferr AssertSql( """ -@__place_0='Ephyra's location' (Size = 4000) +@place='Ephyra's location' (Size = 4000) SELECT `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM `Cities` AS `c` -WHERE ((`c`.`Nation` = @__place_0) OR (`c`.`Location` = @__place_0)) OR (`c`.`Location` = @__place_0) +WHERE ((`c`.`Nation` = @place) OR (`c`.`Location` = @place)) OR (`c`.`Location` = @place) """); } @@ -12233,10 +11024,10 @@ public override async Task Enum_matching_take_value_gets_different_type_mapping( AssertSql( """ -@__value_1='1' -@__p_0='1' +@value='1' +@p='1' -SELECT CAST(`u`.`Rank` & @__value_1 AS signed) +SELECT CAST(`u`.`Rank` & @value AS signed) FROM ( SELECT `g`.`Nickname`, `g`.`Rank` FROM `Gears` AS `g` @@ -12245,7 +11036,7 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` ORDER BY `u`.`Nickname` -LIMIT @__p_0 +LIMIT @p """); } @@ -12255,7 +11046,7 @@ public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_th AssertSql( """ -@__prm_0='1' +@prm='1' SELECT `u`.`Nickname`, `u`.`FullName`, `w0`.`Id` IS NOT NULL AS `Collection` FROM ( @@ -12268,7 +11059,7 @@ UNION ALL LEFT JOIN ( SELECT `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` - WHERE `w`.`Id` > @__prm_0 + WHERE `w`.`Id` > @prm ) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` """); } @@ -12301,17 +11092,6 @@ LEFT JOIN ( """); } - public override async Task DateTimeOffset_DateAdd_AddYears(bool async) - { - await base.DateTimeOffset_DateAdd_AddYears(async); - - AssertSql( -""" -SELECT DATE_ADD(`m`.`Timeline`, INTERVAL CAST(1 AS signed) year) -FROM `Missions` AS `m` -"""); - } - public override async Task Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(bool async) { await base.Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(async); @@ -12382,7 +11162,7 @@ public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_th AssertSql( """ -@__isAutomatic_0='True' +@isAutomatic='True' SELECT `u`.`Nickname`, `u`.`FullName`, `w0`.`Id` IS NOT NULL AS `Collection` FROM ( @@ -12395,7 +11175,7 @@ UNION ALL LEFT JOIN ( SELECT `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` - WHERE `w`.`IsAutomatic` <> @__isAutomatic_0 + WHERE `w`.`IsAutomatic` <> @isAutomatic ) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` """); } @@ -12434,7 +11214,7 @@ public override async Task Comparison_with_value_converted_subclass(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated` FROM `LocustHordes` AS `l` WHERE `l`.`ServerAddress` = CAST('127.0.0.1' AS char) """); @@ -12509,17 +11289,6 @@ SELECT COALESCE(SUM(`m`.`Rating`), 0.0) """); } - public override async Task ToString_guid_property_projection(bool async) - { - await base.ToString_guid_property_projection(async); - - AssertSql( -""" -SELECT `t`.`GearNickName` AS `A`, CAST(`t`.`Id` AS char) AS `B` -FROM `Tags` AS `t` -"""); - } - public override async Task Correlated_collection_with_distinct_not_projecting_identifier_column(bool async) { await base.Correlated_collection_with_distinct_not_projecting_identifier_column(async); @@ -12549,7 +11318,7 @@ public override async Task Include_after_Select_throws(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `c`.`Name`, `c`.`Location`, `c`.`Nation` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated`, `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM `LocustHordes` AS `l` LEFT JOIN `Cities` AS `c` ON `l`.`CapitalName` = `c`.`Name` """); @@ -12648,7 +11417,7 @@ public override async Task Project_derivied_entity_with_convert_to_parent(bool a AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated` FROM `LocustHordes` AS `l` """); } @@ -12793,7 +11562,7 @@ public override async Task Include_on_derived_entity_with_cast(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `c`.`Name`, `c`.`Location`, `c`.`Nation` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`DeputyCommanderName`, `l`.`Eradicated`, `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM `LocustHordes` AS `l` LEFT JOIN `Cities` AS `c` ON `l`.`CapitalName` = `c`.`Name` ORDER BY `l`.`Id` @@ -13284,7 +12053,7 @@ public override async Task ElementAt_basic_with_OrderBy(bool async) AssertSql( """ -@__p_0='0' +@p='0' SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -13295,7 +12064,7 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` ORDER BY `u`.`FullName` -LIMIT 1 OFFSET @__p_0 +LIMIT 1 OFFSET @p """); } @@ -13305,7 +12074,7 @@ public override async Task ElementAtOrDefault_basic_with_OrderBy(bool async) AssertSql( """ -@__p_0='1' +@p='1' SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -13316,7 +12085,7 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` ORDER BY `u`.`FullName` -LIMIT 1 OFFSET @__p_0 +LIMIT 1 OFFSET @p """); } @@ -13326,7 +12095,7 @@ public override async Task ElementAtOrDefault_basic_with_OrderBy_parameter(bool AssertSql( """ -@__p_0='2' +@p='2' SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( @@ -13337,7 +12106,7 @@ UNION ALL FROM `Officers` AS `o` ) AS `u` ORDER BY `u`.`FullName` -LIMIT 1 OFFSET @__p_0 +LIMIT 1 OFFSET @p """); } @@ -13383,60 +12152,6 @@ public override async Task Using_indexer_on_byte_array_and_string_in_projection( """); } - public override async Task DateTimeOffset_to_unix_time_milliseconds(bool async) - { - await base.DateTimeOffset_to_unix_time_milliseconds(async); - - AssertSql( -""" -@__unixEpochMilliseconds_0='0' - -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s1`.`SquadId`, `s1`.`MissionId` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` -LEFT JOIN `SquadMissions` AS `s1` ON `s`.`Id` = `s1`.`SquadId` -WHERE NOT EXISTS ( - SELECT 1 - FROM `SquadMissions` AS `s0` - INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` - WHERE (`s`.`Id` = `s0`.`SquadId`) AND (@__unixEpochMilliseconds_0 = (TIMESTAMPDIFF(microsecond, TIMESTAMP '1970-01-01 00:00:00', `m`.`Timeline`)) DIV (1000))) -ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s1`.`SquadId` -"""); - } - - public override async Task DateTimeOffset_to_unix_time_seconds(bool async) - { - await base.DateTimeOffset_to_unix_time_seconds(async); - - AssertSql( -""" -@__unixEpochSeconds_0='0' - -SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s1`.`SquadId`, `s1`.`MissionId` -FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` -) AS `u` -INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` -LEFT JOIN `SquadMissions` AS `s1` ON `s`.`Id` = `s1`.`SquadId` -WHERE NOT EXISTS ( - SELECT 1 - FROM `SquadMissions` AS `s0` - INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` - WHERE (`s`.`Id` = `s0`.`SquadId`) AND (@__unixEpochSeconds_0 = TIMESTAMPDIFF(second, TIMESTAMP '1970-01-01 00:00:00', `m`.`Timeline`))) -ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s1`.`SquadId` -"""); - } - public override async Task Set_operator_with_navigation_in_projection_groupby_aggregate(bool async) { await base.Set_operator_with_navigation_in_projection_groupby_aggregate(async); @@ -13540,21 +12255,24 @@ public override async Task Nav_expansion_inside_Contains_argument(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +@numbers1='1' +@numbers2='-1' + +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE CASE WHEN EXISTS ( SELECT 1 FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName`) THEN 1 + WHERE `u`.`FullName` = `w`.`OwnerFullName`) THEN 1 ELSE 0 -END IN (1, -1) +END IN (@numbers1, @numbers2) """); } @@ -13564,20 +12282,23 @@ public override async Task Nav_expansion_with_member_pushdown_inside_Contains_ar AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +@weapons1='Marcus' Lancer' (Size = 4000) +@weapons2='Dom's Gnasher' (Size = 4000) + +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE ( SELECT `w`.`Name` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` - LIMIT 1) IN ('Marcus'' Lancer', 'Dom''s Gnasher') + LIMIT 1) IN (@weapons1, @weapons2) """); } @@ -13585,7 +12306,34 @@ public override async Task Subquery_inside_Take_argument(bool async) { await base.Subquery_inside_Take_argument(async); - AssertSql(""); + AssertSql( +""" +@numbers1='0' +@numbers2='1' +@numbers3='2' + +SELECT `u`.`Nickname`, `u`.`SquadId`, `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN ( + SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` + FROM ( + SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, ROW_NUMBER() OVER(PARTITION BY `w`.`OwnerFullName` ORDER BY `w`.`Id`) AS `row` + FROM `Weapons` AS `w` + ) AS `w0` + WHERE `w0`.`row` <= COALESCE(( + SELECT `n`.`Value` + FROM (SELECT @numbers1 AS `Value` UNION ALL VALUES ROW(@numbers2), ROW(@numbers3)) AS `n` + ORDER BY `n`.`Value` + LIMIT 1 OFFSET 1), 0) +) AS `w1` ON `u`.`FullName` = `w1`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `w1`.`OwnerFullName`, `w1`.`Id` +"""); } public override async Task Nav_expansion_inside_Skip_correlated_to_source(bool async) @@ -13831,7 +12579,40 @@ public override async Task Nested_contains_with_enum(bool async) { await base.Nested_contains_with_enum(async); - AssertSql(""); + AssertSql( +""" +@ranks1='1' +@key='5f221fb9-66f4-442a-92c9-d97ed5989cc7' +@keys1='0a47bcb7-a1cb-4345-8944-c58f82d6aac7' +@keys2='5f221fb9-66f4-442a-92c9-d97ed5989cc7' + +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +WHERE CASE + WHEN `u`.`Rank` = @ranks1 THEN @key + ELSE @key +END IN (@keys1, @keys2) +""", + // + """ +@ammoTypes1='1' +@key='5f221fb9-66f4-442a-92c9-d97ed5989cc7' +@keys1='0a47bcb7-a1cb-4345-8944-c58f82d6aac7' +@keys2='5f221fb9-66f4-442a-92c9-d97ed5989cc7' + +SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +FROM `Weapons` AS `w` +WHERE CASE + WHEN `w`.`AmmunitionType` = @ammoTypes1 THEN @key + ELSE @key +END IN (@keys1, @keys2) +"""); } public override async Task ToString_boolean_computed_nullable(bool async) @@ -13860,117 +12641,6 @@ public override async Task Select_inverted_nullable_boolean(bool async) """); } - public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool async) - { - await base.Where_TimeOnly_FromDateTime_compared_to_property(async); - - AssertSql( -""" -SELECT `t`.`Id` AS `TagId`, `m`.`Id` AS `MissionId` -FROM `Tags` AS `t` -CROSS JOIN `Missions` AS `m` -WHERE TIME(`t`.`IssueDate`) = `m`.`Time` -"""); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(bool async) - { - await base.Where_TimeOnly_FromDateTime_compared_to_parameter(async); - - AssertSql( -""" -@__time_0='02:00' (DbType = Time) - -SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` -FROM `Tags` AS `t` -LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId` - FROM `Officers` AS `o` -) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) -WHERE (`u`.`Nickname` IS NOT NULL AND (`u`.`SquadId` IS NOT NULL)) AND (TIME(DATE_ADD(`t`.`IssueDate`, INTERVAL CAST(CAST(`u`.`SquadId` AS double) AS signed) hour)) = @__time_0) -"""); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool async) - { - await base.Where_TimeOnly_FromDateTime_compared_to_constant(async); - - AssertSql( -""" -SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` -FROM `Tags` AS `t` -WHERE TIME(DATE_ADD(`t`.`IssueDate`, INTERVAL CAST(CAST(CHAR_LENGTH(`t`.`Note`) AS double) AS signed) hour)) > TIME '09:00:00' -"""); - } - - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool async) - { - await base.Where_TimeOnly_FromTimeSpan_compared_to_property(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE `m`.`Duration` < `m`.`Time` -"""); - } - - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(bool async) - { - await base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async); - - AssertSql( -""" -@__time_0='01:02' (DbType = Time) - -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE `m`.`Duration` = @__time_0 -"""); - } - - public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) - { - await base.Order_by_TimeOnly_FromTimeSpan(async); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -ORDER BY `m`.`Duration` -"""); - } - - public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool async) - { - await base.Where_DateOnly_FromDateTime_compared_to_property(async); - - AssertSql( -""" -SELECT `t`.`Id` AS `TagId`, `m`.`Id` AS `MissionId` -FROM `Tags` AS `t` -CROSS JOIN `Missions` AS `m` -WHERE DATE(`t`.`IssueDate`) > `m`.`Date` -"""); - } - - public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) - { - await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); - - AssertSql( -""" -@__prm_0='10/11/0002' (DbType = Date) - -SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` -FROM `Tags` AS `t` -WHERE DATE(`t`.`IssueDate`) IN (@__prm_0, DATE '0015-03-07') -"""); - } - // TODO: Implement once TimeSpan is translated as ticks instead of TIME. public override async Task Non_string_concat_uses_appropriate_type_mapping(bool async) { @@ -13978,6 +12648,10 @@ public override async Task Non_string_concat_uses_appropriate_type_mapping(bool Assert.Equal("Unable to cast object of type 'System.Decimal' to type 'System.TimeSpan'.", exception.Message); } + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.MySql.FunctionalTests/Query/TPCManyToManyNoTrackingQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/TPCManyToManyNoTrackingQueryMySqlTest.cs index 6da3c74f3..d1b835d9e 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/TPCManyToManyNoTrackingQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/TPCManyToManyNoTrackingQueryMySqlTest.cs @@ -92,11 +92,11 @@ public override async Task Skip_navigation_count_without_predicate(bool async) """ SELECT `e`.`Id`, `e`.`Name` FROM `EntityOnes` AS `e` -WHERE ( - SELECT COUNT(*) +WHERE EXISTS ( + SELECT 1 FROM `JoinOneSelfPayload` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`LeftId` = `e0`.`Id` - WHERE `e`.`Id` = `j`.`RightId`) > 0 + WHERE `e`.`Id` = `j`.`RightId`) """); } @@ -330,19 +330,15 @@ public override async Task Skip_navigation_order_by_single_or_default(bool async """ SELECT `s0`.`Id`, `s0`.`Name` FROM `EntityOnes` AS `e` -LEFT JOIN LATERAL ( - SELECT `s`.`Id`, `s`.`Name` +LEFT JOIN ( + SELECT `s`.`Id`, `s`.`Name`, `s`.`LeftId` FROM ( - SELECT `e0`.`Id`, `e0`.`Name` + SELECT `e0`.`Id`, `e0`.`Name`, `j`.`LeftId`, ROW_NUMBER() OVER(PARTITION BY `j`.`LeftId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneSelfPayload` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`RightId` = `e0`.`Id` - WHERE `e`.`Id` = `j`.`LeftId` - ORDER BY `e0`.`Id` - LIMIT 1 ) AS `s` - ORDER BY `s`.`Id` - LIMIT 1 -) AS `s0` ON TRUE + WHERE `s`.`row` <= 1 +) AS `s0` ON `e`.`Id` = `s0`.`LeftId` """); } @@ -519,10 +515,10 @@ public override async Task Select_many_over_skip_navigation_where(bool async) SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `EntityOnes` AS `e` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` + SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` AS `OneId0` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `s` ON `e`.`Id` = `s`.`OneId` +) AS `s` ON `e`.`Id` = `s`.`OneId0` """); } @@ -1995,10 +1991,10 @@ public override async Task Select_many_over_skip_navigation_where_non_equality(b SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `EntityOnes` AS `e` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` + SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` AS `OneId0`, `e0`.`Id` AS `Id0` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `s` ON (`e`.`Id` = `s`.`OneId`) AND (`e`.`Id` <> `s`.`Id`) +) AS `s` ON (`e`.`Id` = `s`.`OneId0`) AND (`e`.`Id` <> `s`.`Id0`) """); } @@ -2008,7 +2004,7 @@ public override async Task Contains_on_skip_collection_navigation(bool async) AssertSql( """ -@__entity_equality_two_0_Id='1' (Nullable = true) +@entity_equality_two_Id='1' (Nullable = true) SELECT `e`.`Id`, `e`.`Name` FROM `EntityOnes` AS `e` @@ -2016,7 +2012,7 @@ WHERE EXISTS ( SELECT 1 FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` - WHERE (`e`.`Id` = `j`.`OneId`) AND (`e0`.`Id` = @__entity_equality_two_0_Id)) + WHERE (`e`.`Id` = `j`.`OneId`) AND (`e0`.`Id` = @entity_equality_two_Id)) """); } @@ -2185,11 +2181,11 @@ public override async Task Skip_navigation_count_without_predicate_unidirectiona """ SELECT `u`.`Id`, `u`.`Name` FROM `UnidirectionalEntityOnes` AS `u` -WHERE ( - SELECT COUNT(*) +WHERE EXISTS ( + SELECT 1 FROM `UnidirectionalJoinOneSelfPayload` AS `u0` INNER JOIN `UnidirectionalEntityOnes` AS `u1` ON `u0`.`LeftId` = `u1`.`Id` - WHERE `u`.`Id` = `u0`.`RightId`) > 0 + WHERE `u`.`Id` = `u0`.`RightId`) """); } @@ -2354,10 +2350,10 @@ public override async Task Select_many_over_skip_navigation_where_unidirectional SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` LEFT JOIN ( - SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` + SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` AS `OneId0` FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` -) AS `s` ON `u`.`Id` = `s`.`OneId` +) AS `s` ON `u`.`Id` = `s`.`OneId0` """); } @@ -2724,10 +2720,10 @@ public override async Task Select_many_over_skip_navigation_where_non_equality_u SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` LEFT JOIN ( - SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` + SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` AS `OneId0`, `u1`.`Id` AS `Id0` FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` -) AS `s` ON (`u`.`Id` = `s`.`OneId`) AND (`u`.`Id` <> `s`.`Id`) +) AS `s` ON (`u`.`Id` = `s`.`OneId0`) AND (`u`.`Id` <> `s`.`Id0`) """); } @@ -2737,7 +2733,7 @@ public override async Task Contains_on_skip_collection_navigation_unidirectional AssertSql( """ -@__entity_equality_two_0_Id='1' (Nullable = true) +@entity_equality_two_Id='1' (Nullable = true) SELECT `u`.`Id`, `u`.`Name` FROM `UnidirectionalEntityOnes` AS `u` @@ -2745,7 +2741,7 @@ WHERE EXISTS ( SELECT 1 FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` - WHERE (`u`.`Id` = `u0`.`OneId`) AND (`u1`.`Id` = @__entity_equality_two_0_Id)) + WHERE (`u`.`Id` = `u0`.`OneId`) AND (`u1`.`Id` = @entity_equality_two_Id)) """); } diff --git a/test/EFCore.MySql.FunctionalTests/Query/TPCManyToManyQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/TPCManyToManyQueryMySqlTest.cs index 6af24c76f..a2daa37bc 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/TPCManyToManyQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/TPCManyToManyQueryMySqlTest.cs @@ -92,11 +92,11 @@ public override async Task Skip_navigation_count_without_predicate(bool async) """ SELECT `e`.`Id`, `e`.`Name` FROM `EntityOnes` AS `e` -WHERE ( - SELECT COUNT(*) +WHERE EXISTS ( + SELECT 1 FROM `JoinOneSelfPayload` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`LeftId` = `e0`.`Id` - WHERE `e`.`Id` = `j`.`RightId`) > 0 + WHERE `e`.`Id` = `j`.`RightId`) """); } @@ -330,19 +330,15 @@ public override async Task Skip_navigation_order_by_single_or_default(bool async """ SELECT `s0`.`Id`, `s0`.`Name` FROM `EntityOnes` AS `e` -LEFT JOIN LATERAL ( - SELECT `s`.`Id`, `s`.`Name` +LEFT JOIN ( + SELECT `s`.`Id`, `s`.`Name`, `s`.`LeftId` FROM ( - SELECT `e0`.`Id`, `e0`.`Name` + SELECT `e0`.`Id`, `e0`.`Name`, `j`.`LeftId`, ROW_NUMBER() OVER(PARTITION BY `j`.`LeftId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneSelfPayload` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`RightId` = `e0`.`Id` - WHERE `e`.`Id` = `j`.`LeftId` - ORDER BY `e0`.`Id` - LIMIT 1 ) AS `s` - ORDER BY `s`.`Id` - LIMIT 1 -) AS `s0` ON TRUE + WHERE `s`.`row` <= 1 +) AS `s0` ON `e`.`Id` = `s0`.`LeftId` """); } @@ -519,10 +515,10 @@ public override async Task Select_many_over_skip_navigation_where(bool async) SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `EntityOnes` AS `e` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` + SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` AS `OneId0` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `s` ON `e`.`Id` = `s`.`OneId` +) AS `s` ON `e`.`Id` = `s`.`OneId0` """); } @@ -2003,10 +1999,10 @@ public override async Task Select_many_over_skip_navigation_where_non_equality(b SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `EntityOnes` AS `e` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` + SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` AS `OneId0`, `e0`.`Id` AS `Id0` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `s` ON (`e`.`Id` = `s`.`OneId`) AND (`e`.`Id` <> `s`.`Id`) +) AS `s` ON (`e`.`Id` = `s`.`OneId0`) AND (`e`.`Id` <> `s`.`Id0`) """); } @@ -2016,7 +2012,7 @@ public override async Task Contains_on_skip_collection_navigation(bool async) AssertSql( """ -@__entity_equality_two_0_Id='1' (Nullable = true) +@entity_equality_two_Id='1' (Nullable = true) SELECT `e`.`Id`, `e`.`Name` FROM `EntityOnes` AS `e` @@ -2024,7 +2020,7 @@ WHERE EXISTS ( SELECT 1 FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` - WHERE (`e`.`Id` = `j`.`OneId`) AND (`e0`.`Id` = @__entity_equality_two_0_Id)) + WHERE (`e`.`Id` = `j`.`OneId`) AND (`e0`.`Id` = @entity_equality_two_Id)) """); } @@ -2186,11 +2182,11 @@ public override async Task Skip_navigation_count_without_predicate_unidirectiona """ SELECT `u`.`Id`, `u`.`Name` FROM `UnidirectionalEntityOnes` AS `u` -WHERE ( - SELECT COUNT(*) +WHERE EXISTS ( + SELECT 1 FROM `UnidirectionalJoinOneSelfPayload` AS `u0` INNER JOIN `UnidirectionalEntityOnes` AS `u1` ON `u0`.`LeftId` = `u1`.`Id` - WHERE `u`.`Id` = `u0`.`RightId`) > 0 + WHERE `u`.`Id` = `u0`.`RightId`) """); } @@ -2355,10 +2351,10 @@ public override async Task Select_many_over_skip_navigation_where_unidirectional SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` LEFT JOIN ( - SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` + SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` AS `OneId0` FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` -) AS `s` ON `u`.`Id` = `s`.`OneId` +) AS `s` ON `u`.`Id` = `s`.`OneId0` """); } @@ -2748,10 +2744,10 @@ public override async Task Select_many_over_skip_navigation_where_non_equality_u SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` LEFT JOIN ( - SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` + SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` AS `OneId0`, `u1`.`Id` AS `Id0` FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` -) AS `s` ON (`u`.`Id` = `s`.`OneId`) AND (`u`.`Id` <> `s`.`Id`) +) AS `s` ON (`u`.`Id` = `s`.`OneId0`) AND (`u`.`Id` <> `s`.`Id0`) """); } @@ -2761,7 +2757,7 @@ public override async Task Contains_on_skip_collection_navigation_unidirectional AssertSql( """ -@__entity_equality_two_0_Id='1' (Nullable = true) +@entity_equality_two_Id='1' (Nullable = true) SELECT `u`.`Id`, `u`.`Name` FROM `UnidirectionalEntityOnes` AS `u` @@ -2769,7 +2765,7 @@ WHERE EXISTS ( SELECT 1 FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` - WHERE (`u`.`Id` = `u0`.`OneId`) AND (`u1`.`Id` = @__entity_equality_two_0_Id)) + WHERE (`u`.`Id` = `u0`.`OneId`) AND (`u1`.`Id` = @entity_equality_two_Id)) """); } diff --git a/test/EFCore.MySql.FunctionalTests/Query/TPTGearsOfWarQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/TPTGearsOfWarQueryMySqlTest.cs index a0a91e103..0f7795a0b 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/TPTGearsOfWarQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/TPTGearsOfWarQueryMySqlTest.cs @@ -36,24 +36,6 @@ public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) m => start <= m.Timeline.Date && m.Timeline < end && dates.Contains(m.Timeline))); } - public override Task Where_datetimeoffset_milliseconds_parameter_and_constant(bool async) - { - var dateTimeOffset = MySqlTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0))); - - // Literal where clause - var p = Expression.Parameter(typeof(Mission), "i"); - var dynamicWhere = Expression.Lambda>( - Expression.Equal( - Expression.Property(p, "Timeline"), - Expression.Constant(dateTimeOffset) - ), p); - - return AssertCount( - async, - ss => ss.Set().Where(dynamicWhere), - ss => ss.Set().Where(m => m.Timeline == dateTimeOffset)); - } - [ConditionalTheory(Skip = "TODO: Does not work as expected, probably due to some test definition issues.")] public override async Task DateTimeOffsetNow_minus_timespan(bool async) { @@ -237,54 +219,6 @@ public override Task Correlated_collection_with_groupby_with_complex_grouping_ke return base.Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection(async); } - public override async Task DateTimeOffset_to_unix_time_milliseconds(bool async) - { - await base.DateTimeOffset_to_unix_time_milliseconds(async); - - AssertSql( -""" -@__unixEpochMilliseconds_0='0' - -SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, CASE - WHEN `o`.`Nickname` IS NOT NULL THEN 'Officer' -END AS `Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s1`.`SquadId`, `s1`.`MissionId` -FROM `Gears` AS `g` -LEFT JOIN `Officers` AS `o` ON (`g`.`Nickname` = `o`.`Nickname`) AND (`g`.`SquadId` = `o`.`SquadId`) -INNER JOIN `Squads` AS `s` ON `g`.`SquadId` = `s`.`Id` -LEFT JOIN `SquadMissions` AS `s1` ON `s`.`Id` = `s1`.`SquadId` -WHERE NOT EXISTS ( - SELECT 1 - FROM `SquadMissions` AS `s0` - INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` - WHERE (`s`.`Id` = `s0`.`SquadId`) AND (@__unixEpochMilliseconds_0 = (TIMESTAMPDIFF(microsecond, TIMESTAMP '1970-01-01 00:00:00', `m`.`Timeline`)) DIV (1000))) -ORDER BY `g`.`Nickname`, `g`.`SquadId`, `s`.`Id`, `s1`.`SquadId` -"""); - } - - public override async Task DateTimeOffset_to_unix_time_seconds(bool async) - { - await base.DateTimeOffset_to_unix_time_seconds(async); - - AssertSql( -""" -@__unixEpochSeconds_0='0' - -SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, CASE - WHEN `o`.`Nickname` IS NOT NULL THEN 'Officer' -END AS `Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s1`.`SquadId`, `s1`.`MissionId` -FROM `Gears` AS `g` -LEFT JOIN `Officers` AS `o` ON (`g`.`Nickname` = `o`.`Nickname`) AND (`g`.`SquadId` = `o`.`SquadId`) -INNER JOIN `Squads` AS `s` ON `g`.`SquadId` = `s`.`Id` -LEFT JOIN `SquadMissions` AS `s1` ON `s`.`Id` = `s1`.`SquadId` -WHERE NOT EXISTS ( - SELECT 1 - FROM `SquadMissions` AS `s0` - INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` - WHERE (`s`.`Id` = `s0`.`SquadId`) AND (@__unixEpochSeconds_0 = TIMESTAMPDIFF(second, TIMESTAMP '1970-01-01 00:00:00', `m`.`Timeline`))) -ORDER BY `g`.`Nickname`, `g`.`SquadId`, `s`.`Id`, `s1`.`SquadId` -"""); - } - [SupportedServerVersionCondition(nameof(ServerVersionSupport.LimitWithNonConstantValue))] public override async Task Where_subquery_with_ElementAt_using_column_as_index(bool async) { @@ -293,22 +227,6 @@ public override async Task Where_subquery_with_ElementAt_using_column_as_index(b AssertSql(""); } - public override async Task Where_datetimeoffset_hour_component(bool async) - { - await AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Hour == /* 10 */ 8 - select m); - - AssertSql( -""" -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` -FROM `Missions` AS `m` -WHERE EXTRACT(hour FROM `m`.`Timeline`) = 8 -"""); - } - // TODO: Implement once TimeSpan is translated as ticks instead of TIME. public override async Task Non_string_concat_uses_appropriate_type_mapping(bool async) { diff --git a/test/EFCore.MySql.FunctionalTests/Query/ToSqlQueryMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/ToSqlQueryMySqlTest.cs index 2b4d6f375..887773abc 100644 --- a/test/EFCore.MySql.FunctionalTests/Query/ToSqlQueryMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Query/ToSqlQueryMySqlTest.cs @@ -1,4 +1,6 @@ using System.Threading.Tasks; +using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; @@ -8,6 +10,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query; public class ToSqlQueryMySqlTest : ToSqlQueryTestBase { + public ToSqlQueryMySqlTest([NotNull] NonSharedFixture fixture) + : base(fixture) + { + } + protected override ITestStoreFactory TestStoreFactory => MySqlTestStoreFactory.Instance; diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/BasicTypesQueryMySqlFixture.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/BasicTypesQueryMySqlFixture.cs new file mode 100644 index 000000000..a034fe4eb --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/BasicTypesQueryMySqlFixture.cs @@ -0,0 +1,94 @@ +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class BasicTypesQueryMySqlFixture : BasicTypesQueryFixtureBase, ITestSqlLoggerFactory +{ + private BasicTypesData _expectedData; + + protected override ITestStoreFactory TestStoreFactory + => MySqlTestStoreFactory.Instance; + + protected override Task SeedAsync(BasicTypesContext context) + { + _expectedData ??= LoadAndTweakData(); + context.AddRange(_expectedData.BasicTypesEntities); + context.AddRange(_expectedData.NullableBasicTypesEntities); + return context.SaveChangesAsync(); + } + + public override ISetSource GetExpectedData() + => _expectedData ??= LoadAndTweakData(); + + private BasicTypesData LoadAndTweakData() + { + var data = (BasicTypesData)base.GetExpectedData(); + + foreach (var item in data.BasicTypesEntities) + { + // For all relevant temporal types, chop sub-microsecond precision which PostgreSQL does not support. + // Temporal types which aren't set (default) get mapped to -infinity on PostgreSQL; this value causes many tests to fail. + + if (item.DateTime == default) + { + item.DateTime += TimeSpan.FromSeconds(1); + } + + // PostgreSQL maps DateTime to timestamptz by default, but that represents UTC timestamps which require DateTimeKind.Utc. + item.DateTime = DateTime.SpecifyKind(new DateTime(StripSubMicrosecond(item.DateTime.Ticks)), DateTimeKind.Utc); + + if (item.DateOnly == default) + { + item.DateOnly = item.DateOnly.AddDays(1); + } + + item.TimeOnly = new TimeOnly(StripSubMicrosecond(item.TimeOnly.Ticks)); + item.TimeSpan = new TimeSpan(StripSubMicrosecond(item.TimeSpan.Ticks)); + + if (item.DateTimeOffset == default) + { + item.DateTimeOffset += TimeSpan.FromSeconds(1); + } + + // PostgreSQL doesn't have a real DateTimeOffset type; we map .NET DateTimeOffset to timestamptz, which represents a UTC + // timestamp, and so we only support offset=0. + // Also chop sub-microsecond precision which PostgreSQL does not support. + item.DateTimeOffset = new DateTimeOffset(StripSubMicrosecond(item.DateTimeOffset.Ticks), TimeSpan.Zero); + } + + // Do the same for the nullable counterparts + foreach (var item in data.NullableBasicTypesEntities) + { + if (item.DateTime.HasValue) + { + item.DateTime = DateTime.SpecifyKind(new DateTime(StripSubMicrosecond(item.DateTime.Value.Ticks)), DateTimeKind.Utc); + } + + if (item.TimeOnly.HasValue) + { + item.TimeOnly = new TimeOnly(StripSubMicrosecond(item.TimeOnly.Value.Ticks)); + } + + if (item.TimeSpan.HasValue) + { + item.TimeSpan = new TimeSpan(StripSubMicrosecond(item.TimeSpan.Value.Ticks)); + } + + if (item.DateTimeOffset.HasValue) + { + item.DateTimeOffset = new DateTimeOffset(StripSubMicrosecond(item.DateTimeOffset.Value.Ticks), TimeSpan.Zero); + } + } + + return data; + + static long StripSubMicrosecond(long ticks) => ticks - (ticks % (TimeSpan.TicksPerMillisecond / 1000)); + } + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/BigIntegerTranslationsTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/BigIntegerTranslationsTest.cs new file mode 100644 index 000000000..026d80956 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/BigIntegerTranslationsTest.cs @@ -0,0 +1,227 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class BigIntegerTranslationsTest : QueryTestBase +{ + // ReSharper disable once UnusedParameter.Local + public BigIntegerTranslationsTest(BigIntegerQueryFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task Abs(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => BigInteger.Abs(e.BigInteger) == 1)); + + AssertSql( + """ +SELECT e."Id", e."BigInteger" +FROM "Entities" AS e +WHERE abs(e."BigInteger") = 1 +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task Pow(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => BigInteger.Pow(e.BigInteger, 2) == 4)); + + AssertSql( + """ +SELECT e."Id", e."BigInteger" +FROM "Entities" AS e +WHERE power(e."BigInteger", 2) = 4 +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task Max(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => BigInteger.Max(e.BigInteger, 1) == 1)); + + AssertSql( + """ +SELECT e."Id", e."BigInteger" +FROM "Entities" AS e +WHERE GREATEST(e."BigInteger", 1) = 1 +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task Min(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => BigInteger.Min(e.BigInteger, 1) == 1)); + + AssertSql( + """ +SELECT e."Id", e."BigInteger" +FROM "Entities" AS e +WHERE LEAST(e."BigInteger", 1) = 1 +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task IsZero(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => e.BigInteger.IsZero)); + + AssertSql( + """ +SELECT e."Id", e."BigInteger" +FROM "Entities" AS e +WHERE e."BigInteger" = 0 +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task IsOne(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => e.BigInteger.IsOne)); + + AssertSql( + """ +SELECT e."Id", e."BigInteger" +FROM "Entities" AS e +WHERE e."BigInteger" = 1 +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task IsEven(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => e.BigInteger.IsEven)); + + AssertSql( + """ +SELECT e."Id", e."BigInteger" +FROM "Entities" AS e +WHERE e."BigInteger" % 2 = 0 +"""); + } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + public class BigIntegerQueryContext(DbContextOptions options) : PoolableDbContext(options) + { + public DbSet Entities { get; set; } + + public static async Task SeedAsync(BigIntegerQueryContext context) + { + context.Entities.AddRange(BigIntegerData.CreateEntities()); + await context.SaveChangesAsync(); + } + } + + public class Entity + { + public int Id { get; set; } + public BigInteger BigInteger { get; set; } + } + + public class BigIntegerQueryFixture : SharedStoreFixtureBase, IQueryFixtureBase, ITestSqlLoggerFactory + { + private BigIntegerData _expectedData; + + protected override string StoreName + => "BigIntegerQueryTest"; + + protected override ITestStoreFactory TestStoreFactory + => MySqlTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override Task SeedAsync(BigIntegerQueryContext context) + => BigIntegerQueryContext.SeedAsync(context); + + public Func GetContextCreator() + => CreateContext; + + public ISetSource GetExpectedData() + => _expectedData ??= new BigIntegerData(); + + public IReadOnlyDictionary EntitySorters + => new Dictionary> { { typeof(Entity), e => ((Entity)e).Id } } + .ToDictionary(e => e.Key, e => (object)e.Value); + + public IReadOnlyDictionary EntityAsserters + => new Dictionary> + { + { + typeof(Entity), (e, a) => + { + Assert.Equal(e is null, a is null); + + if (a is not null) + { + var ee = (Entity)e!; + var aa = (Entity)a; + + Assert.Equal(ee.Id, aa.Id); + Assert.Equal(ee.BigInteger, aa.BigInteger); + } + } + } + }.ToDictionary(e => e.Key, e => (object)e.Value); + } + + protected class BigIntegerData : ISetSource + { + public IReadOnlyList Entities { get; } = CreateEntities(); + + public IQueryable Set() + where TEntity : class + { + if (typeof(TEntity) == typeof(Entity)) + { + return (IQueryable)Entities.AsQueryable(); + } + + throw new InvalidOperationException("Invalid entity type: " + typeof(TEntity)); + } + + public static IReadOnlyList CreateEntities() + => new List + { + new() { Id = 1, BigInteger = new BigInteger(0) }, + new() { Id = 2, BigInteger = new BigInteger(1) }, + new() { Id = 3, BigInteger = new BigInteger(2) }, + new() { Id = 4, BigInteger = new BigInteger(3) }, + new() { Id = 5, BigInteger = new BigInteger(-1) }, + }; + } +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/ByteArrayTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/ByteArrayTranslationsMySqlTest.cs new file mode 100644 index 000000000..1dd764f37 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/ByteArrayTranslationsMySqlTest.cs @@ -0,0 +1,112 @@ +using System.Threading.Tasks; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class ByteArrayTranslationsMySqlTest : ByteArrayTranslationsTestBase +{ + // ReSharper disable once UnusedParameter.Local + public ByteArrayTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Length() + { + await base.Length(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE LENGTH(`b`.`ByteArray`) = 4 +"""); + } + + public override async Task Index() + { + await base.Index(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (LENGTH(`b`.`ByteArray`) >= 3) AND (ASCII(SUBSTRING(`b`.`ByteArray`, 2 + 1, 1)) = 190) +"""); + } + + public override async Task First() + { + await base.First(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (LENGTH(`b`.`ByteArray`) >= 1) AND (ASCII(`b`.`ByteArray`) = 222) +"""); + } + + public override async Task Contains_with_constant() + { + await base.Contains_with_constant(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE LOCATE(0x01, `b`.`ByteArray`) > 0 +"""); + } + + public override async Task Contains_with_parameter() + { + await base.Contains_with_parameter(); + + AssertSql( +""" +@someByte='1' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE LOCATE(UNHEX(HEX(@someByte)), `b`.`ByteArray`) > 0 +"""); + } + + public override async Task Contains_with_column() + { + await base.Contains_with_column(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE LOCATE(UNHEX(HEX(`b`.`Byte`)), `b`.`ByteArray`) > 0 +"""); + } + + public override async Task SequenceEqual() + { + await base.SequenceEqual(); + + AssertSql( +""" +@byteArrayParam='0xDEADBEEF' (Size = 8000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`ByteArray` = @byteArrayParam +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/CitextTranslationsTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/CitextTranslationsTest.cs new file mode 100644 index 000000000..499978730 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/CitextTranslationsTest.cs @@ -0,0 +1,337 @@ +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +/// +/// Tests operations on the PostgreSQL citext type. +/// +public class CitextTranslationsTest : IClassFixture +{ + private CitextQueryFixture Fixture { get; } + + // ReSharper disable once UnusedParameter.Local + public CitextTranslationsTest(CitextQueryFixture fixture, ITestOutputHelper testOutputHelper) + { + Fixture = fixture; + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + [Fact] + public void StartsWith_literal() + { + using var ctx = CreateContext(); + var result = ctx.SomeEntities.Single(s => s.CaseInsensitiveText.StartsWith("some")); + + Assert.Equal(1, result.Id); + AssertSql( + """ +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE s."CaseInsensitiveText" LIKE 'some%' +LIMIT 2 +"""); + } + + [Fact] + public void StartsWith_param_pattern() + { + using var ctx = CreateContext(); + var param = "some"; + var result = ctx.SomeEntities.Single(s => s.CaseInsensitiveText.StartsWith(param)); + + Assert.Equal(1, result.Id); + AssertSql( + """ +@param_startswith='some%' + +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE s."CaseInsensitiveText" LIKE @param_startswith +LIMIT 2 +"""); + } + + [Fact] + public void StartsWith_param_instance() + { + using var ctx = CreateContext(); + var param = "SomeTextWithExtraStuff"; + var result = ctx.SomeEntities.Single(s => param.StartsWith(s.CaseInsensitiveText)); + + Assert.Equal(1, result.Id); + AssertSql( + """ +@param='SomeTextWithExtraStuff' + +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE left(@param, length(s."CaseInsensitiveText"))::citext = s."CaseInsensitiveText" +LIMIT 2 +"""); + } + + [Fact] + public void EndsWith_literal() + { + using var ctx = CreateContext(); + var result = ctx.SomeEntities.Single(s => s.CaseInsensitiveText.EndsWith("sometext")); + + Assert.Equal(1, result.Id); + AssertSql( + """ +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE s."CaseInsensitiveText" LIKE '%sometext' +LIMIT 2 +"""); + } + + [Fact] + public void EndsWith_param_pattern() + { + using var ctx = CreateContext(); + var param = "sometext"; + var result = ctx.SomeEntities.Single(s => s.CaseInsensitiveText.EndsWith(param)); + + Assert.Equal(1, result.Id); + AssertSql( + """ +@param_endswith='%sometext' + +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE s."CaseInsensitiveText" LIKE @param_endswith +LIMIT 2 +"""); + } + + [Fact] + public void EndsWith_param_instance() + { + using var ctx = CreateContext(); + var param = "ExtraStuffThenSomeText"; + var result = ctx.SomeEntities.Single(s => param.EndsWith(s.CaseInsensitiveText)); + + Assert.Equal(1, result.Id); + AssertSql( + """ +@param='ExtraStuffThenSomeText' + +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE right(@param, length(s."CaseInsensitiveText"))::citext = s."CaseInsensitiveText" +LIMIT 2 +"""); + } + + [Fact] + public void Contains_literal() + { + using var ctx = CreateContext(); + var result = ctx.SomeEntities.Single(s => s.CaseInsensitiveText.Contains("ometex")); + + Assert.Equal(1, result.Id); + AssertSql( + """ +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE s."CaseInsensitiveText" LIKE '%ometex%' +LIMIT 2 +"""); + } + + [Fact] + public void Contains_param_pattern() + { + using var ctx = CreateContext(); + var param = "ometex"; + var result = ctx.SomeEntities.Single(s => s.CaseInsensitiveText.Contains(param)); + + Assert.Equal(1, result.Id); + AssertSql( + """ +@param_contains='%ometex%' + +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE s."CaseInsensitiveText" LIKE @param_contains +LIMIT 2 +"""); + } + + [Fact] + public void Contains_param_instance() + { + using var ctx = CreateContext(); + var param = "ExtraSometextExtra"; + var result = ctx.SomeEntities.Single(s => param.Contains(s.CaseInsensitiveText)); + + Assert.Equal(1, result.Id); + AssertSql( + """ +@param='ExtraSometextExtra' + +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE strpos(@param, s."CaseInsensitiveText") > 0 +LIMIT 2 +"""); + } + + [Fact] + public void IndexOf_literal() + { + using var ctx = CreateContext(); + var result = ctx.SomeEntities.Single(s => s.CaseInsensitiveText.IndexOf("ometex") == 1); + + Assert.Equal(1, result.Id); + AssertSql( + """ +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE strpos(s."CaseInsensitiveText", 'ometex') - 1 = 1 +LIMIT 2 +"""); + } + + [Fact] + public void IndexOf_param_pattern() + { + using var ctx = CreateContext(); + var param = "ometex"; + var result = ctx.SomeEntities.Single(s => s.CaseInsensitiveText.IndexOf(param) == 1); + + Assert.Equal(1, result.Id); + AssertSql( + """ +@param='ometex' + +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE strpos(s."CaseInsensitiveText", @param) - 1 = 1 +LIMIT 2 +"""); + } + + [Fact] + public void IndexOf_param_instance() + { + using var ctx = CreateContext(); + var param = "ExtraSometextExtra"; + var result = ctx.SomeEntities.Single(s => param.IndexOf(s.CaseInsensitiveText) == 5); + + Assert.Equal(1, result.Id); + AssertSql( + """ +@param='ExtraSometextExtra' + +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE strpos(@param, s."CaseInsensitiveText") - 1 = 5 +LIMIT 2 +"""); + } + + [Fact] + public void Replace_literal() + { + using var ctx = CreateContext(); + var result = ctx.SomeEntities.Single(s => s.CaseInsensitiveText.Replace("Te", "Ne") == "SomeNext"); + + Assert.Equal(1, result.Id); + AssertSql( + """ +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE replace(s."CaseInsensitiveText", 'Te', 'Ne') = 'SomeNext' +LIMIT 2 +"""); + } + + [Fact] + public void Replace_param_pattern() + { + using var ctx = CreateContext(); + var param = "Te"; + var result = ctx.SomeEntities.Single(s => s.CaseInsensitiveText.Replace(param, "Ne") == "SomeNext"); + + Assert.Equal(1, result.Id); + AssertSql( + """ +@param='Te' + +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE replace(s."CaseInsensitiveText", @param, 'Ne') = 'SomeNext' +LIMIT 2 +"""); + } + + [Fact] + public void Replace_param_instance() + { + using var ctx = CreateContext(); + var param = "ExtraSometextExtra"; + var result = ctx.SomeEntities.Single(s => param.Replace(s.CaseInsensitiveText, "NewStuff") == "ExtraNewStuffExtra"); + + Assert.Equal(1, result.Id); + AssertSql( + """ +@param='ExtraSometextExtra' + +SELECT s."Id", s."CaseInsensitiveText" +FROM "SomeEntities" AS s +WHERE replace(@param, s."CaseInsensitiveText", 'NewStuff') = 'ExtraNewStuffExtra' +LIMIT 2 +"""); + } + + protected CitextQueryContext CreateContext() + => Fixture.CreateContext(); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + public class CitextQueryContext(DbContextOptions options) : PoolableDbContext(options) + { + public DbSet SomeEntities { get; set; } + + public static async Task SeedAsync(CitextQueryContext context) + { + context.SomeEntities.AddRange( + new SomeArrayEntity { Id = 1, CaseInsensitiveText = "SomeText" }, + new SomeArrayEntity { Id = 2, CaseInsensitiveText = "AnotherText" }); + await context.SaveChangesAsync(); + } + } + + public class SomeArrayEntity + { + public int Id { get; set; } + + [Column(TypeName = "citext")] + public string CaseInsensitiveText { get; set; } = null!; + } + + public class CitextQueryFixture : SharedStoreFixtureBase + { + protected override string StoreName + => "CitextQueryTest"; + + protected override ITestStoreFactory TestStoreFactory + => MySqlTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override Task SeedAsync(CitextQueryContext context) + => CitextQueryContext.SeedAsync(context); + } +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/EnumTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/EnumTranslationsMySqlTest.cs new file mode 100644 index 000000000..595856aaa --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/EnumTranslationsMySqlTest.cs @@ -0,0 +1,314 @@ +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class EnumTranslationsMySqlTest : EnumTranslationsTestBase +{ + public EnumTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Equality + + public override async Task Equality_to_constant() + { + await base.Equality_to_constant(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Enum` = 0 +"""); + } + + public override async Task Equality_to_parameter() + { + await base.Equality_to_parameter(); + + AssertSql( +""" +@basicEnum='0' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Enum` = @basicEnum +"""); + } + + public override async Task Equality_nullable_enum_to_constant() + { + await base.Equality_nullable_enum_to_constant(); + + AssertSql( +""" +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE `n`.`Enum` = 0 +"""); + } + + public override async Task Equality_nullable_enum_to_parameter() + { + await base.Equality_nullable_enum_to_parameter(); + + AssertSql( +""" +@basicEnum='0' + +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE `n`.`Enum` = @basicEnum +"""); + } + + public override async Task Equality_nullable_enum_to_null_constant() + { + await base.Equality_nullable_enum_to_null_constant(); + + AssertSql( +""" +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE `n`.`Enum` IS NULL +"""); + } + + public override async Task Equality_nullable_enum_to_null_parameter() + { + await base.Equality_nullable_enum_to_null_parameter(); + + AssertSql( +""" +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE `n`.`Enum` IS NULL +"""); + } + + public override async Task Equality_nullable_enum_to_nullable_parameter() + { + await base.Equality_nullable_enum_to_nullable_parameter(); + + AssertSql( +""" +@basicEnum='0' (Nullable = true) + +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE `n`.`Enum` = @basicEnum +"""); + } + + #endregion Equality + + public override async Task Bitwise_and_enum_constant() + { + await base.Bitwise_and_enum_constant(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & 1 AS signed) > 0 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & 1 AS signed) = 1 +"""); + } + + public override async Task Bitwise_and_integral_constant() + { + await base.Bitwise_and_integral_constant(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & 8 AS signed) = 8 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(CAST(`b`.`FlagsEnum` AS signed) & 8 AS signed) = 8 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(CAST(`b`.`FlagsEnum` AS signed) & 8 AS signed) = 8 +"""); + } + + public override async Task Bitwise_and_nullable_enum_with_constant() + { + await base.Bitwise_and_nullable_enum_with_constant(); + + AssertSql( +""" +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE CAST(`n`.`FlagsEnum` & 8 AS signed) > 0 +"""); + } + + public override async Task Where_bitwise_and_nullable_enum_with_null_constant() + { + await base.Where_bitwise_and_nullable_enum_with_null_constant(); + + AssertSql( +""" +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE CAST(`n`.`FlagsEnum` & NULL AS signed) > 0 +"""); + } + + public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter() + { + await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(); + + AssertSql( +""" +@flagsEnum='8' + +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE CAST(`n`.`FlagsEnum` & @flagsEnum AS signed) > 0 +"""); + } + + public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter() + { + await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(); + + AssertSql( +""" +@flagsEnum='8' (Nullable = true) + +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE CAST(`n`.`FlagsEnum` & @flagsEnum AS signed) > 0 +""", + // + """ +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE CAST(`n`.`FlagsEnum` & NULL AS signed) > 0 +"""); + } + + public override async Task Bitwise_or() + { + await base.Bitwise_or(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` | 8 AS signed) > 0 +"""); + } + + public override async Task Bitwise_projects_values_in_select() + { + await base.Bitwise_projects_values_in_select(); + + AssertSql( +""" +SELECT CAST(`b`.`FlagsEnum` & 8 AS signed) = 8 AS `BitwiseTrue`, CAST(`b`.`FlagsEnum` & 8 AS signed) = 4 AS `BitwiseFalse`, CAST(`b`.`FlagsEnum` & 8 AS signed) AS `BitwiseValue` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & 8 AS signed) = 8 +LIMIT 1 +"""); + } + + public override async Task HasFlag() + { + await base.HasFlag(); + +AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & 8 AS signed) = 8 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & 12 AS signed) = 12 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & 8 AS signed) = 8 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & 8 AS signed) = 8 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(8 & `b`.`FlagsEnum` AS signed) = `b`.`FlagsEnum` +""", + // + """ +SELECT CAST(`b`.`FlagsEnum` & 8 AS signed) = 8 AS `hasFlagTrue`, CAST(`b`.`FlagsEnum` & 4 AS signed) = 4 AS `hasFlagFalse` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & 8 AS signed) = 8 +LIMIT 1 +"""); + } + + public override async Task HasFlag_with_non_nullable_parameter() + { + await base.HasFlag_with_non_nullable_parameter(); + + AssertSql( +""" +@flagsEnum='8' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & @flagsEnum AS signed) = @flagsEnum +"""); + } + + public override async Task HasFlag_with_nullable_parameter() + { + await base.HasFlag_with_nullable_parameter(); + + AssertSql( +""" +@flagsEnum='8' (Nullable = true) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`FlagsEnum` & @flagsEnum AS signed) = @flagsEnum +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/GuidTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/GuidTranslationsMySqlTest.cs new file mode 100644 index 000000000..3df552918 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/GuidTranslationsMySqlTest.cs @@ -0,0 +1,91 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class GuidTranslationsMySqlTest : GuidTranslationsTestBase +{ + // ReSharper disable once UnusedParameter.Local + public GuidTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task New_with_constant() + { + await base.New_with_constant(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Guid` = 'df36f493-463f-4123-83f9-6b135deeb7ba' +"""); + } + + public override async Task New_with_parameter() + { + await base.New_with_parameter(); + + AssertSql( +""" +@p='df36f493-463f-4123-83f9-6b135deeb7ba' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Guid` = @p +"""); + } + + public override async Task ToString_projection() + { + await base.ToString_projection(); + + AssertSql( +""" +SELECT CAST(`b`.`Guid` AS char) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task NewGuid() + { + await base.NewGuid(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE UUID() <> '00000000-0000-0000-0000-000000000000' +"""); + } + + [ConditionalFact] + public virtual async Task CreateVersion7() + { + await AssertQuery( + ss => ss.Set() + .Where(od => Guid.CreateVersion7() != default)); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/MathTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/MathTranslationsMySqlTest.cs new file mode 100644 index 000000000..b32b2d20a --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/MathTranslationsMySqlTest.cs @@ -0,0 +1,766 @@ +using System.Threading.Tasks; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class MathTranslationsMySqlTest : MathTranslationsTestBase +{ + public MathTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Abs_decimal() + { + await base.Abs_decimal(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ABS(`b`.`Decimal`) = 9.5 +"""); + } + + public override async Task Abs_int() + { + await base.Abs_int(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ABS(`b`.`Int`) = 9 +"""); + } + + public override async Task Abs_double() + { + await base.Abs_double(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ABS(`b`.`Double`) = 9.5 +"""); + } + + public override async Task Abs_float() + { + await base.Abs_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(ABS(`b`.`Float`) AS double) = 9.5 +"""); + } + + public override async Task Ceiling() + { + await base.Ceiling(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CEILING(`b`.`Double`) = 9.0 +"""); + } + + public override async Task Ceiling_float() + { + await base.Ceiling_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CEILING(`b`.`Float`) = 9 +"""); + } + + public override async Task Floor_decimal() + { + await base.Floor_decimal(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE FLOOR(`b`.`Decimal`) = 8.0 +"""); + } + + public override async Task Floor_double() + { + await base.Floor_double(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE FLOOR(`b`.`Double`) = 8.0 +"""); + } + + public override async Task Floor_float() + { + await base.Floor_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE FLOOR(`b`.`Float`) = 8 +"""); + } + + public override async Task Power() + { + await base.Power(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE POWER(CAST(`b`.`Int` AS double), 2.0) = 64.0 +"""); + } + + public override async Task Power_float() + { + await base.Power_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (POWER(`b`.`Float`, 2) > 73) AND (POWER(`b`.`Float`, 2) < 74) +"""); + } + + public override async Task Round_decimal() + { + await base.Round_decimal(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ROUND(`b`.`Decimal`) = 9.0 +""", + // + """ +SELECT ROUND(`b`.`Decimal`) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Round_double() + { + await base.Round_double(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ROUND(`b`.`Double`) = 9.0 +""", + // + """ +SELECT ROUND(`b`.`Double`) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Round_float() + { + await base.Round_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ROUND(`b`.`Float`) = 9 +""", + // + """ +SELECT ROUND(`b`.`Float`) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Round_with_digits_decimal() + { + await base.Round_with_digits_decimal(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ROUND(`b`.`Decimal`, 1) = 255.1 +"""); + } + + // PostgreSQL only has round(v, s) over numeric, may be possible to cast back and forth though + public override Task Round_with_digits_double() + => AssertTranslationFailed(() => base.Round_with_digits_double()); + + // PostgreSQL only has round(v, s) over numeric, may be possible to cast back and forth though + public override Task Round_with_digits_float() + => AssertTranslationFailed(() => base.Round_with_digits_float()); + + public override async Task Truncate_decimal() + { + await base.Truncate_decimal(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TRUNCATE(`b`.`Decimal`, 0) = 8.0 +""", + // + """ +SELECT TRUNCATE(`b`.`Decimal`, 0) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Truncate_double() + { + await base.Truncate_double(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TRUNCATE(`b`.`Double`, 0) = 8.0 +""", + // + """ +SELECT TRUNCATE(`b`.`Double`, 0) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Truncate_float() + { + await base.Truncate_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TRUNCATE(`b`.`Float`, 0) = 8 +""", + // + """ +SELECT TRUNCATE(`b`.`Float`, 0) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Truncate_project_and_order_by_it_twice() + { + await base.Truncate_project_and_order_by_it_twice(); + + AssertSql( +""" +SELECT TRUNCATE(`b`.`Double`, 0) AS `A` +FROM `BasicTypesEntities` AS `b` +ORDER BY TRUNCATE(`b`.`Double`, 0) +"""); + } + + // issue #16038 + // AssertSql( + // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] + //FROM [Orders] AS [o] + //WHERE [o].[OrderID] < 10250 + //ORDER BY [A]"); + public override async Task Truncate_project_and_order_by_it_twice2() + { + await base.Truncate_project_and_order_by_it_twice2(); + + AssertSql( +""" +SELECT TRUNCATE(`b`.`Double`, 0) AS `A` +FROM `BasicTypesEntities` AS `b` +ORDER BY TRUNCATE(`b`.`Double`, 0) DESC +"""); + } + + // issue #16038 + // AssertSql( + // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] + //FROM [Orders] AS [o] + //WHERE [o].[OrderID] < 10250 + //ORDER BY [A] DESC"); + public override async Task Truncate_project_and_order_by_it_twice3() + { + await base.Truncate_project_and_order_by_it_twice3(); + + AssertSql( +""" +SELECT TRUNCATE(`b`.`Double`, 0) AS `A` +FROM `BasicTypesEntities` AS `b` +ORDER BY TRUNCATE(`b`.`Double`, 0) DESC +"""); + } + + public override async Task Exp() + { + await base.Exp(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXP(`b`.`Double`) > 1.0 +"""); + } + + public override async Task Exp_float() + { + await base.Exp_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXP(`b`.`Float`) > 1 +"""); + } + + public override async Task Log() + { + await base.Log(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Double` > 0.0) AND (LOG(`b`.`Double`) <> 0.0) +"""); + } + + public override async Task Log_float() + { + await base.Log_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Float` > 0) AND (LOG(`b`.`Float`) <> 0) +"""); + } + + // PostgreSQL only has log(x, base) over numeric, may be possible to cast back and forth though + public override Task Log_with_newBase() + => AssertTranslationFailed(() => base.Log_with_newBase()); + + // PostgreSQL only has log(x, base) over numeric, may be possible to cast back and forth though + public override Task Log_with_newBase_float() + => AssertTranslationFailed(() => base.Log_with_newBase_float()); + + public override async Task Log10() + { + await base.Log10(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Double` > 0.0) AND ((LOG10(`b`.`Double`) <> 0.0) OR LOG10(`b`.`Double`) IS NULL) +"""); + } + + public override async Task Log10_float() + { + await base.Log10_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Float` > 0) AND ((LOG10(`b`.`Float`) <> 0) OR LOG10(`b`.`Float`) IS NULL) +"""); + } + + public override async Task Log2() + => await AssertTranslationFailed(() => base.Log2()); + + public override async Task Sqrt() + { + await base.Sqrt(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Double` > 0.0) AND (SQRT(`b`.`Double`) > 0.0) +"""); + } + + public override async Task Sqrt_float() + { + await base.Sqrt_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Float` > 0) AND (SQRT(`b`.`Float`) > 0) +"""); + } + + public override async Task Sign() + { + await base.Sign(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE SIGN(`b`.`Double`) > 0 +"""); + } + + public override async Task Sign_float() + { + await base.Sign_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE SIGN(`b`.`Float`) > 0 +"""); + } + + public override async Task Max() + { + await base.Max(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE GREATEST(`b`.`Int`, `b`.`Short` - 3) = `b`.`Int` +"""); + } + + public override async Task Max_nested() + { + await base.Max_nested(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE GREATEST(`b`.`Short` - 3, `b`.`Int`, 1) = `b`.`Int` +"""); + } + + public override async Task Max_nested_twice() + { + await base.Max_nested_twice(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE GREATEST(1, `b`.`Int`, 2, `b`.`Short` - 3) = `b`.`Int` +"""); + } + + public override async Task Min() + { + await base.Min(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE LEAST(`b`.`Int`, `b`.`Short` + 3) = `b`.`Int` +"""); + } + + public override async Task Min_nested() + { + await base.Min_nested(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE LEAST(`b`.`Short` + 3, `b`.`Int`, 99999) = `b`.`Int` +"""); + } + + public override async Task Min_nested_twice() + { + await base.Min_nested_twice(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE LEAST(99999, `b`.`Int`, 99998, `b`.`Short` + 3) = `b`.`Int` +"""); + } + + public override async Task Degrees() + { + await base.Degrees(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DEGREES(`b`.`Double`) > 0.0 +"""); + } + + public override async Task Degrees_float() + { + await base.Degrees_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DEGREES(`b`.`Float`) > 0 +"""); + } + + public override async Task Radians() + { + await base.Radians(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE RADIANS(`b`.`Double`) > 0.0 +"""); + } + + public override async Task Radians_float() + { + await base.Radians_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE RADIANS(`b`.`Float`) > 0 +"""); + } + + #region Trigonometry + + public override async Task Acos() + { + await base.Acos(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ((`b`.`Double` >= -1.0) AND (`b`.`Double` <= 1.0)) AND (ACOS(`b`.`Double`) > 1.0) +"""); + } + + public override async Task Acos_float() + { + await base.Acos_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ((`b`.`Float` >= -1) AND (`b`.`Float` <= 1)) AND (ACOS(`b`.`Float`) > 0) +"""); + } + + public override async Task Acosh() + => await AssertTranslationFailed(() => base.Acosh()); + + public override async Task Asin() + { + await base.Asin(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ((`b`.`Double` >= -1.0) AND (`b`.`Double` <= 1.0)) AND (ASIN(`b`.`Double`) > -1.7976931348623157E+308) +"""); + } + + public override async Task Asin_float() + { + await base.Asin_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ((`b`.`Float` >= -1) AND (`b`.`Float` <= 1)) AND (CAST(ASIN(`b`.`Float`) AS double) > -1.7976931348623157E+308) +"""); + } + + public override async Task Asinh() + => await AssertTranslationFailed(() => base.Asinh()); + + public override async Task Atan() + { + await base.Atan(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ATAN(`b`.`Double`) > 0.0 +"""); + } + + public override async Task Atan_float() + { + await base.Atan_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ATAN(`b`.`Float`) > 0 +"""); + } + + public override async Task Atanh() + => await AssertTranslationFailed(() => base.Atanh()); + + public override async Task Atan2() + { + await base.Atan2(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ATAN2(`b`.`Double`, 1.0) > 0.0 +"""); + } + + public override async Task Atan2_float() + { + await base.Atan2_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ATAN2(`b`.`Float`, 1) > 0 +"""); + } + + public override async Task Cos() + { + await base.Cos(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE COS(`b`.`Double`) > 0.0 +"""); + } + + public override async Task Cos_float() + { + await base.Cos_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE COS(`b`.`Float`) > 0 +"""); + } + + public override async Task Cosh() + => await AssertTranslationFailed(() => base.Cosh()); + + public override async Task Sin() + { + await base.Sin(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE SIN(`b`.`Double`) > 0.0 +"""); + } + + public override async Task Sin_float() + { + await base.Sin_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE SIN(`b`.`Float`) > 0 +"""); + } + + public override async Task Sinh() + => await AssertTranslationFailed(() => base.Sinh()); + + public override async Task Tan() + { + await base.Tan(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TAN(`b`.`Double`) > 0.0 +"""); + } + + public override async Task Tan_float() + { + await base.Tan_float(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TAN(`b`.`Float`) > 0 +"""); + } + + public override async Task Tanh() + => await AssertTranslationFailed(() => base.Tanh()); + + #endregion Trigonometry + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/MiscellaneousTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/MiscellaneousTranslationsMySqlTest.cs new file mode 100644 index 000000000..26a83355c --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/MiscellaneousTranslationsMySqlTest.cs @@ -0,0 +1,406 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; +using MySqlConnector; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class MiscellaneousTranslationsMySqlTest : MiscellaneousTranslationsRelationalTestBase +{ + public MiscellaneousTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Random + + public override async Task Random_on_EF_Functions() + { + await base.Random_on_EF_Functions(); + + AssertSql( +""" +SELECT COUNT(*) +FROM `BasicTypesEntities` AS `b` +WHERE (RAND() >= 0.0) AND (RAND() < 1.0) +"""); + } + + public override async Task Random_Shared_Next_with_no_args() + { + await base.Random_Shared_Next_with_no_args(); + + AssertSql(); + } + + public override async Task Random_Shared_Next_with_one_arg() + { + await base.Random_Shared_Next_with_one_arg(); + + AssertSql(); + } + + public override async Task Random_Shared_Next_with_two_args() + { + await base.Random_Shared_Next_with_two_args(); + + AssertSql(); + } + + public override async Task Random_new_Next_with_no_args() + { + await base.Random_new_Next_with_no_args(); + + AssertSql(); + } + + public override async Task Random_new_Next_with_one_arg() + { + await base.Random_new_Next_with_one_arg(); + + AssertSql(); + } + + public override async Task Random_new_Next_with_two_args() + { + await base.Random_new_Next_with_two_args(); + + AssertSql(); + } + + #endregion Random + + #region Convert + + // These tests convert (among other things) to and from boolean, which PostgreSQL + // does not support (https://github.com/dotnet/efcore/issues/19606) + + public override async Task Convert_ToBoolean() + { + var exception = await Assert.ThrowsAsync(() => base.Convert_ToBoolean()); + Assert.Equal("42846", exception.SqlState); + } + + public override async Task Convert_ToByte() + { + var exception = await Assert.ThrowsAsync(() => base.Convert_ToByte()); + Assert.Equal("42846", exception.SqlState); + } + + public override async Task Convert_ToDecimal() + { + var exception = await Assert.ThrowsAsync(() => base.Convert_ToDecimal()); + Assert.Equal("42846", exception.SqlState); + } + + public override async Task Convert_ToDouble() + { + var exception = await Assert.ThrowsAsync(() => base.Convert_ToDouble()); + Assert.Equal("42846", exception.SqlState); + } + + public override async Task Convert_ToInt16() + { + var exception = await Assert.ThrowsAsync(() => base.Convert_ToInt16()); + Assert.Equal("42846", exception.SqlState); + } + + public override async Task Convert_ToInt32() + { + await base.Convert_ToInt32(); + +AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Bool` AS signed) = 1 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Byte` AS signed) = 12 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Decimal` AS signed) = 12 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Double` AS signed) = 12 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Float` AS signed) = 12 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Short` AS signed) = 12 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Int` AS signed) = 12 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Long` AS signed) = 12 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(CAST(`b`.`Int` AS char) AS signed) = 12 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Int` AS signed) = 12 +"""); + } + + public override async Task Convert_ToInt64() + { + var exception = await Assert.ThrowsAsync(() => base.Convert_ToInt64()); + Assert.Equal("42846", exception.SqlState); + } + + // Convert on DateTime not yet supported + public override Task Convert_ToString() + => AssertTranslationFailed(() => base.Convert_ToString()); + + #endregion Convert + + #region Compare + + public override async Task Int_Compare_to_simple_zero() + { + await base.Int_Compare_to_simple_zero(); + +AssertSql( +""" +@orderId='8' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` = @orderId +""", + // + """ +@orderId='8' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` <> @orderId +""", + // + """ +@orderId='8' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` > @orderId +""", + // + """ +@orderId='8' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` <= @orderId +""", + // + """ +@orderId='8' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` > @orderId +""", + // + """ +@orderId='8' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` <= @orderId +"""); + } + + public override async Task DateTime_Compare_to_simple_zero(bool compareTo) + { + // The base test implementation uses an Unspecified DateTime, which isn't supported with PostgreSQL timestamptz + var dateTime = new DateTime(1998, 5, 4, 15, 30, 10, DateTimeKind.Utc); + + if (compareTo) + { + await AssertQuery( + ss => ss.Set().Where(c => c.DateTime.CompareTo(dateTime) == 0)); + + await AssertQuery( + ss => ss.Set().Where(c => 0 != c.DateTime.CompareTo(dateTime))); + + await AssertQuery( + ss => ss.Set().Where(c => c.DateTime.CompareTo(dateTime) > 0)); + + await AssertQuery( + ss => ss.Set().Where(c => 0 >= c.DateTime.CompareTo(dateTime))); + + await AssertQuery( + ss => ss.Set().Where(c => 0 < c.DateTime.CompareTo(dateTime))); + + await AssertQuery( + ss => ss.Set().Where(c => c.DateTime.CompareTo(dateTime) <= 0)); + } + else + { + await AssertQuery( + ss => ss.Set().Where(c => DateTime.Compare(c.DateTime, dateTime) == 0)); + + await AssertQuery( + ss => ss.Set().Where(c => 0 != DateTime.Compare(c.DateTime, dateTime))); + + await AssertQuery( + ss => ss.Set().Where(c => DateTime.Compare(c.DateTime, dateTime) > 0)); + + await AssertQuery( + ss => ss.Set().Where(c => 0 >= DateTime.Compare(c.DateTime, dateTime))); + + await AssertQuery( + ss => ss.Set().Where(c => 0 < DateTime.Compare(c.DateTime, dateTime))); + + await AssertQuery( + ss => ss.Set().Where(c => DateTime.Compare(c.DateTime, dateTime) <= 0)); + } + +AssertSql( +""" +@dateTime='1998-05-04T15:30:10.0000000Z' (DbType = DateTime) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`DateTime` = @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000Z' (DbType = DateTime) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`DateTime` <> @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000Z' (DbType = DateTime) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`DateTime` > @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000Z' (DbType = DateTime) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`DateTime` <= @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000Z' (DbType = DateTime) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`DateTime` > @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000Z' (DbType = DateTime) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`DateTime` <= @dateTime +"""); + } + + public override async Task TimeSpan_Compare_to_simple_zero(bool compareTo) + { + await base.TimeSpan_Compare_to_simple_zero(compareTo); + + AssertSql( +""" +@timeSpan='01:02:03' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`TimeSpan` = @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`TimeSpan` <> @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`TimeSpan` > @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`TimeSpan` <= @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`TimeSpan` > @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`TimeSpan` <= @timeSpan +"""); + } + + #endregion Compare + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/ArithmeticOperatorTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/ArithmeticOperatorTranslationsMySqlTest.cs new file mode 100644 index 000000000..667b6de27 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/ArithmeticOperatorTranslationsMySqlTest.cs @@ -0,0 +1,83 @@ +using System.Threading.Tasks; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Operators; + +public class ArithmeticOperatorTranslationsMySqlTest : ArithmeticOperatorTranslationsTestBase +{ + public ArithmeticOperatorTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Add() + { + await base.Add(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Int` + 2) = 10 +"""); + } + + public override async Task Subtract() + { + await base.Subtract(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Int` - 3) = 5 +"""); + } + + public override async Task Multiply() + { + await base.Multiply(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Int` * 2) = 16 +"""); + } + + public override async Task Modulo() + { + await base.Modulo(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Int` % 3) = 2 +"""); + } + + public override async Task Minus() + { + await base.Minus(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE -`b`.`Int` = -8 +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/BitwiseOperatorTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/BitwiseOperatorTranslationsMySqlTest.cs new file mode 100644 index 000000000..8c5354d45 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/BitwiseOperatorTranslationsMySqlTest.cs @@ -0,0 +1,210 @@ +using System.Threading.Tasks; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Operators; + +public class BitwiseOperatorTranslationsMySqlTest : BitwiseOperatorTranslationsTestBase +{ + public BitwiseOperatorTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Or() + { + await base.Or(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(CAST(`b`.`Int` AS signed) | `b`.`Long` AS signed) = 7 +""", + // + """ +SELECT CAST(CAST(`b`.`Int` AS signed) | `b`.`Long` AS signed) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Or_over_boolean() + { + await base.Or_over_boolean(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Int` = 12) OR (`b`.`String` = 'Seattle') +""", + // + """ +SELECT (`b`.`Int` = 12) OR (`b`.`String` = 'Seattle') +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Or_multiple() + { + await base.Or_multiple(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(CAST(`b`.`Int` | `b`.`Short` AS signed) | `b`.`Long` AS signed) = 7 +"""); + } + + public override async Task And() + { + await base.And(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Int` & `b`.`Short` AS signed) = 2 +""", + // + """ +SELECT CAST(`b`.`Int` & `b`.`Short` AS signed) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task And_over_boolean() + { + await base.And_over_boolean(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Int` = 8) AND (`b`.`String` = 'Seattle') +""", + // + """ +SELECT (`b`.`Int` = 8) AND (`b`.`String` = 'Seattle') +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Xor() + { + await base.Xor(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Int` ^ `b`.`Short` AS signed) = 1 +""", + // + """ +SELECT CAST(`b`.`Int` ^ `b`.`Short` AS signed) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Xor_over_boolean() + { + await base.Xor_over_boolean(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Int` = `b`.`Short`) ^ (`b`.`String` = 'Seattle') +"""); + } + + public override async Task Complement() + { + await base.Complement(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(~`b`.`Int` AS signed) = -9 +"""); + } + + public override async Task And_or_over_boolean() + { + await base.And_or_over_boolean(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ((`b`.`Int` = 12) AND (`b`.`Short` = 12)) OR (`b`.`String` = 'Seattle') +"""); + } + + public override async Task Or_with_logical_or() + { + await base.Or_with_logical_or(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ((`b`.`Int` = 12) OR (`b`.`Short` = 12)) OR (`b`.`String` = 'Seattle') +"""); + } + + public override async Task And_with_logical_and() + { + await base.And_with_logical_and(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ((`b`.`Int` = 8) AND (`b`.`Short` = 8)) AND (`b`.`String` = 'Seattle') +"""); + } + + public override async Task Or_with_logical_and() + { + await base.Or_with_logical_and(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ((`b`.`Int` = 8) OR (`b`.`Short` = 9)) AND (`b`.`String` = 'Seattle') +"""); + } + + public override async Task And_with_logical_or() + { + await base.And_with_logical_or(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ((`b`.`Int` = 12) AND (`b`.`Short` = 12)) OR (`b`.`String` = 'Seattle') +"""); + } + + public override Task Left_shift() + => AssertTranslationFailed(() => base.Left_shift()); + + public override Task Right_shift() + => AssertTranslationFailed(() => base.Right_shift()); + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/ComparisonOperatorTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/ComparisonOperatorTranslationsMySqlTest.cs new file mode 100644 index 000000000..c7de8e1f2 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/ComparisonOperatorTranslationsMySqlTest.cs @@ -0,0 +1,95 @@ +using System.Threading.Tasks; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Operators; + +public class ComparisonOperatorTranslationsMySqlTest : ComparisonOperatorTranslationsTestBase +{ + public ComparisonOperatorTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Equal() + { + await base.Equal(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` = 8 +"""); + } + + public override async Task NotEqual() + { + await base.NotEqual(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` <> 8 +"""); + } + + public override async Task GreaterThan() + { + await base.GreaterThan(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` > 8 +"""); + } + + public override async Task GreaterThanOrEqual() + { + await base.GreaterThanOrEqual(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` >= 8 +"""); + } + + public override async Task LessThan() + { + await base.LessThan(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` < 8 +"""); + } + + public override async Task LessThanOrEqual() + { + await base.LessThanOrEqual(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` <= 8 +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/LogicalOperatorTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/LogicalOperatorTranslationsMySqlTest.cs new file mode 100644 index 000000000..56642d936 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/LogicalOperatorTranslationsMySqlTest.cs @@ -0,0 +1,95 @@ +using System.Threading.Tasks; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Operators; + +public class LogicalOperatorTranslationsMySqlTest : LogicalOperatorTranslationsTestBase +{ + public LogicalOperatorTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task And() + { + await base.And(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Int` = 8) AND (`b`.`String` = 'Seattle') +"""); + } + + public override async Task And_with_bool_property() + { + await base.And_with_bool_property(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Bool` AND (`b`.`String` = 'Seattle') +"""); + } + + public override async Task Or() + { + await base.Or(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`Int` = 999) OR (`b`.`String` = 'Seattle') +"""); + } + + public override async Task Or_with_bool_property() + { + await base.Or_with_bool_property(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Bool` OR (`b`.`String` = 'Seattle') +"""); + } + + public override async Task Not() + { + await base.Not(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`Int` <> 999 +"""); + } + + public override async Task Not_with_bool_property() + { + await base.Not_with_bool_property(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE NOT (`b`.`Bool`) +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/MiscellaneousOperatorTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/MiscellaneousOperatorTranslationsMySqlTest.cs new file mode 100644 index 000000000..b985e5524 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Operators/MiscellaneousOperatorTranslationsMySqlTest.cs @@ -0,0 +1,50 @@ +using System.Threading.Tasks; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Operators; + +public class MiscellaneousOperatorTranslationsMySqlTest : MiscellaneousOperatorTranslationsTestBase +{ + public MiscellaneousOperatorTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Conditional() + { + await base.Conditional(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CASE + WHEN `b`.`Int` = 8 THEN `b`.`String` + ELSE 'Foo' +END = 'Seattle' +"""); + } + + public override async Task Coalesce() + { + await base.Coalesce(); + + AssertSql( +""" +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE COALESCE(`n`.`String`, 'Unknown') = 'Seattle' +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/StringTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/StringTranslationsMySqlTest.cs new file mode 100644 index 000000000..13dbb7cc9 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/StringTranslationsMySqlTest.cs @@ -0,0 +1,1609 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class StringTranslationsMySqlTest : StringTranslationsRelationalTestBase +{ + public StringTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Equals + + public override async Task Equals() + { + await base.Equals(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` = 'Seattle' +"""); + } + + public override async Task Equals_with_OrdinalIgnoreCase() + { + await base.Equals_with_OrdinalIgnoreCase(); + + AssertSql(); + } + + public override async Task Equals_with_Ordinal() + { + await base.Equals_with_Ordinal(); + + AssertSql(); + } + + public override async Task Static_Equals() + { + await base.Static_Equals(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` = 'Seattle' +"""); + } + + public override async Task Static_Equals_with_OrdinalIgnoreCase() + { + await base.Static_Equals_with_OrdinalIgnoreCase(); + + AssertSql(); + } + + public override async Task Static_Equals_with_Ordinal() + { + await base.Static_Equals_with_Ordinal(); + + AssertSql(); + } + + #endregion Equals + + #region Miscellaneous + + public override async Task Length() + { + await base.Length(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CHAR_LENGTH(`b`.`String`) = 7 +"""); + } + + public override async Task ToUpper() + { + await base.ToUpper(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE UPPER(`b`.`String`) = 'SEATTLE' +""", + // + """ +SELECT UPPER(`b`.`String`) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task ToLower() + { + await base.ToLower(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE LOWER(`b`.`String`) = 'seattle' +""", + // + """ +SELECT LOWER(`b`.`String`) +FROM `BasicTypesEntities` AS `b` +"""); + } + + #endregion Miscellaneous + + #region IndexOf + + public override async Task IndexOf() + { + await base.IndexOf(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (LOCATE('eattl', `b`.`String`) - 1) <> -1 +"""); + } + + // TODO: #3547 + public override Task IndexOf_Char() + => Assert.ThrowsAsync(() => base.IndexOf_Char()); + + public override async Task IndexOf_with_empty_string() + { + await base.IndexOf_with_empty_string(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (LOCATE('', `b`.`String`) - 1) = 0 +"""); + } + + public override async Task IndexOf_with_one_parameter_arg() + { + await base.IndexOf_with_one_parameter_arg(); + + AssertSql( +""" +@pattern='eattl' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (LOCATE(@pattern, `b`.`String`) - 1) = 1 +"""); + } + + public override async Task IndexOf_with_one_parameter_arg_char() + { + await base.IndexOf_with_one_parameter_arg_char(); + + AssertSql( + """ +@pattern='e' (DbType = String) + +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE strpos(b."String", @pattern) - 1 = 1 +"""); + } + + // PostgreSQL does not have strpos with starting position + public override Task IndexOf_with_constant_starting_position() + => AssertTranslationFailed(() => base.IndexOf_with_constant_starting_position()); + + // PostgreSQL does not have strpos with starting position + public override Task IndexOf_with_constant_starting_position_char() + => AssertTranslationFailed(() => base.IndexOf_with_constant_starting_position_char()); + + // PostgreSQL does not have strpos with starting position + public override Task IndexOf_with_parameter_starting_position() + => AssertTranslationFailed(() => base.IndexOf_with_parameter_starting_position()); + + // PostgreSQL does not have strpos with starting position + public override Task IndexOf_with_parameter_starting_position_char() + => AssertTranslationFailed(() => base.IndexOf_with_parameter_starting_position_char()); + + public override async Task IndexOf_after_ToString() + { + await base.IndexOf_after_ToString(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (LOCATE('55', CAST(`b`.`Int` AS char)) - 1) = 1 +"""); + } + + public override async Task IndexOf_over_ToString() + { + await base.IndexOf_over_ToString(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (LOCATE(CAST(`b`.`Int` AS char), '12559') - 1) = 1 +"""); + } + + #endregion IndexOf + + #region Replace + + public override async Task Replace() + { + await base.Replace(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE REPLACE(`b`.`String`, 'Sea', 'Rea') = 'Reattle' +"""); + } + + // TODO: #3547 + public override Task Replace_Char() + => AssertTranslationFailed(() => base.Replace_Char()); + + public override async Task Replace_with_empty_string() + { + await base.Replace_with_empty_string(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`String` <> '') AND (REPLACE(`b`.`String`, `b`.`String`, '') = '') +"""); + } + + public override async Task Replace_using_property_arguments() + { + await base.Replace_using_property_arguments(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`String` <> '') AND (REPLACE(`b`.`String`, `b`.`String`, CAST(`b`.`Int` AS char)) = CAST(`b`.`Int` AS char)) +"""); + } + + #endregion Replace + + #region Substring + + public override async Task Substring() + { + await base.Substring(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CHAR_LENGTH(`b`.`String`) >= 3) AND (SUBSTRING(`b`.`String`, 1 + 1, 2) = 'ea') +"""); + } + + public override async Task Substring_with_one_arg_with_zero_startIndex() + { + await base.Substring_with_one_arg_with_zero_startIndex(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE SUBSTRING(`b`.`String`, 0 + 1, CHAR_LENGTH(`b`.`String`)) = 'Seattle' +"""); + } + + public override async Task Substring_with_one_arg_with_constant() + { + await base.Substring_with_one_arg_with_constant(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CHAR_LENGTH(`b`.`String`) >= 1) AND (SUBSTRING(`b`.`String`, 1 + 1, CHAR_LENGTH(`b`.`String`)) = 'eattle') +"""); + } + + public override async Task Substring_with_one_arg_with_parameter() + { + await base.Substring_with_one_arg_with_parameter(); + + AssertSql( +""" +@start='2' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CHAR_LENGTH(`b`.`String`) >= 2) AND (SUBSTRING(`b`.`String`, @start + 1, CHAR_LENGTH(`b`.`String`)) = 'attle') +"""); + } + + public override async Task Substring_with_two_args_with_zero_startIndex() + { + await base.Substring_with_two_args_with_zero_startIndex(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CHAR_LENGTH(`b`.`String`) >= 3) AND (SUBSTRING(`b`.`String`, 0 + 1, 3) = 'Sea') +"""); + } + + public override async Task Substring_with_two_args_with_zero_length() + { + await base.Substring_with_two_args_with_zero_length(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CHAR_LENGTH(`b`.`String`) >= 2) AND (SUBSTRING(`b`.`String`, 2 + 1, 0) = '') +"""); + } + + public override async Task Substring_with_two_args_with_parameter() + { + await base.Substring_with_two_args_with_parameter(); + + AssertSql( +""" +@start='2' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CHAR_LENGTH(`b`.`String`) >= 5) AND (SUBSTRING(`b`.`String`, @start + 1, 3) = 'att') +"""); + } + + public override async Task Substring_with_two_args_with_IndexOf() + { + await base.Substring_with_two_args_with_IndexOf(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`String` LIKE '%a%') AND (SUBSTRING(`b`.`String`, (LOCATE('a', `b`.`String`) - 1) + 1, 3) = 'att') +"""); + } + + #endregion Substring + + #region IsNullOrEmpty/Whitespace + + public override async Task IsNullOrEmpty() + { + await base.IsNullOrEmpty(); + + AssertSql( +""" +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE `n`.`String` IS NULL OR (`n`.`String` = '') +""", + // + """ +SELECT `n`.`String` IS NULL OR (`n`.`String` = '') +FROM `NullableBasicTypesEntities` AS `n` +"""); + } + + public override async Task IsNullOrEmpty_negated() + { + await base.IsNullOrEmpty_negated(); + + AssertSql( +""" +SELECT `n`.`Id`, `n`.`Bool`, `n`.`Byte`, `n`.`ByteArray`, `n`.`DateOnly`, `n`.`DateTime`, `n`.`DateTimeOffset`, `n`.`Decimal`, `n`.`Double`, `n`.`Enum`, `n`.`FlagsEnum`, `n`.`Float`, `n`.`Guid`, `n`.`Int`, `n`.`Long`, `n`.`Short`, `n`.`String`, `n`.`TimeOnly`, `n`.`TimeSpan` +FROM `NullableBasicTypesEntities` AS `n` +WHERE `n`.`String` IS NOT NULL AND (`n`.`String` <> '') +""", + // + """ +SELECT `n`.`String` IS NOT NULL AND (`n`.`String` <> '') +FROM `NullableBasicTypesEntities` AS `n` +"""); + } + + public override async Task IsNullOrWhiteSpace() + { + await base.IsNullOrWhiteSpace(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TRIM(`b`.`String`) = '' +"""); + } + + #endregion IsNullOrEmpty/Whitespace + + #region StartsWith + + public override async Task StartsWith_Literal() + { + await base.StartsWith_Literal(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` LIKE 'Se%' +"""); + } + + // TODO: #3547 + public override Task StartsWith_Literal_Char() + => AssertTranslationFailed(() => base.StartsWith_Literal_Char()); + + public override async Task StartsWith_Parameter() + { + await base.StartsWith_Parameter(); + + AssertSql( +""" +@pattern_startswith='Se%' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` LIKE @pattern_startswith +"""); + } + + public override Task StartsWith_Parameter_Char() + => AssertTranslationFailed(() => base.StartsWith_Parameter_Char()); + + public override async Task StartsWith_Column() + { + await base.StartsWith_Column(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE LEFT(`b`.`String`, CHAR_LENGTH(`b`.`String`)) = `b`.`String` +"""); + } + + public override async Task StartsWith_with_StringComparison_Ordinal() + { + await base.StartsWith_with_StringComparison_Ordinal(); + + AssertSql(); + } + + public override async Task StartsWith_with_StringComparison_OrdinalIgnoreCase() + { + await base.StartsWith_with_StringComparison_OrdinalIgnoreCase(); + + AssertSql(); + } + + public override async Task StartsWith_with_StringComparison_unsupported() + { + await base.StartsWith_with_StringComparison_unsupported(); + + AssertSql(); + } + + #endregion StartsWith + + #region EndsWith + + public override async Task EndsWith_Literal() + { + await base.EndsWith_Literal(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` LIKE '%le' +"""); + } + + // TODO: #3547 + public override Task EndsWith_Literal_Char() + => AssertTranslationFailed(() => base.EndsWith_Literal_Char()); + + public override async Task EndsWith_Parameter() + { + await base.EndsWith_Parameter(); + + AssertSql( +""" +@pattern_endswith='%le' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` LIKE @pattern_endswith +"""); + } + + // TODO: #3547 + public override Task EndsWith_Parameter_Char() + => AssertTranslationFailed(() => base.EndsWith_Parameter_Char()); + + public override async Task EndsWith_Column() + { + // SQL Server trims trailing whitespace for length calculations, making our EndsWith() column translation not work reliably in that + // case + await AssertQuery( + ss => ss.Set().Where(b => b.String == "Seattle" && b.String.EndsWith(b.String))); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`String` = 'Seattle') AND (RIGHT(`b`.`String`, CHAR_LENGTH(`b`.`String`)) = `b`.`String`) +"""); + } + + public override async Task EndsWith_with_StringComparison_Ordinal() + { + await base.EndsWith_with_StringComparison_Ordinal(); + + AssertSql(); + } + + public override async Task EndsWith_with_StringComparison_OrdinalIgnoreCase() + { + await base.EndsWith_with_StringComparison_OrdinalIgnoreCase(); + + AssertSql(); + } + + public override async Task EndsWith_with_StringComparison_unsupported() + { + await base.EndsWith_with_StringComparison_unsupported(); + + AssertSql(); + } + + #endregion EndsWith + + #region Contains + + public override async Task Contains_Literal() + { + await AssertQuery( + ss => ss.Set().Where(c => c.String.Contains("eattl")), // SQL Server is case-insensitive by default + ss => ss.Set().Where(c => c.String.Contains("eattl", StringComparison.OrdinalIgnoreCase))); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` LIKE '%eattl%' +"""); + } + + // TODO: #3547 + public override Task Contains_Literal_Char() + => AssertTranslationFailed(() => base.Contains_Literal_Char()); + + public override async Task Contains_Column() + { + await base.Contains_Column(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (LOCATE(`b`.`String`, `b`.`String`) > 0) OR (`b`.`String` LIKE '') +""", + // + """ +SELECT (LOCATE(`b`.`String`, `b`.`String`) > 0) OR (`b`.`String` LIKE '') +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Contains_negated() + { + await base.Contains_negated(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` NOT LIKE '%eattle%' +""", + // + """ +SELECT `b`.`String` NOT LIKE '%eattle%' +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task Contains_with_StringComparison_Ordinal() + { + await base.Contains_with_StringComparison_Ordinal(); + + AssertSql(); + } + + public override async Task Contains_with_StringComparison_OrdinalIgnoreCase() + { + await base.Contains_with_StringComparison_OrdinalIgnoreCase(); + + AssertSql(); + } + + public override async Task Contains_with_StringComparison_unsupported() + { + await base.Contains_with_StringComparison_unsupported(); + + AssertSql(); + } + + public override async Task Contains_constant_with_whitespace() + { + await base.Contains_constant_with_whitespace(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` LIKE '% %' +"""); + } + + public override async Task Contains_parameter_with_whitespace() + { + await base.Contains_parameter_with_whitespace(); + + AssertSql( +""" +@pattern_contains='% %' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` LIKE @pattern_contains +"""); + } + + #endregion Contains + + #region TrimStart + + public override async Task TrimStart_without_arguments() + { + await base.TrimStart_without_arguments(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TRIM(LEADING FROM `b`.`String`) = 'Boston ' +"""); + } + + public override async Task TrimStart_with_char_argument() + { + await base.TrimStart_with_char_argument(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TRIM(LEADING 'S' FROM `b`.`String`) = 'eattle' +"""); + } + + public override async Task TrimStart_with_char_array_argument() + { + await base.TrimStart_with_char_array_argument(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE ltrim(b."String", 'Se') = 'attle' +"""); + } + + #endregion TrimStart + + #region TrimEnd + + public override async Task TrimEnd_without_arguments() + { + await base.TrimEnd_without_arguments(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TRIM(TRAILING FROM `b`.`String`) = ' Boston' +"""); + } + + public override async Task TrimEnd_with_char_argument() + { + await base.TrimEnd_with_char_argument(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TRIM(TRAILING 'e' FROM `b`.`String`) = 'Seattl' +"""); + } + + public override async Task TrimEnd_with_char_array_argument() + { + await base.TrimEnd_with_char_array_argument(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE rtrim(b."String", 'le') = 'Seatt' +"""); + } + + #endregion TrimEnd + + #region Trim + + public override async Task Trim_without_argument_in_predicate() + { + await base.Trim_without_argument_in_predicate(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TRIM(`b`.`String`) = 'Boston' +"""); + } + + public override async Task Trim_with_char_argument_in_predicate() + { + await base.Trim_with_char_argument_in_predicate(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TRIM('S' FROM `b`.`String`) = 'eattle' +"""); + } + + public override async Task Trim_with_char_array_argument_in_predicate() + { + await base.Trim_with_char_array_argument_in_predicate(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE btrim(b."String", 'Se') = 'attl' +"""); + } + + #endregion Trim + + #region Compare + + public override async Task Compare_simple_zero() + { + await base.Compare_simple_zero(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` = 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <> 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= 'Seattle' +"""); + } + + public override async Task Compare_simple_one() + { + await base.Compare_simple_one(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` < 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` >= 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` >= 'Seattle' +"""); + } + + public override async Task Compare_with_parameter() + { + await base.Compare_with_parameter(); + + AssertSql( +""" +@basicTypeEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` < @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` >= @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` >= @basicTypeEntity_String +"""); + } + + public override async Task Compare_simple_more_than_one() + { + await base.Compare_simple_more_than_one(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CASE + WHEN `b`.`String` = 'Seattle' THEN 0 + WHEN `b`.`String` > 'Seattle' THEN 1 + WHEN `b`.`String` < 'Seattle' THEN -1 +END = 42 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CASE + WHEN `b`.`String` = 'Seattle' THEN 0 + WHEN `b`.`String` > 'Seattle' THEN 1 + WHEN `b`.`String` < 'Seattle' THEN -1 +END > 42 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE 42 > CASE + WHEN `b`.`String` = 'Seattle' THEN 0 + WHEN `b`.`String` > 'Seattle' THEN 1 + WHEN `b`.`String` < 'Seattle' THEN -1 +END +"""); + } + + public override async Task Compare_nested() + { + await base.Compare_nested(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` = (CONCAT('M', `b`.`String`)) +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <> SUBSTRING(`b`.`String`, 0 + 1, 0) +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > REPLACE('Seattle', 'Sea', `b`.`String`) +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= (CONCAT('M', `b`.`String`)) +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > SUBSTRING(`b`.`String`, 0 + 1, 0) +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` < REPLACE('Seattle', 'Sea', `b`.`String`) +"""); + } + + public override async Task Compare_multi_predicate() + { + await base.Compare_multi_predicate(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`String` >= 'Seattle') AND (`b`.`String` < 'Toronto') +"""); + } + + public override async Task CompareTo_simple_zero() + { + await base.CompareTo_simple_zero(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` = 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <> 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= 'Seattle' +"""); + } + + public override async Task CompareTo_simple_one() + { + await base.CompareTo_simple_one(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` < 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` >= 'Seattle' +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` >= 'Seattle' +"""); + } + + public override async Task CompareTo_with_parameter() + { + await base.CompareTo_with_parameter(); + + AssertSql( +""" +@basicTypesEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` < @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` >= @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` >= @basicTypesEntity_String +"""); + } + + public override async Task CompareTo_simple_more_than_one() + { + await base.CompareTo_simple_more_than_one(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CASE + WHEN `b`.`String` = 'Seattle' THEN 0 + WHEN `b`.`String` > 'Seattle' THEN 1 + WHEN `b`.`String` < 'Seattle' THEN -1 +END = 42 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CASE + WHEN `b`.`String` = 'Seattle' THEN 0 + WHEN `b`.`String` > 'Seattle' THEN 1 + WHEN `b`.`String` < 'Seattle' THEN -1 +END > 42 +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE 42 > CASE + WHEN `b`.`String` = 'Seattle' THEN 0 + WHEN `b`.`String` > 'Seattle' THEN 1 + WHEN `b`.`String` < 'Seattle' THEN -1 +END +"""); + } + + public override async Task CompareTo_nested() + { + await base.CompareTo_nested(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` = (CONCAT('M', `b`.`String`)) +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <> SUBSTRING(`b`.`String`, 0 + 1, 0) +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > REPLACE('Seattle', 'Sea', `b`.`String`) +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` <= (CONCAT('M', `b`.`String`)) +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` > SUBSTRING(`b`.`String`, 0 + 1, 0) +""", + // + """ +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` < REPLACE('Seattle', 'Sea', `b`.`String`) +"""); + } + + public override async Task Compare_to_multi_predicate() + { + await base.Compare_to_multi_predicate(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`String` >= 'Seattle') AND (`b`.`String` < 'Toronto') +"""); + } + + #endregion Compare + + #region Join + + public override async Task Join_over_non_nullable_column() + { + await base.Join_over_non_nullable_column(); + + AssertSql( +""" +SELECT `b1`.`Int`, `b0`.`String`, `b0`.`Id` +FROM ( + SELECT `b`.`Int` + FROM `BasicTypesEntities` AS `b` + GROUP BY `b`.`Int` +) AS `b1` +LEFT JOIN `BasicTypesEntities` AS `b0` ON `b1`.`Int` = `b0`.`Int` +ORDER BY `b1`.`Int` +"""); + } + + public override async Task Join_over_nullable_column() + { + await base.Join_over_nullable_column(); + + AssertSql( +""" +SELECT `n3`.`Key`, `n1`.`String`, `n1`.`Id` +FROM ( + SELECT `n0`.`Key` + FROM ( + SELECT COALESCE(`n`.`Int`, 0) AS `Key` + FROM `NullableBasicTypesEntities` AS `n` + ) AS `n0` + GROUP BY `n0`.`Key` +) AS `n3` +LEFT JOIN ( + SELECT `n2`.`Id`, `n2`.`String`, COALESCE(`n2`.`Int`, 0) AS `Key` + FROM `NullableBasicTypesEntities` AS `n2` +) AS `n1` ON `n3`.`Key` = `n1`.`Key` +ORDER BY `n3`.`Key` +"""); + } + + public override async Task Join_with_predicate() + { + await base.Join_with_predicate(); + + AssertSql( +""" +SELECT `b1`.`Int`, `b2`.`String`, `b2`.`Id` +FROM ( + SELECT `b`.`Int` + FROM `BasicTypesEntities` AS `b` + GROUP BY `b`.`Int` +) AS `b1` +LEFT JOIN ( + SELECT `b0`.`String`, `b0`.`Id`, `b0`.`Int` + FROM `BasicTypesEntities` AS `b0` + WHERE CHAR_LENGTH(`b0`.`String`) > 6 +) AS `b2` ON `b1`.`Int` = `b2`.`Int` +ORDER BY `b1`.`Int` +"""); + } + + public override async Task Join_with_ordering() + { + await base.Join_with_ordering(); + + AssertSql( +""" +SELECT `b1`.`Int`, `b0`.`String`, `b0`.`Id` +FROM ( + SELECT `b`.`Int` + FROM `BasicTypesEntities` AS `b` + GROUP BY `b`.`Int` +) AS `b1` +LEFT JOIN `BasicTypesEntities` AS `b0` ON `b1`.`Int` = `b0`.`Int` +ORDER BY `b1`.`Int`, `b0`.`Id` DESC +"""); + } + + public override async Task Join_non_aggregate() + { + await base.Join_non_aggregate(); + + AssertSql( +""" +@foo='foo' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CONCAT_WS('|', `b`.`String`, @foo, '', 'bar') = 'Seattle|foo||bar' +"""); + } + + #endregion Join + + #region Concatenation + + public override async Task Concat_operator() + { + await base.Concat_operator(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CONCAT(`b`.`String`, 'Boston')) = 'SeattleBoston' +"""); + } + + public override async Task Concat_aggregate() + { + await base.Concat_aggregate(); + + AssertSql( +""" +SELECT `b1`.`Int`, `b0`.`String`, `b0`.`Id` +FROM ( + SELECT `b`.`Int` + FROM `BasicTypesEntities` AS `b` + GROUP BY `b`.`Int` +) AS `b1` +LEFT JOIN `BasicTypesEntities` AS `b0` ON `b1`.`Int` = `b0`.`Int` +ORDER BY `b1`.`Int` +"""); + } + + public override async Task Concat_string_int_comparison1() + { + await base.Concat_string_int_comparison1(); + + AssertSql( +""" +@i='10' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CONCAT(`b`.`String`, CAST(@i AS char))) = 'Seattle10' +"""); + } + + public override async Task Concat_string_int_comparison2() + { + await base.Concat_string_int_comparison2(); + + AssertSql( +""" +@i='10' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CONCAT(CAST(@i AS char), `b`.`String`)) = '10Seattle' +"""); + } + + public override async Task Concat_string_int_comparison3() + { + await base.Concat_string_int_comparison3(); + + AssertSql( +""" +@p='30' +@j='21' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CONCAT(CONCAT(CONCAT(CAST(@p AS char), `b`.`String`), CAST(@j AS char)), CAST(42 AS char))) = '30Seattle2142' +"""); + } + + public override async Task Concat_string_int_comparison4() + { + await base.Concat_string_int_comparison4(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CONCAT(CAST(`b`.`Int` AS char), `b`.`String`)) = '8Seattle' +"""); + } + + public override async Task Concat_string_string_comparison() + { + await base.Concat_string_string_comparison(); + + AssertSql( +""" +@i='A' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (CONCAT(@i, `b`.`String`)) = 'ASeattle' +"""); + } + + public override async Task Concat_method_comparison() + { + await base.Concat_method_comparison(); + + AssertSql( +""" +@i='A' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CONCAT(@i, `b`.`String`) = 'ASeattle' +"""); + } + + public override async Task Concat_method_comparison_2() + { + await base.Concat_method_comparison_2(); + + AssertSql( +""" +@i='A' (Size = 4000) +@j='B' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CONCAT(@i, @j, `b`.`String`) = 'ABSeattle' +"""); + } + + public override async Task Concat_method_comparison_3() + { + await base.Concat_method_comparison_3(); + + AssertSql( +""" +@i='A' (Size = 4000) +@j='B' (Size = 4000) +@k='C' (Size = 4000) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CONCAT(@i, @j, @k, `b`.`String`) = 'ABCSeattle' +"""); + } + + #endregion Concatenation + + #region LINQ Operators + + public override async Task FirstOrDefault() + { + await base.FirstOrDefault(); + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE SUBSTRING(`b`.`String`, 1, 1) = 'S' +"""); + } + + public override async Task LastOrDefault() + { + await base.LastOrDefault(); + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE SUBSTRING(`b`.`String`, CHAR_LENGTH(`b`.`String`), 1) = 'e' +"""); + } + + #endregion LINQ Operators + + #region Like + + public override async Task Where_Like_and_comparison() + { + await base.Where_Like_and_comparison(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`String` LIKE 'S%') AND (`b`.`Int` = 8) +"""); + } + + public override async Task Where_Like_or_comparison() + { + await base.Where_Like_or_comparison(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`String` LIKE 'S%') OR (`b`.`Int` = 2147483647) +"""); + } + + public override async Task Like_with_non_string_column_using_ToString() + { + await base.Like_with_non_string_column_using_ToString(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Int` AS char) LIKE '%5%' +"""); + } + + public override async Task Like_with_non_string_column_using_double_cast() + { + await base.Like_with_non_string_column_using_double_cast(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`Int` AS char) LIKE '%5%' +"""); + } + + #endregion Like + + #region Regex + + public override async Task Regex_IsMatch() + { + await base.Regex_IsMatch(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`String` REGEXP '^S' +"""); + } + + public override async Task Regex_IsMatch_constant_input() + { + await base.Regex_IsMatch_constant_input(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE 'Seattle' ~ ('(?p)' || b."String") +"""); + } + + #endregion Regex + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateOnlyTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateOnlyTranslationsMySqlTest.cs new file mode 100644 index 000000000..8b3eee79d --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateOnlyTranslationsMySqlTest.cs @@ -0,0 +1,243 @@ +using System.Threading.Tasks; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Temporal; + +public class DateOnlyTranslationsMySqlTest : DateOnlyTranslationsTestBase +{ + public DateOnlyTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Year() + { + await base.Year(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(year FROM `b`.`DateOnly`) = 1990 +"""); + } + + public override async Task Month() + { + await base.Month(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(month FROM `b`.`DateOnly`) = 11 +"""); + } + + public override async Task Day() + { + await base.Day(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(day FROM `b`.`DateOnly`) = 10 +"""); + } + + public override async Task DayOfYear() + { + await base.DayOfYear(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DAYOFYEAR(`b`.`DateOnly`) = 314 +"""); + } + + public override async Task DayOfWeek() + { + await base.DayOfWeek(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (DAYOFWEEK(`b`.`DateOnly`) - 1) = 6 +"""); + } + + public override async Task DayNumber() + { + await base.DayNumber(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (TO_DAYS(`b`.`DateOnly`) - 366) = 726780 +"""); + } + + public override async Task AddYears() + { + await base.AddYears(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DATE_ADD(`b`.`DateOnly`, INTERVAL CAST(3 AS signed) year) = DATE '1993-11-10' +"""); + } + + public override async Task AddMonths() + { + await base.AddMonths(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DATE_ADD(`b`.`DateOnly`, INTERVAL CAST(3 AS signed) month) = DATE '1991-02-10' +"""); + } + + public override async Task AddDays() + { + await base.AddDays(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DATE_ADD(`b`.`DateOnly`, INTERVAL CAST(3 AS signed) day) = DATE '1990-11-13' +"""); + } + + public override async Task DayNumber_subtraction() + { + await base.DayNumber_subtraction(); + + AssertSql( +""" +@DayNumber='726775' + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ((TO_DAYS(`b`.`DateOnly`) - 366) - @DayNumber) = 5 +"""); + } + + public override async Task FromDateTime() + { + await base.FromDateTime(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DATE(`b`.`DateTime`) = DATE '1998-05-04' +"""); + } + + public override async Task FromDateTime_compared_to_property() + { + await base.FromDateTime_compared_to_property(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DATE(`b`.`DateTime`) = `b`.`DateOnly` +"""); + } + + public override async Task FromDateTime_compared_to_constant_and_parameter() + { + await base.FromDateTime_compared_to_constant_and_parameter(); + + AssertSql( +""" +@dateOnly='10/11/0002' (DbType = Date) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DATE(`b`.`DateTime`) IN (@dateOnly, DATE '1998-05-04') +"""); + } + + public override async Task ToDateTime_property_with_constant_TimeOnly() + { + await base.ToDateTime_property_with_constant_TimeOnly(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ADDTIME(CAST(`b`.`DateOnly` AS datetime(6)), TIME '21:05:19.9405') = TIMESTAMP '2020-01-01 21:05:19.9405' +"""); + } + + public override async Task ToDateTime_property_with_property_TimeOnly() + { + await base.ToDateTime_property_with_property_TimeOnly(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ADDTIME(CAST(`b`.`DateOnly` AS datetime(6)), `b`.`TimeOnly`) = TIMESTAMP '2020-01-01 15:30:10' +"""); + } + + public override async Task ToDateTime_constant_DateTime_with_property_TimeOnly() + { + await base.ToDateTime_constant_DateTime_with_property_TimeOnly(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ADDTIME(CAST(DATE '1990-11-10' AS datetime(6)), `b`.`TimeOnly`) = TIMESTAMP '1990-11-10 15:30:10' +"""); + } + + public override async Task ToDateTime_with_complex_DateTime() + { + await base.ToDateTime_with_complex_DateTime(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ADDTIME(CAST(DATE_ADD(`b`.`DateOnly`, INTERVAL CAST(1 AS signed) year) AS datetime(6)), `b`.`TimeOnly`) = TIMESTAMP '2021-01-01 15:30:10' +"""); + } + + public override async Task ToDateTime_with_complex_TimeOnly() + { + await base.ToDateTime_with_complex_TimeOnly(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE ADDTIME(CAST(`b`.`DateOnly` AS datetime(6)), DATE_ADD(`b`.`TimeOnly`, INTERVAL CAST(1.0 AS signed) hour)) = TIMESTAMP '2020-01-01 16:30:10' +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsMySqlTest.cs new file mode 100644 index 000000000..370f2c7d4 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsMySqlTest.cs @@ -0,0 +1,248 @@ +using System; +using System.Threading.Tasks; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; +using Xunit.Sdk; + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Temporal; + +public class DateTimeOffsetTranslationsMySqlTest : DateTimeOffsetTranslationsTestBase +{ + public DateTimeOffsetTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + // Not supported by design (DateTimeOffset with non-zero offset) + public override Task Now() + => Assert.ThrowsAsync(() => base.Now()); + + public override async Task UtcNow() + { + await base.UtcNow(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`DateTimeOffset` <> UTC_TIMESTAMP(6) +"""); + } + + // The test compares with new DateTimeOffset().Date, which MySql sends as -infinity, causing a discrepancy with the client behavior + // which uses 1/1/1:0:0:0 + public override Task Date() + => Assert.ThrowsAsync(() => base.Date()); + + public override async Task Year() + { + await base.Year(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(year FROM `b`.`DateTimeOffset`) = 1998 +"""); + } + + public override async Task Month() + { + await base.Month(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(month FROM `b`.`DateTimeOffset`) = 5 +"""); + } + + public override async Task DayOfYear() + { + await base.DayOfYear(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DAYOFYEAR(`b`.`DateTimeOffset`) = 124 +"""); + } + + public override async Task Day() + { + await base.Day(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(day FROM `b`.`DateTimeOffset`) = 4 +"""); + } + + public override async Task Hour() + { + await base.Hour(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(hour FROM `b`.`DateTimeOffset`) = 15 +"""); + } + + public override async Task Minute() + { + await base.Minute(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(minute FROM `b`.`DateTimeOffset`) = 30 +"""); + } + + public override async Task Second() + { + await base.Second(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(second FROM `b`.`DateTimeOffset`) = 10 +"""); + } + + // SQL translation not implemented, too annoying + public override Task Millisecond() + => AssertTranslationFailed(() => base.Millisecond()); + + // TODO: #3406 + public override Task Microsecond() + => AssertTranslationFailed(() => base.Microsecond()); + + // TODO: #3406 + public override Task Nanosecond() + => AssertTranslationFailed(() => base.Nanosecond()); + + public override async Task TimeOfDay() + { + await base.TimeOfDay(); + + AssertSql( +""" +SELECT CAST(`b`.`DateTimeOffset` AS time(6)) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task AddYears() + { + await base.AddYears(); + + AssertSql( +""" +SELECT DATE_ADD(`b`.`DateTimeOffset`, INTERVAL CAST(1 AS signed) year) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task AddMonths() + { + await base.AddMonths(); + + AssertSql( +""" +SELECT DATE_ADD(`b`.`DateTimeOffset`, INTERVAL CAST(1 AS signed) month) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task AddDays() + { + await base.AddDays(); + + AssertSql( +""" +SELECT DATE_ADD(`b`.`DateTimeOffset`, INTERVAL CAST(1.0 AS signed) day) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task AddHours() + { + await base.AddHours(); + + AssertSql( +""" +SELECT DATE_ADD(`b`.`DateTimeOffset`, INTERVAL CAST(1.0 AS signed) hour) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task AddMinutes() + { + await base.AddMinutes(); + + AssertSql( +""" +SELECT DATE_ADD(`b`.`DateTimeOffset`, INTERVAL CAST(1.0 AS signed) minute) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task AddSeconds() + { + await base.AddSeconds(); + + AssertSql( +""" +SELECT DATE_ADD(`b`.`DateTimeOffset`, INTERVAL CAST(1.0 AS signed) second) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override async Task AddMilliseconds() + { + await base.AddMilliseconds(); + + AssertSql( +""" +SELECT DATE_ADD(`b`.`DateTimeOffset`, INTERVAL 1000 * CAST(300.0 AS signed) microsecond) +FROM `BasicTypesEntities` AS `b` +"""); + } + + public override Task ToUnixTimeMilliseconds() + => AssertTranslationFailed(() => base.ToUnixTimeMilliseconds()); + + public override Task ToUnixTimeSecond() + => AssertTranslationFailed(() => base.ToUnixTimeSecond()); + + public override async Task Milliseconds_parameter_and_constant() + { + await base.Milliseconds_parameter_and_constant(); + + AssertSql( +""" +SELECT COUNT(*) +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`DateTimeOffset` = TIMESTAMP '1902-01-02 08:30:00.123456' +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateTimeTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateTimeTranslationsMySqlTest.cs new file mode 100644 index 000000000..e987a2f7d --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateTimeTranslationsMySqlTest.cs @@ -0,0 +1,261 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Temporal; + +/// +/// Note that is mapped to PG timestamp with time zone, as is the provider default; +/// this causes issues with various tests. See also , which +/// explicitly maps to timestamp without time zone. +/// +public class DateTimeTranslationsMySqlTest : DateTimeTranslationsTestBase +{ + public DateTimeTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Now() + { + await base.Now(); + + AssertSql( +""" +@myDatetime='2015-04-10T00:00:00.0000000' (DbType = DateTime) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CURRENT_TIMESTAMP(6) <> @myDatetime +"""); + } + + public override async Task UtcNow() + { + // Overriding to set Kind=Utc for timestamptz + var myDatetime = DateTime.SpecifyKind(new DateTime(2015, 4, 10), DateTimeKind.Utc); + + await AssertQuery( + ss => ss.Set().Where(c => DateTime.UtcNow != myDatetime)); + + AssertSql( +""" +@myDatetime='2015-04-10T00:00:00.0000000Z' (DbType = DateTime) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE UTC_TIMESTAMP(6) <> @myDatetime +"""); + } + + // DateTime.Today returns a Local DateTime, which can't be compared with timestamptz + // (see TemporalTranslationsMySqlTimestampWithoutTimeZoneTest for a working version of this test) + public override Task Today() + => Assert.ThrowsAsync(() => base.Today()); + + public override async Task Date() + { + // Overriding to set Kind=Utc for timestamptz + var myDatetime = DateTime.SpecifyKind(new DateTime(1998, 5, 4), DateTimeKind.Utc); + + await AssertQuery( + ss => ss.Set().Where(o => o.DateTime.Date == myDatetime)); + + AssertSql( +""" +@myDatetime='1998-05-04T00:00:00.0000000Z' (DbType = DateTime) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CONVERT(`b`.`DateTime`, date) = @myDatetime +"""); + } + + public override async Task AddYear() + { + await base.AddYear(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(year FROM DATE_ADD(`b`.`DateTime`, INTERVAL CAST(1 AS signed) year)) = 1999 +"""); + } + + public override async Task Year() + { + await base.Year(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(year FROM `b`.`DateTime`) = 1998 +"""); + } + + public override async Task Month() + { + await base.Month(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(month FROM `b`.`DateTime`) = 5 +"""); + } + + public override async Task DayOfYear() + { + await base.DayOfYear(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DAYOFYEAR(`b`.`DateTime`) = 124 +"""); + } + + public override async Task Day() + { + await base.Day(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(day FROM `b`.`DateTime`) = 4 +"""); + } + + public override async Task Hour() + { + await base.Hour(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(hour FROM `b`.`DateTime`) = 15 +"""); + } + + public override async Task Minute() + { + await base.Minute(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(minute FROM `b`.`DateTime`) = 30 +"""); + } + + public override async Task Second() + { + await base.Second(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(second FROM `b`.`DateTime`) = 10 +"""); + } + + // SQL translation not implemented, too annoying + public override Task Millisecond() + => AssertTranslationFailed(() => base.Millisecond()); + + public override async Task TimeOfDay() + { + await base.TimeOfDay(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE CAST(`b`.`DateTime` AS time(6)) = TIME '00:00:00' +"""); + } + + public override async Task subtract_and_TotalDays() + { + // Overriding to set Kind=Utc for timestamptz + var date = DateTime.SpecifyKind(new DateTime(1997, 1, 1), DateTimeKind.Utc); + + await AssertQuery( + ss => ss.Set().Where(o => (o.DateTime - date).TotalDays > 365)); + + AssertSql( + """ +@date='1997-01-01T00:00:00.0000000Z' (DbType = DateTime) + +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_part('epoch', b."DateTime" - @date) / 86400.0 > 365.0 +"""); + } + + // DateTime.Parse() returns either a Local or Unspecified DateTime, which can't be compared with timestamptz + // (see TemporalTranslationsMySqlTimestampWithoutTimeZoneTest for a working version of this test) + public override Task Parse_with_constant() + => Assert.ThrowsAsync(() => base.Parse_with_constant()); + + // DateTime.Parse() returns either a Local or Unspecified DateTime, which can't be compared with timestamptz + // (see TemporalTranslationsMySqlTimestampWithoutTimeZoneTest for a working version of this test) + public override Task Parse_with_parameter() + => Assert.ThrowsAsync(() => base.Parse_with_parameter()); + + public override async Task New_with_constant() + { + // Overriding to set Kind=Utc for timestamptz + await AssertQuery( + ss => ss.Set().Where(o => o.DateTime == new DateTime(1998, 5, 4, 15, 30, 10, DateTimeKind.Utc))); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`DateTime` = TIMESTAMP '1998-05-04 15:30:10' +"""); + } + + public override async Task New_with_parameters() + { + // Overriding to set Kind=Utc for timestamptz + var year = 1998; + var month = 5; + var date = 4; + var hour = 15; + + await AssertQuery( + ss => ss.Set().Where(o => o.DateTime == new DateTime(year, month, date, hour, 30, 10, DateTimeKind.Utc))); + + AssertSql( +""" +@p='1998-05-04T15:30:10.0000000Z' (DbType = DateTime) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`DateTime` = @p +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateTimeTranslationsWithoutTimeZoneTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateTimeTranslationsWithoutTimeZoneTest.cs new file mode 100644 index 000000000..90c29f493 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/DateTimeTranslationsWithoutTimeZoneTest.cs @@ -0,0 +1,322 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +#nullable enable + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Temporal; + +/// +/// Same as , but the property is mapped to a PostgreSQL +/// timestamp without time zone, which corresponds to a with +/// . +/// +public class DateTimeTranslationsWithoutTimeZoneTest + : DateTimeTranslationsTestBase +{ + public DateTimeTranslationsWithoutTimeZoneTest( + BasicTypesQueryMySqlTimestampWithoutTimeZoneFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Now() + { + await base.Now(); + + AssertSql( + """ +@myDatetime='2015-04-10T00:00:00.0000000' + +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE now()::timestamp <> @myDatetime +"""); + } + + public override async Task UtcNow() + { + // Overriding to set Kind=Utc for timestamptz. This test generally doesn't make much sense here. + var myDatetime = DateTime.SpecifyKind(new DateTime(2015, 4, 10), DateTimeKind.Utc); + + await AssertQuery( + ss => ss.Set().Where(c => DateTime.UtcNow != myDatetime)); + + AssertSql( + """ +@myDatetime='2015-04-10T00:00:00.0000000Z' (DbType = DateTime) + +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE now() <> @myDatetime +"""); + } + + public override async Task Today() + { + await base.Today(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE b."DateTime" = date_trunc('day', now()::timestamp) +"""); + } + + public override async Task Date() + { + await base.Date(); + + AssertSql( + """ +@myDatetime='1998-05-04T00:00:00.0000000' + +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_trunc('day', b."DateTime") = @myDatetime +"""); + } + + public override async Task AddYear() + { + await base.AddYear(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_part('year', b."DateTime" + INTERVAL '1 years')::int = 1999 +"""); + } + + public override async Task Year() + { + await base.Year(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_part('year', b."DateTime")::int = 1998 +"""); + } + + public override async Task Month() + { + await base.Month(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_part('month', b."DateTime")::int = 5 +"""); + } + + public override async Task DayOfYear() + { + await base.DayOfYear(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_part('doy', b."DateTime")::int = 124 +"""); + } + + public override async Task Day() + { + await base.Day(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_part('day', b."DateTime")::int = 4 +"""); + } + + public override async Task Hour() + { + await base.Hour(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_part('hour', b."DateTime")::int = 15 +"""); + } + + public override async Task Minute() + { + await base.Minute(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_part('minute', b."DateTime")::int = 30 +"""); + } + + public override async Task Second() + { + await base.Second(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_part('second', b."DateTime")::int = 10 +"""); + } + + // SQL translation not implemented, too annoying + public override Task Millisecond() + => AssertTranslationFailed(() => base.Millisecond()); + + public override async Task TimeOfDay() + { + await base.TimeOfDay(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE b."DateTime"::time = TIME '00:00:00' +"""); + } + + public override async Task subtract_and_TotalDays() + { + await base.subtract_and_TotalDays(); + + AssertSql( + """ +@date='1997-01-01T00:00:00.0000000' + +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE date_part('epoch', b."DateTime" - @date) / 86400.0 > 365.0 +"""); + } + + public override async Task Parse_with_constant() + { + await base.Parse_with_constant(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE b."DateTime" = TIMESTAMP '1998-05-04T15:30:10' +"""); + } + + public override async Task Parse_with_parameter() + { + await base.Parse_with_parameter(); + + AssertSql( + """ +@Parse='1998-05-04T15:30:10.0000000' + +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE b."DateTime" = @Parse +"""); + } + + public override async Task New_with_constant() + { + await base.New_with_constant(); + + AssertSql( + """ +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE b."DateTime" = TIMESTAMP '1998-05-04T15:30:10' +"""); + } + + public override async Task New_with_parameters() + { + await base.New_with_parameters(); + + AssertSql( + """ +@p='1998-05-04T15:30:10.0000000' + +SELECT b."Id", b."Bool", b."Byte", b."ByteArray", b."DateOnly", b."DateTime", b."DateTimeOffset", b."Decimal", b."Double", b."Enum", b."FlagsEnum", b."Float", b."Guid", b."Int", b."Long", b."Short", b."String", b."TimeOnly", b."TimeSpan" +FROM "BasicTypesEntities" AS b +WHERE b."DateTime" = @p +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + public class BasicTypesQueryMySqlTimestampWithoutTimeZoneFixture : BasicTypesQueryMySqlFixture + { + private BasicTypesData? _expectedData; + + protected override string StoreName + => "BasicTypesTimestampWithoutTimeZoneTest"; + + protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) + { + base.OnModelCreating(modelBuilder, context); + + modelBuilder.Entity().Property(b => b.DateTime).HasColumnType("timestamp without time zone"); + modelBuilder.Entity().Property(b => b.DateTime).HasColumnType("timestamp without time zone"); + } + + protected override Task SeedAsync(BasicTypesContext context) + { + _expectedData ??= LoadAndTweakData(); + context.AddRange(_expectedData.BasicTypesEntities); + context.AddRange(_expectedData.NullableBasicTypesEntities); + return context.SaveChangesAsync(); + } + + public override ISetSource GetExpectedData() + => _expectedData ??= LoadAndTweakData(); + + private BasicTypesData LoadAndTweakData() + { + var data = (BasicTypesData)base.GetExpectedData(); + + foreach (var item in data.BasicTypesEntities) + { + // Change Kind fo all DateTimes from Utc to Unspecified, as we're mapping to 'timestamp without time zone' + item.DateTime = DateTime.SpecifyKind(item.DateTime, DateTimeKind.Unspecified); + } + + // Do the same for the nullable counterparts + foreach (var item in data.NullableBasicTypesEntities) + { + if (item.DateTime.HasValue) + { + item.DateTime = DateTime.SpecifyKind(item.DateTime.Value, DateTimeKind.Unspecified); + } + } + + return data; + } + } +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/TimeOnlyTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/TimeOnlyTranslationsMySqlTest.cs new file mode 100644 index 000000000..51c8a726e --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/TimeOnlyTranslationsMySqlTest.cs @@ -0,0 +1,213 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Temporal; + +public class TimeOnlyTranslationsMySqlTest : TimeOnlyTranslationsTestBase +{ + public TimeOnlyTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Hour() + { + await base.Hour(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(hour FROM `b`.`TimeOnly`) = 15 +"""); + } + + public override async Task Minute() + { + await base.Minute(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(minute FROM `b`.`TimeOnly`) = 30 +"""); + } + + public override async Task Second() + { + await base.Second(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(second FROM `b`.`TimeOnly`) = 10 +"""); + } + + // Translation not yet implemented + public override Task Millisecond() + => AssertTranslationFailed(() => base.Millisecond()); + + // Translation not yet implemented + public override Task Microsecond() + => AssertTranslationFailed(() => base.Millisecond()); + + // Probably not relevant for PostgreSQL, which supports microsecond precision only + public override Task Nanosecond() + => AssertTranslationFailed(() => base.Millisecond()); + + public override async Task AddHours() + { + await base.AddHours(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DATE_ADD(`b`.`TimeOnly`, INTERVAL CAST(3.0 AS signed) hour) = TIME '18:30:10' +"""); + } + + public override async Task AddMinutes() + { + await base.AddMinutes(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE DATE_ADD(`b`.`TimeOnly`, INTERVAL CAST(3.0 AS signed) minute) = TIME '15:33:10' +"""); + } + + public override async Task Add_TimeSpan() + { + await base.Add_TimeSpan(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`TimeOnly` + TIME '03:00:00') = TIME '18:30:10' +"""); + } + + public override async Task IsBetween() + { + await base.IsBetween(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`TimeOnly` >= TIME '14:00:00') & (`b`.`TimeOnly` < TIME '16:00:00') +"""); + } + + public override async Task Subtract() + { + await base.Subtract(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (`b`.`TimeOnly` - TIME '03:00:00') = TIME '12:30:10' +"""); + } + + public override async Task FromDateTime_compared_to_property() + { + await base.FromDateTime_compared_to_property(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TIME(`b`.`DateTime`) = `b`.`TimeOnly` +"""); + } + + public override async Task FromDateTime_compared_to_parameter() + { + await base.FromDateTime_compared_to_parameter(); + + AssertSql( +""" +@time='15:30' (DbType = Time) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TIME(`b`.`DateTime`) = @time +"""); + } + + public override async Task FromDateTime_compared_to_constant() + { + await base.FromDateTime_compared_to_constant(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE TIME(`b`.`DateTime`) = TIME '15:30:10' +"""); + } + + public override async Task FromTimeSpan_compared_to_property() + { + await base.FromTimeSpan_compared_to_property(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`TimeSpan` < `b`.`TimeOnly` +"""); + } + + public override async Task FromTimeSpan_compared_to_parameter() + { + await base.FromTimeSpan_compared_to_parameter(); + + AssertSql( +""" +@time='01:02' (DbType = Time) + +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE `b`.`TimeSpan` = @time +"""); + } + + public override async Task Order_by_FromTimeSpan() + { + // TODO: Base implementation is non-deterministic, remove this override once that's fixed on the EF side. + await AssertQuery( + ss => ss.Set().OrderBy(x => TimeOnly.FromTimeSpan(x.TimeSpan)).ThenBy(x => x.Id), + assertOrder: true); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +ORDER BY `b`.`TimeSpan`, `b`.`Id` +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/TimeSpanTranslationsMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/TimeSpanTranslationsMySqlTest.cs new file mode 100644 index 000000000..4bd67b517 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/Temporal/TimeSpanTranslationsMySqlTest.cs @@ -0,0 +1,78 @@ +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query.Translations.Temporal; + +public class TimeSpanTranslationsMySqlTest : TimeSpanTranslationsTestBase +{ + public TimeSpanTranslationsMySqlTest(BasicTypesQueryMySqlFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Hours() + { + await base.Hours(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(hour FROM `b`.`TimeSpan`) = 3 +"""); + } + + public override async Task Minutes() + { + await base.Minutes(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(minute FROM `b`.`TimeSpan`) = 4 +"""); + } + + public override async Task Seconds() + { + await base.Seconds(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE EXTRACT(second FROM `b`.`TimeSpan`) = 5 +"""); + } + + public override async Task Milliseconds() + { + await base.Milliseconds(); + + AssertSql( +""" +SELECT `b`.`Id`, `b`.`Bool`, `b`.`Byte`, `b`.`ByteArray`, `b`.`DateOnly`, `b`.`DateTime`, `b`.`DateTimeOffset`, `b`.`Decimal`, `b`.`Double`, `b`.`Enum`, `b`.`FlagsEnum`, `b`.`Float`, `b`.`Guid`, `b`.`Int`, `b`.`Long`, `b`.`Short`, `b`.`String`, `b`.`TimeOnly`, `b`.`TimeSpan` +FROM `BasicTypesEntities` AS `b` +WHERE (EXTRACT(microsecond FROM `b`.`TimeSpan`)) DIV (1000) = 678 +"""); + } + + public override Task Microseconds() + => AssertTranslationFailed(() => base.Microseconds()); + + public override Task Nanoseconds() + => AssertTranslationFailed(() => base.Nanoseconds()); + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => MySqlTestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.MySql.FunctionalTests/Query/Translations/TimestampTranslationsTest.cs b/test/EFCore.MySql.FunctionalTests/Query/Translations/TimestampTranslationsTest.cs new file mode 100644 index 000000000..d45994da8 --- /dev/null +++ b/test/EFCore.MySql.FunctionalTests/Query/Translations/TimestampTranslationsTest.cs @@ -0,0 +1,1014 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +// The EF Core specification test suite has: +// +// * Northwind Orders.OrderDate and others: DateTime mapped to 'timestamp without time zone' (so Unspecified/Local) +// * GearsOfWar Mission.Timeline: DateTimeOffset (mapped to 'timestamp with time zone') +// +// But there's no DateTime mapped to 'timestamp with time zone' (so Utc). +// This test suite checks this and various PG-specific things. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class TimestampTranslationsTest : QueryTestBase +{ + // ReSharper disable once UnusedParameter.Local + public TimestampTranslationsTest(TimestampQueryFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Basic mapping + + [ConditionalFact] + public void DateTime_maps_to_timestamptz_by_default() + { + using var ctx = CreateContext(); + + Assert.Equal( + "timestamp with time zone", + ctx.Model.GetEntityTypes().Single().GetProperty(nameof(Entity.TimestamptzDateTime)).GetColumnType()); + } + + [ConditionalFact] + public void DateTime_array_maps_to_timestamptz_by_default() + { + using var ctx = CreateContext(); + + Assert.Equal( + "timestamp with time zone[]", + ctx.Model.GetEntityTypes().Single().GetProperty(nameof(Entity.TimestamptzDateTimeArray)).GetColumnType()); + } + + [ConditionalFact] + public async Task Cannot_insert_utc_datetime_into_timestamp() + { + await using var ctx = CreateContext(); + + ctx.Entities.Add(new Entity { TimestampDateTime = DateTime.UtcNow }); + var exception = await Assert.ThrowsAsync(() => ctx.SaveChangesAsync()); + Assert.IsType(exception.InnerException); + } + + [ConditionalFact] + public async Task Cannot_insert_unspecified_datetime_into_timestamptz() + { + await using var ctx = CreateContext(); + + ctx.Entities.Add(new Entity { TimestamptzDateTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Unspecified) }); + var exception = await Assert.ThrowsAsync(() => ctx.SaveChangesAsync()); + Assert.IsType(exception.InnerException); + } + + [ConditionalFact] + public async Task Cannot_insert_local_datetime_into_timestamptz() + { + await using var ctx = CreateContext(); + + ctx.Entities.Add(new Entity { TimestamptzDateTime = DateTime.Now }); + var exception = await Assert.ThrowsAsync(() => ctx.SaveChangesAsync()); + Assert.IsType(exception.InnerException); + } + + #endregion Basic mapping + + #region Comparisons + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task Compare_timestamp_column_to_local_DateTime_literal(bool async) + { + // Note that we're in the Europe/Berlin timezone (see MySqlTestStore below) + await AssertQuery( + async, + ss => ss.Set().Where(e => e.TimestampDateTime == new DateTime(1998, 4, 12, 15, 26, 38, DateTimeKind.Local))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestampDateTime" = TIMESTAMP '1998-04-12T15:26:38' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task Compare_timestamp_column_to_local_DateTime_parameter(bool async) + { + var dateTime = new DateTime(1998, 4, 12, 15, 26, 38, DateTimeKind.Local); + + await AssertQuery( + async, + ss => ss.Set().Where(e => e.TimestampDateTime == dateTime)); + + // The string representation of our local DateTime is generated with the local time zone (by the EF Core test infra), + // so we can't assert on it. + Assert.Contains( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestampDateTime" = @dateTime +""", + Fixture.TestSqlLoggerFactory.SqlStatements.Single()); + } + + // Compare_timestamp_column_to_unspecified_DateTime_literal: requires translating DateTime.SpecifyKind + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task Compare_timestamp_column_to_unspecified_DateTime_parameter(bool async) + { + var dateTime = new DateTime(1998, 4, 12, 15, 26, 38, DateTimeKind.Unspecified); + + await AssertQuery( + async, + ss => ss.Set().Where(e => e.TimestampDateTime == dateTime)); + + AssertSql( + """ +@dateTime='1998-04-12T15:26:38.0000000' + +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestampDateTime" = @dateTime +"""); + } + + [ConditionalFact] + public async Task Cannot_compare_timestamp_column_to_utc_DateTime_literal() + { + await using var ctx = CreateContext(); + + await Assert.ThrowsAsync( + () => ctx.Entities.Where(e => e.TimestampDateTime == new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Utc)) + .ToListAsync()); + } + + [ConditionalFact] + public async Task Cannot_compare_timestamp_column_to_utc_DateTime_parameter() + { + await using var ctx = CreateContext(); + + var dateTime = new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Utc); + + await Assert.ThrowsAsync( + () => ctx.Entities.Where(e => e.TimestampDateTime == dateTime) + .ToListAsync()); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task Compare_timestamptz_column_to_utc_DateTime_literal(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => e.TimestamptzDateTime == new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Utc))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestamptzDateTime" = TIMESTAMPTZ '1998-04-12T13:26:38Z' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task Compare_timestamptz_column_to_utc_DateTime_parameter(bool async) + { + var dateTime = new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Utc); + + await AssertQuery( + async, + ss => ss.Set().Where(e => e.TimestamptzDateTime == dateTime)); + + AssertSql( + """ +@dateTime='1998-04-12T13:26:38.0000000Z' (DbType = DateTime) + +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestamptzDateTime" = @dateTime +"""); + } + + [ConditionalFact] + public async Task Cannot_compare_timestamptz_column_to_local_DateTime_literal() + { + await using var ctx = CreateContext(); + + await Assert.ThrowsAsync( + () => ctx.Entities.Where(e => e.TimestamptzDateTime == new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Local)) + .ToListAsync()); + } + + [ConditionalFact] + public async Task Cannot_compare_timestamptz_column_to_local_DateTime_parameter() + { + await using var ctx = CreateContext(); + + var dateTime = new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Local); + + await Assert.ThrowsAsync( + () => ctx.Entities.Where(e => e.TimestamptzDateTime == dateTime) + .ToListAsync()); + } + + [ConditionalFact] + public async Task Cannot_compare_timestamptz_column_to_unspecified_DateTime_literal() + { + await using var ctx = CreateContext(); + + await Assert.ThrowsAsync( + () => ctx.Entities.Where(e => e.TimestamptzDateTime == new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Unspecified)) + .ToListAsync()); + } + + [ConditionalFact] + public async Task Cannot_compare_timestamptz_column_to_unspecified_DateTime_parameter() + { + await using var ctx = CreateContext(); + + var dateTime = new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Unspecified); + + await Assert.ThrowsAsync( + () => ctx.Entities.Where(e => e.TimestamptzDateTime == dateTime) + .ToListAsync()); + } + + [ConditionalFact] + public async Task Cannot_compare_timestamptz_column_to_timestamp_column() + { + await using var ctx = CreateContext(); + + await Assert.ThrowsAsync( + () => ctx.Entities.Where(e => e.TimestamptzDateTime == e.TimestampDateTime) + .ToListAsync()); + } + + [ConditionalFact] + public async Task Compare_timestamptz_column_to_timestamp_column_with_ToUniversalTime() + { + await using var ctx = CreateContext(); + + // We can't use AssertQuery since the local (expected) evaluation is dependent on the machine's timezone, which is out of + // our control. + var count = await ctx.Set() + .Where(e => e.TimestamptzDateTime == e.TimestampDateTime.ToUniversalTime()) + .CountAsync(); + + Assert.Equal(1, count); + + AssertSql( + """ +SELECT count(*)::int +FROM "Entities" AS e +WHERE e."TimestamptzDateTime" = e."TimestampDateTime"::timestamptz +"""); + } + + [ConditionalFact] + public async Task Compare_timestamptz_column_to_timestamp_column_with_ToLocalTime() + { + await using var ctx = CreateContext(); + + // We can't use AssertQuery since the local (expected) evaluation is dependent on the machine's timezone, which is out of + // our control. + var count = await ctx.Set() + .Where(e => e.TimestamptzDateTime.ToLocalTime() == e.TimestampDateTime) + .CountAsync(); + + Assert.Equal(1, count); + + AssertSql( + """ +SELECT count(*)::int +FROM "Entities" AS e +WHERE e."TimestamptzDateTime"::timestamp = e."TimestampDateTime" +"""); + } + + #endregion Comparisons + + #region Now + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_datetime_now(bool async) + { + var myDatetime = new DateTime(2015, 4, 10); + + await AssertQuery( + async, + ss => ss.Set().Where(c => DateTime.Now != myDatetime)); + + AssertSql( + """ +@myDatetime='2015-04-10T00:00:00.0000000' + +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE now()::timestamp <> @myDatetime +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_datetime_utcnow(bool async) + { + var myDatetime = new DateTime(2015, 4, 10, 0, 0, 0, DateTimeKind.Utc); + + await AssertQuery( + async, + ss => ss.Set().Where(c => DateTime.UtcNow != myDatetime)); + + AssertSql( + """ +@myDatetime='2015-04-10T00:00:00.0000000Z' (DbType = DateTime) + +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE now() <> @myDatetime +"""); + } + + #endregion Now + + #region Date member + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_datetime_date_on_timestamptz(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => e.TimestamptzDateTime.Date == new DateTime(1998, 4, 12, 0, 0, 0, DateTimeKind.Utc))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE date_trunc('day', e."TimestamptzDateTime", 'UTC') = TIMESTAMPTZ '1998-04-12T00:00:00Z' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_datetime_date_on_timestamp(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => e.TimestampDateTime.Date == new DateTime(1998, 4, 12, 0, 0, 0, DateTimeKind.Local))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE date_trunc('day', e."TimestampDateTime") = TIMESTAMP '1998-04-12T00:00:00' +"""); + } + + #endregion + + #region DateTimeOffset + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task DateTimeOffset_DateTime(bool async) + { + // We only support UTC DateTimeOffset, so DateTimeOffset.DateTime is just a matter of converting to timestamp without time zone + await AssertQuery( + async, + ss => ss.Set().Where( + e => e.TimestampDateTimeOffset.DateTime == new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Unspecified))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestampDateTimeOffset" AT TIME ZONE 'UTC' = TIMESTAMP '1998-04-12T13:26:38' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task DateTimeOffset_UtcDateTime(bool async) + { + // We only support UTC DateTimeOffset, so DateTimeOffset.UtcDateTime does nothing (type change on CLR change, no change on the + // PG side. + await AssertQuery( + async, + ss => ss.Set().Where( + e => e.TimestampDateTimeOffset.UtcDateTime == new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Utc))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestampDateTimeOffset" = TIMESTAMPTZ '1998-04-12T13:26:38Z' +"""); + } + + [ConditionalFact] + public async Task DateTimeOffset_LocalDateTime() + { + // Note that we're in the Europe/Berlin timezone (see MySqlTestStore below) + + // We can't use AssertQuery since the local (expected) evaluation is dependent on the machine's timezone, which is out of + // our control. + await using var ctx = CreateContext(); + + var count = await ctx.Set() + .Where(e => e.TimestampDateTimeOffset.LocalDateTime == new DateTime(1998, 4, 12, 15, 26, 38, DateTimeKind.Local)) + .CountAsync(); + + Assert.Equal(1, count); + + AssertSql( + """ +SELECT count(*)::int +FROM "Entities" AS e +WHERE e."TimestampDateTimeOffset"::timestamp = TIMESTAMP '1998-04-12T15:26:38' +"""); + } + + [ConditionalTheory] // #2220 + [MemberData(nameof(IsAsyncData))] + public async Task DateTimeOffset_Date_project(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Select(e => new { e.TimestampDateTimeOffset.Date })); + + AssertSql( + """ +SELECT date_trunc('day', e."TimestampDateTimeOffset" AT TIME ZONE 'UTC') AS "Date" +FROM "Entities" AS e +"""); + + // Additional check to make sure Unspecified DateTimes are returned, as per the .NET DateTimeOffset.Date behavior + // (AssertQuery above doesn't confirm this since Kind isn't taken into account for DateTime comparisons) + await using var ctx = CreateContext(); + + foreach (var date in ctx.Set().Select(e => e.TimestampDateTimeOffset.Date)) + { + Assert.Equal(DateTimeKind.Unspecified, date.Kind); + } + } + + #endregion DateTimeOffset + + #region DateTime constructors + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_datetime_ctor1(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => + new DateTime(e.TimestampDateTime.Year, e.TimestampDateTime.Month, 1) == new DateTime(1998, 4, 12)), + assertEmpty: true); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE make_date(date_part('year', e."TimestampDateTime")::int, date_part('month', e."TimestampDateTime")::int, 1) = TIMESTAMP '1998-04-12T00:00:00' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_datetime_ctor2(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => + new DateTime(e.TimestampDateTime.Year, e.TimestampDateTime.Month, 1, 0, 0, 0) == new DateTime(1998, 4, 12)), + assertEmpty: true); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE make_timestamp(date_part('year', e."TimestampDateTime")::int, date_part('month', e."TimestampDateTime")::int, 1, 0, 0, 0::double precision) = TIMESTAMP '1998-04-12T00:00:00' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_datetime_ctor3_local(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => + new DateTime(e.TimestampDateTime.Year, e.TimestampDateTime.Month, 1, 0, 0, 0, DateTimeKind.Local) + == new DateTime(1996, 9, 11)), + assertEmpty: true); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE make_timestamp(date_part('year', e."TimestampDateTime")::int, date_part('month', e."TimestampDateTime")::int, 1, 0, 0, 0::double precision) = TIMESTAMP '1996-09-11T00:00:00' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_datetime_ctor3_utc(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + o => + new DateTime(o.TimestamptzDateTime.Year, o.TimestamptzDateTime.Month, 1, 0, 0, 0, DateTimeKind.Utc) + == new DateTime(1998, 4, 1, 0, 0, 0, DateTimeKind.Utc))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE make_timestamptz(date_part('year', e."TimestamptzDateTime" AT TIME ZONE 'UTC')::int, date_part('month', e."TimestamptzDateTime" AT TIME ZONE 'UTC')::int, 1, 0, 0, 0::double precision, 'UTC') = TIMESTAMPTZ '1998-04-01T00:00:00Z' +"""); + } + + #endregion DateTime constructors + + #region SpecifyKind + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task DateTime_SpecifyKind_on_timestamp_to_utc(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => DateTime.SpecifyKind(e.TimestampDateTime, DateTimeKind.Utc) + == new DateTime(1998, 4, 12, 15, 26, 38, DateTimeKind.Utc))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestampDateTime" AT TIME ZONE 'UTC' = TIMESTAMPTZ '1998-04-12T15:26:38Z' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task DateTime_SpecifyKind_on_timestamptz_to_unspecified(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => DateTime.SpecifyKind(e.TimestamptzDateTime, DateTimeKind.Unspecified) + == new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Unspecified))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestamptzDateTime" AT TIME ZONE 'UTC' = TIMESTAMP '1998-04-12T13:26:38' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task DateTime_SpecifyKind_on_timestamptz_to_local(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => DateTime.SpecifyKind(e.TimestamptzDateTime, DateTimeKind.Local) + == new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Unspecified))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestamptzDateTime" AT TIME ZONE 'UTC' = TIMESTAMP '1998-04-12T13:26:38' +"""); + } + + [ConditionalFact] + public async Task DateTime_SpecifyKind_with_parameter_kind_throws() + { + await using var ctx = CreateContext(); + + var kind = DateTimeKind.Local; + + var exception = await Assert.ThrowsAsync( + () => ctx.Set().Where(e => DateTime.SpecifyKind(e.TimestamptzDateTime, kind) == default).ToListAsync()); + + Assert.Equal("Translating SpecifyKind is only supported with a constant Kind argument", exception.Message); + } + + #endregion SpecifyKind + + #region Time zone conversions + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_ConvertTimeBySystemTimeZoneId_on_DateTime_timestamptz_column(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + c => TimeZoneInfo.ConvertTimeBySystemTimeZoneId(c.TimestamptzDateTime, "Europe/Berlin") + == new DateTime(1998, 4, 12, 15, 26, 38))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestamptzDateTime" AT TIME ZONE 'Europe/Berlin' = TIMESTAMP '1998-04-12T15:26:38' +"""); + } + + [ConditionalFact] + public virtual async Task Where_ConvertTimeBySystemTimeZoneId_fails_on_DateTime_timestamp_column() + { + await using var ctx = CreateContext(); + + await Assert.ThrowsAsync( + () => ctx.Set().Where( + c => TimeZoneInfo.ConvertTimeBySystemTimeZoneId(c.TimestampDateTime, "Europe/Berlin") + == new DateTime(1998, 4, 12, 15, 26, 38)).ToListAsync()); + } + + [ConditionalFact] + public virtual async Task Where_ConvertTimeToUtc_on_DateTime_timestamp_column() + { + // We can't use AssertQuery since the local (expected) evaluation is dependent on the machine's timezone, which is out of + // our control. + await using var ctx = CreateContext(); + + var count = await ctx.Set() + .Where(e => TimeZoneInfo.ConvertTimeToUtc(e.TimestampDateTime) == new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Utc)) + .CountAsync(); + + Assert.Equal(1, count); + + AssertSql( + """ +SELECT count(*)::int +FROM "Entities" AS e +WHERE e."TimestampDateTime"::timestamptz = TIMESTAMPTZ '1998-04-12T13:26:38Z' +"""); + } + + [ConditionalFact] + public virtual async Task Where_ConvertTimeToUtc_fails_on_DateTime_timestamptz_column() + { + await using var ctx = CreateContext(); + + await Assert.ThrowsAsync( + () => ctx.Set().Where( + c => TimeZoneInfo.ConvertTimeToUtc(c.TimestamptzDateTime) + == new DateTime(1998, 4, 12, 15, 26, 38, DateTimeKind.Utc)) + .ToListAsync()); + } + + #endregion Time zone conversions + + #region DateOnly + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task DateOnly_FromDateTime_with_timestamptz(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => DateOnly.FromDateTime(e.TimestamptzDateTime) == new DateOnly(1998, 4, 12))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE CAST(e."TimestamptzDateTime" AT TIME ZONE 'UTC' AS date) = DATE '1998-04-12' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task DateOnly_FromDateTime_with_timestamp(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => DateOnly.FromDateTime(e.TimestampDateTime) == new DateOnly(1998, 4, 12))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestampDateTime"::date = DATE '1998-04-12' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task DateOnly_ToDateTime_with_timestamptz(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => DateOnly.FromDateTime(e.TimestamptzDateTime).ToDateTime(new TimeOnly(15, 26, 38)) + == new DateTime(1998, 4, 12, 15, 26, 38))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE CAST(e."TimestamptzDateTime" AT TIME ZONE 'UTC' AS date) + TIME '15:26:38' = TIMESTAMP '1998-04-12T15:26:38' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task DateOnly_DayNumber(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => DateOnly.FromDateTime(e.TimestamptzDateTime).DayNumber == 729490)); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE CAST(e."TimestamptzDateTime" AT TIME ZONE 'UTC' AS date) - DATE '0001-01-01' = 729490 +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task DateOnly_DayNumber_subtraction(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => DateOnly.FromDateTime(e.TimestamptzDateTime).DayNumber - + DateOnly.FromDateTime(e.TimestamptzDateTime - TimeSpan.FromDays(3)).DayNumber == 3)); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE CAST(e."TimestamptzDateTime" AT TIME ZONE 'UTC' AS date) - CAST((e."TimestamptzDateTime" - INTERVAL '3 00:00:00') AT TIME ZONE 'UTC' AS date) = 3 +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task DateOnly_FromDayNumber(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(e => DateOnly.FromDayNumber(e.Id) == new DateOnly(0001, 01, 03))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE DATE '0001-01-01' + e."Id" = DATE '0001-01-03' +"""); + } + + #endregion DateOnly + + #region TimeOnly + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task TimeOnly_FromDateTime_with_timestamp(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => TimeOnly.FromDateTime(e.TimestampDateTime) == new TimeOnly(15, 26, 38))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE e."TimestampDateTime"::time without time zone = TIME '15:26:38' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task TimeOnly_FromDateTime_with_timestamptz(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => TimeOnly.FromDateTime(e.TimestamptzDateTime) == new TimeOnly(13, 26, 38))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE CAST(e."TimestamptzDateTime" AT TIME ZONE 'UTC' AS time without time zone) = TIME '13:26:38' +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task TimeOnly_ToTimeSpan(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where( + e => TimeOnly.FromDateTime(e.TimestamptzDateTime) == new TimeOnly(13, 26, 38))); + + AssertSql( + """ +SELECT e."Id", e."TimestampDateTime", e."TimestampDateTimeArray", e."TimestampDateTimeOffset", e."TimestampDateTimeOffsetArray", e."TimestampDateTimeRange", e."TimestamptzDateTime", e."TimestamptzDateTimeArray", e."TimestamptzDateTimeRange" +FROM "Entities" AS e +WHERE CAST(e."TimestamptzDateTime" AT TIME ZONE 'UTC' AS time without time zone) = TIME '13:26:38' +"""); + } + + #endregion TimeOnly + + #region Support + + private TimestampQueryContext CreateContext() + => Fixture.CreateContext(); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + public class TimestampQueryContext(DbContextOptions options) : PoolableDbContext(options) + { + public DbSet Entities { get; set; } + + public static async Task SeedAsync (TimestampQueryContext context) + { + context.Entities.AddRange(TimestampData.CreateEntities()); + await context.SaveChangesAsync(); + } + } + + public class Entity + { + public int Id { get; set; } + + public DateTime TimestamptzDateTime { get; set; } + + [Column(TypeName = "timestamp without time zone")] + public DateTime TimestampDateTime { get; set; } + + public DateTimeOffset TimestampDateTimeOffset { get; set; } + + public DateTime[] TimestamptzDateTimeArray { get; set; } + + [Column(TypeName = "timestamp without time zone[]")] + public DateTime[] TimestampDateTimeArray { get; set; } + + public DateTimeOffset[] TimestampDateTimeOffsetArray { get; set; } + } + + public class TimestampQueryFixture : SharedStoreFixtureBase, IQueryFixtureBase, ITestSqlLoggerFactory + { + protected override string StoreName + => "TimestampQueryTest"; + + // Set the PostgreSQL TimeZone parameter to something local, to ensure that operations which take TimeZone into account + // don't depend on the database's time zone, and also that operations which shouldn't take TimeZone into account indeed + // don't. + protected override ITestStoreFactory TestStoreFactory + => MySqlTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + private TimestampData _expectedData; + + protected override Task SeedAsync(TimestampQueryContext context) + => TimestampQueryContext.SeedAsync(context); + + public Func GetContextCreator() + => CreateContext; + + public ISetSource GetExpectedData() + => _expectedData ??= new TimestampData(); + + public IReadOnlyDictionary EntitySorters + => new Dictionary> { { typeof(Entity), e => ((Entity)e)?.Id } } + .ToDictionary(e => e.Key, e => (object)e.Value); + + public IReadOnlyDictionary EntityAsserters + => new Dictionary> + { + { + typeof(Entity), (e, a) => + { + Assert.Equal(e is null, a is null); + if (a is not null) + { + var ee = (Entity)e!; + var aa = (Entity)a; + + Assert.Equal(ee.Id, aa.Id); + + Assert.Equal(ee.TimestamptzDateTime, aa.TimestamptzDateTime); + Assert.Equal(ee.TimestampDateTime, aa.TimestampDateTime); + Assert.Equal(ee.TimestampDateTimeOffset, aa.TimestampDateTimeOffset); + + Assert.Equal(ee.TimestamptzDateTimeArray, aa.TimestamptzDateTimeArray); + Assert.Equal(ee.TimestampDateTimeArray, aa.TimestampDateTimeArray); + Assert.Equal(ee.TimestampDateTimeOffsetArray, aa.TimestampDateTimeOffsetArray); + } + } + } + }.ToDictionary(e => e.Key, e => (object)e.Value); + } + + protected class TimestampData : ISetSource + { + public IReadOnlyList Entities { get; } = CreateEntities(); + + public IQueryable Set() + where TEntity : class + { + if (typeof(TEntity) == typeof(Entity)) + { + return (IQueryable)Entities.AsQueryable(); + } + + throw new InvalidOperationException("Invalid entity type: " + typeof(TEntity)); + } + + public static IReadOnlyList CreateEntities() + { + var utcDateTime1 = new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Utc); + var localDateTime1 = new DateTime(1998, 4, 12, 15, 26, 38, DateTimeKind.Local); + var utcDateTime2 = new DateTime(2015, 1, 27, 8, 45, 12, 345, DateTimeKind.Utc); + var unspecifiedDateTime2 = new DateTime(2015, 1, 27, 10, 45, 12, 345, DateTimeKind.Unspecified); + + var utcDateTimeArray1 = new[] + { + new DateTime(1998, 4, 12, 13, 26, 38, DateTimeKind.Utc), new DateTime(1998, 4, 12, 17, 26, 38, DateTimeKind.Utc) + }; + + var localDateTimeArray1 = new[] + { + new DateTime(1998, 4, 12, 15, 26, 38, DateTimeKind.Local), new DateTime(1998, 4, 13, 15, 26, 38, DateTimeKind.Local) + }; + + var utcDateTimeArray2 = new[] + { + new DateTime(2015, 1, 27, 8, 45, 12, 345, DateTimeKind.Utc), new DateTime(2015, 1, 28, 8, 45, 12, 345, DateTimeKind.Utc) + }; + + var localDateTimeArray2 = new[] + { + new DateTime(2015, 1, 27, 10, 45, 12, 345, DateTimeKind.Unspecified), + new DateTime(2015, 1, 28, 10, 45, 12, 345, DateTimeKind.Unspecified) + }; + + return new List + { + new() + { + Id = 1, + TimestamptzDateTime = utcDateTime1, + TimestampDateTime = localDateTime1, + TimestampDateTimeOffset = new DateTimeOffset(utcDateTime1), + TimestamptzDateTimeArray = utcDateTimeArray1, + TimestampDateTimeArray = localDateTimeArray1, + TimestampDateTimeOffsetArray = [new(utcDateTimeArray1[0]), new(utcDateTimeArray1[1])], + }, + new() + { + Id = 2, + TimestamptzDateTime = utcDateTime2, + TimestampDateTime = unspecifiedDateTime2, + TimestampDateTimeOffset = new DateTimeOffset(utcDateTime2), + TimestamptzDateTimeArray = utcDateTimeArray2, + TimestampDateTimeArray = localDateTimeArray2, + TimestampDateTimeOffsetArray = [new(utcDateTimeArray2[0]), new(utcDateTimeArray2[1])], + } + }; + } + } + + #endregion +} diff --git a/test/EFCore.MySql.FunctionalTests/Scaffolding/CompiledModelMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Scaffolding/CompiledModelMySqlTest.cs index c9707a1df..45b94c08a 100644 --- a/test/EFCore.MySql.FunctionalTests/Scaffolding/CompiledModelMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Scaffolding/CompiledModelMySqlTest.cs @@ -33,6 +33,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Scaffolding; // TODO: Add more Pomelo specific cases. public class CompiledModelMySqlTest : CompiledModelRelationalTestBase { + public CompiledModelMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + protected override void BuildBigModel(ModelBuilder modelBuilder, bool jsonColumns) { base.BuildBigModel(modelBuilder, jsonColumns); diff --git a/test/EFCore.MySql.FunctionalTests/TPTTableSplittingMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/TPTTableSplittingMySqlTest.cs index 80c2fa929..39cb4f554 100644 --- a/test/EFCore.MySql.FunctionalTests/TPTTableSplittingMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/TPTTableSplittingMySqlTest.cs @@ -8,8 +8,8 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests { public class TPTTableSplittingMySqlTest : TPTTableSplittingTestBase { - public TPTTableSplittingMySqlTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) + public TPTTableSplittingMySqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture, testOutputHelper) { } diff --git a/test/EFCore.MySql.FunctionalTests/TableSplittingMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/TableSplittingMySqlTest.cs index 9c8ed6be2..66c5203e3 100644 --- a/test/EFCore.MySql.FunctionalTests/TableSplittingMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/TableSplittingMySqlTest.cs @@ -11,8 +11,8 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests [SupportedServerVersionCondition(nameof(ServerVersionSupport.GeneratedColumns))] public class TableSplittingMySqlTest : TableSplittingTestBase { - public TableSplittingMySqlTest(ITestOutputHelper testOutputHelper) - : base(testOutputHelper) + public TableSplittingMySqlTest(NonSharedFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture, testOutputHelper) { } diff --git a/test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommand.cs b/test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommand.cs index 8183631f4..1b9d46c31 100644 --- a/test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommand.cs +++ b/test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommand.cs @@ -9,8 +9,9 @@ public class DebugRelationalCommand : RelationalCommand public DebugRelationalCommand( [NotNull] RelationalCommandBuilderDependencies dependencies, [NotNull] string commandText, + [NotNull] string logCommandText, [NotNull] IReadOnlyList parameters) - : base(dependencies, commandText, parameters) + : base(dependencies, commandText, logCommandText, parameters) { } diff --git a/test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommandBuilder.cs b/test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommandBuilder.cs index 2ad8e7c77..ad9790fe9 100644 --- a/test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommandBuilder.cs +++ b/test/EFCore.MySql.FunctionalTests/TestUtilities/DebugServices/DebugRelationalCommandBuilder.cs @@ -11,5 +11,8 @@ public DebugRelationalCommandBuilder([NotNull] RelationalCommandBuilderDependenc } public override IRelationalCommand Build() - => new DebugRelationalCommand(Dependencies, base.Build().CommandText, Parameters); + { + var relationalCommand = base.Build(); + return new DebugRelationalCommand(Dependencies, relationalCommand.CommandText, relationalCommand.LogCommandText, Parameters); + } } diff --git a/test/EFCore.MySql.FunctionalTests/TestUtilities/MySqlTestStore.cs b/test/EFCore.MySql.FunctionalTests/TestUtilities/MySqlTestStore.cs index ba852c3e3..4c1c1df0e 100644 --- a/test/EFCore.MySql.FunctionalTests/TestUtilities/MySqlTestStore.cs +++ b/test/EFCore.MySql.FunctionalTests/TestUtilities/MySqlTestStore.cs @@ -111,7 +111,7 @@ public static MySqlDbContextOptionsBuilder AddOptions(MySqlDbContextOptionsBuild return builder // Our UseMySql() methods explicitly set TranslateParameterizedCollectionsToConstants() as the default, which is not the // default that the EF Core tests expect. - .TranslateParameterizedCollectionsToParameters() + .UseParameterizedCollectionMode(ParameterTranslationMode.MultipleParameters) .UseQuerySplittingBehavior(QuerySplittingBehavior.SingleQuery) .CommandTimeout(GetCommandTimeout()) .ExecutionStrategy(d => new TestMySqlRetryingExecutionStrategy(d)); diff --git a/test/EFCore.MySql.FunctionalTests/Update/NonSharedModelUpdatesMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Update/NonSharedModelUpdatesMySqlTest.cs index 84b3e21fb..5343091ed 100644 --- a/test/EFCore.MySql.FunctionalTests/Update/NonSharedModelUpdatesMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Update/NonSharedModelUpdatesMySqlTest.cs @@ -1,4 +1,6 @@ using System.Threading.Tasks; +using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.EntityFrameworkCore.Update; using Pomelo.EntityFrameworkCore.MySql.FunctionalTests.TestUtilities; @@ -8,6 +10,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Update; public class NonSharedModelUpdatesMySqlTest : NonSharedModelUpdatesTestBase { + public NonSharedModelUpdatesMySqlTest([NotNull] NonSharedFixture fixture) + : base(fixture) + { + } + public override async Task Principal_and_dependent_roundtrips_with_cycle_breaking(bool async) { await base.Principal_and_dependent_roundtrips_with_cycle_breaking(async); diff --git a/test/EFCore.MySql.FunctionalTests/Update/StoredProcedureUpdateMySqlTest.cs b/test/EFCore.MySql.FunctionalTests/Update/StoredProcedureUpdateMySqlTest.cs index 069bba7db..311aaa071 100644 --- a/test/EFCore.MySql.FunctionalTests/Update/StoredProcedureUpdateMySqlTest.cs +++ b/test/EFCore.MySql.FunctionalTests/Update/StoredProcedureUpdateMySqlTest.cs @@ -15,6 +15,11 @@ namespace Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Update; public class StoredProcedureUpdateMySqlTest : StoredProcedureUpdateTestBase { + public StoredProcedureUpdateMySqlTest(NonSharedFixture fixture) + : base(fixture) + { + } + public override async Task Insert_with_output_parameter(bool async) { await base.Insert_with_output_parameter( diff --git a/test/EFCore.MySql.IntegrationTests/Commands/TestPerformanceCommand.cs b/test/EFCore.MySql.IntegrationTests/Commands/TestPerformanceCommand.cs index 4fc5f64c0..e18add6dc 100644 --- a/test/EFCore.MySql.IntegrationTests/Commands/TestPerformanceCommand.cs +++ b/test/EFCore.MySql.IntegrationTests/Commands/TestPerformanceCommand.cs @@ -116,7 +116,9 @@ async Task select100(AppDb db) } } +#pragma warning disable EF1003 _db.Database.ExecuteSqlRaw("DELETE FROM `" + _db.Model.FindEntityType(typeof(Blog)).GetTableName() + "`"); +#pragma warning restore EF1003 PerfTest(insert1, "Insert 1", iterations, concurrency, ops).GetAwaiter().GetResult(); var insertCount = _db.Blogs.Count(); diff --git a/test/EFCore.MySql.IntegrationTests/Program.cs b/test/EFCore.MySql.IntegrationTests/Program.cs index bbe993778..9944a3283 100644 --- a/test/EFCore.MySql.IntegrationTests/Program.cs +++ b/test/EFCore.MySql.IntegrationTests/Program.cs @@ -1,6 +1,7 @@ using System; +using System.Linq; using Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Commands; -using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -12,12 +13,20 @@ public class Program { public static void Main(string[] args) { - if (args.Length == 0) + if (args.Length == 0 || + args.Any(arg => string.Equals(arg, "--applicationName", StringComparison.OrdinalIgnoreCase))) { - BuildWebHost(args).Run(); + BuildWebApplication(args) + .Run(); } else { + Console.WriteLine("Args:"); + for (var i = 0; i < args.Length; i++) + { + Console.WriteLine($"{i}: {args[i]}"); + } + var serviceCollection = new ServiceCollection(); serviceCollection .AddLogging(builder => @@ -41,13 +50,17 @@ public static void Main(string[] args) } } - public static IWebHost BuildWebHost(string[] args) + private static WebApplication BuildWebApplication(string[] args) { - return WebHost.CreateDefaultBuilder(args) - .UseUrls("http://*:5000") - .UseStartup() - .Build(); - } + var builder = WebApplication.CreateBuilder(args); + builder.WebHost + .UseUrls("http://*:5000"); + Startup.ConfigureServices(builder.Services); + var app = builder.Build(); + Startup.Configure(app, app.Environment); + + return app; + } } } diff --git a/test/EFCore.MySql.IntegrationTests/Startup.cs b/test/EFCore.MySql.IntegrationTests/Startup.cs index 25106a7bd..35ebc3ca5 100644 --- a/test/EFCore.MySql.IntegrationTests/Startup.cs +++ b/test/EFCore.MySql.IntegrationTests/Startup.cs @@ -1,32 +1,21 @@ using System; -using System.Buffers; using Pomelo.EntityFrameworkCore.MySql.IntegrationTests.Models; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc.Formatters; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using MySqlConnector; using Newtonsoft.Json; -using Pomelo.EntityFrameworkCore.MySql.Infrastructure; using Pomelo.EntityFrameworkCore.MySql.Tests; namespace Pomelo.EntityFrameworkCore.MySql.IntegrationTests { - public class Startup + public static class Startup { - public Startup(IWebHostEnvironment env) - { - Configuration = AppConfig.Config; - } - - public IConfigurationRoot Configuration { get; } - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) + public static void ConfigureServices(IServiceCollection services) { // Add framework services. services @@ -81,7 +70,7 @@ private static string GetConnectionString() } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + public static void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseRouting(); app.UseEndpoints(endpoints => diff --git a/test/EFCore.MySql.Tests/MySqlRelationalConnectionTest.cs b/test/EFCore.MySql.Tests/MySqlRelationalConnectionTest.cs index a822ae311..647a645b4 100644 --- a/test/EFCore.MySql.Tests/MySqlRelationalConnectionTest.cs +++ b/test/EFCore.MySql.Tests/MySqlRelationalConnectionTest.cs @@ -301,6 +301,7 @@ private static MySqlRelationalConnection CreateConnection(DbContextOptions optio var singletonOptions = new MySqlOptions(); singletonOptions.Initialize(options); + var exceptionDetector = new ExceptionDetector(); return new MySqlRelationalConnection( new RelationalConnectionDependencies( options, @@ -329,7 +330,9 @@ private static MySqlRelationalConnection CreateConnection(DbContextOptions optio TestServiceFactory.Instance.Create(), TestServiceFactory.Instance.Create(), singletonOptions), - new ExceptionDetector()))), + exceptionDetector, + new LoggingOptions())), + exceptionDetector), new MySqlConnectionStringOptionsValidator(), singletonOptions); } diff --git a/test/EFCore.MySql.Tests/MySqlTestFixtureBase.cs b/test/EFCore.MySql.Tests/MySqlTestFixtureBase.cs index b47d3f5b2..b17648716 100644 --- a/test/EFCore.MySql.Tests/MySqlTestFixtureBase.cs +++ b/test/EFCore.MySql.Tests/MySqlTestFixtureBase.cs @@ -9,18 +9,19 @@ namespace Pomelo.EntityFrameworkCore.MySql { - public abstract class MySqlTestFixtureBase : IDisposable + public abstract class MySqlTestFixtureBase : IAsyncDisposable { public abstract void SetupDatabase(); public abstract DbContext CreateDefaultDbContext(); - protected virtual void Dispose(bool disposing) + protected virtual ValueTask DisposeAsync(bool disposing) { + return ValueTask.CompletedTask; } - public void Dispose() + public async ValueTask DisposeAsync() { - Dispose(true); + await DisposeAsync(true); GC.SuppressFinalize(this); } } @@ -59,13 +60,15 @@ await TestStore.InitializeMySqlAsync(null, CreateDefaultDbContext, null, async c SetupDatabase(); } - public Task DisposeAsync() - => Task.CompletedTask; + async Task IAsyncLifetime.DisposeAsync() + { + await DisposeAsync(true); + } - protected override void Dispose(bool disposing) + protected override async ValueTask DisposeAsync(bool disposing) { - TestStore.Dispose(); - base.Dispose(disposing); + await TestStore.DisposeAsync(); + await base.DisposeAsync(disposing); } protected virtual string StoreName diff --git a/test/EFCore.MySql.Tests/TestBase.cs b/test/EFCore.MySql.Tests/TestBase.cs index 8d4f2eaa7..1cb46433c 100644 --- a/test/EFCore.MySql.Tests/TestBase.cs +++ b/test/EFCore.MySql.Tests/TestBase.cs @@ -8,7 +8,7 @@ namespace Pomelo.EntityFrameworkCore.MySql { - public class TestBase : IDisposable, IAsyncLifetime + public class TestBase : IAsyncDisposable, IAsyncLifetime where TContext : ContextBase, new() { public async Task InitializeAsync() @@ -16,10 +16,10 @@ public async Task InitializeAsync() TestStore = await MySqlTestStore.CreateInitializedAsync(StoreName); } - public Task DisposeAsync() - => Task.CompletedTask; + async Task IAsyncLifetime.DisposeAsync() + => await DisposeAsync(); - public virtual void Dispose() => TestStore.Dispose(); + public virtual ValueTask DisposeAsync() => TestStore.DisposeAsync(); public virtual string StoreName => GetType().Name; public virtual MySqlTestStore TestStore { get; private set; } diff --git a/tools/QueryBaselineUpdater/Program.cs b/tools/QueryBaselineUpdater/Program.cs index 15ae5504f..616150639 100644 --- a/tools/QueryBaselineUpdater/Program.cs +++ b/tools/QueryBaselineUpdater/Program.cs @@ -20,7 +20,8 @@ private static int Main(string[] args) throw new ArgumentException($"Path '{testFileBasePath}' does not exist or is not a directory."); } - var notFound = new List(); + var notFoundFiles = new List(); + var notFoundChunks = new List(); foreach (var file in Regex.Matches( File.ReadAllText(queryBaselineFilePath), @@ -36,7 +37,7 @@ private static int Main(string[] args) Regex.Replace( Regex.Replace( match.Groups["Name"].Value, - @"^Pomelo\.EntityFrameworkCore\.MySql\.FunctionalTests\.", + @"^(?:Pomelo\.EntityFrameworkCore\.MySql\.FunctionalTests\.|Microsoft\.EntityFrameworkCore\.)", string.Empty), @"\.[^.]+$", string.Empty), @@ -58,6 +59,12 @@ private static int Main(string[] args) { var filePath = file.First().File; + if (!File.Exists(filePath)) + { + notFoundFiles.Add(filePath); + continue; + } + // If we didn't find the chunk in the original file, it is possible that the test class is partial and that the chunk exists // in a separate file that has the name `.MySql.cs`. var retryCustomized = new List(); @@ -65,8 +72,8 @@ private static int Main(string[] args) File.WriteAllText( filePath, file.Aggregate( - File.ReadAllText(filePath), - (result, current) => ReplaceChunk(result, current, retryCustomized))); + File.ReadAllText(filePath), + (result, current) => ReplaceChunk(result, current, retryCustomized))); if (!retryCustomized.Any()) { @@ -89,28 +96,37 @@ private static int Main(string[] args) .OrderByDescending(t => t.Line) .Aggregate( File.ReadAllText(customizedFilePath), - (result, current) => ReplaceChunk(result, current, notFound))); + (result, current) => ReplaceChunk(result, current, notFoundChunks))); } else { - notFound.AddRange(retryCustomized); + notFoundChunks.AddRange(retryCustomized); } } - if (notFound.Any()) + if (notFoundChunks.Any()) { Console.WriteLine("The following chunks where not found:"); Console.WriteLine(); - foreach (var id in notFound) + foreach (var id in notFoundChunks) { Console.WriteLine(id); } + } - return -1; + if (notFoundFiles.Any()) + { + Console.WriteLine("The following files where not found:"); + Console.WriteLine(); + + foreach (var filePath in notFoundFiles) + { + Console.WriteLine(filePath); + } } - return 0; + return notFoundChunks.Any() || notFoundFiles.Any() ? -1 : 0; } private static string ReplaceChunk(string result, AssertSqlChunk current, List notFound)