Update the translator for the string methods to add a couple more: Substring, IndexOf,FirstOrDefault,LastOrDefault

pull/131/head
Christopher Jolly 3 years ago
parent 05b10ea856
commit 4554aad38e

@ -20,44 +20,68 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
{ {
private readonly JetSqlExpressionFactory _sqlExpressionFactory; private readonly JetSqlExpressionFactory _sqlExpressionFactory;
// TODO: Translation. private static readonly MethodInfo _indexOfMethodInfo
[NotNull] private static readonly MethodInfo _concat = typeof(string).GetRuntimeMethod(nameof(string.Concat), new[] {typeof(string), typeof(string)}); = typeof(string).GetRequiredRuntimeMethod(nameof(string.IndexOf), typeof(string));
[NotNull] private static readonly MethodInfo _contains = typeof(string).GetRuntimeMethod(nameof(string.Contains), new[] {typeof(string)}); private static readonly MethodInfo _replaceMethodInfo
= typeof(string).GetRequiredRuntimeMethod(nameof(string.Replace), typeof(string), typeof(string));
[NotNull] private static readonly MethodInfo _startsWith = typeof(string).GetRuntimeMethod(nameof(string.StartsWith), new[] {typeof(string)}); private static readonly MethodInfo _toLowerMethodInfo
[NotNull] private static readonly MethodInfo _endsWith = typeof(string).GetRuntimeMethod(nameof(string.EndsWith), new[] {typeof(string)}); = typeof(string).GetRequiredRuntimeMethod(nameof(string.ToLower), Array.Empty<Type>());
[NotNull] private static readonly MethodInfo _trimWithNoParam = typeof(string).GetRuntimeMethod(nameof(string.Trim), new Type[0]); private static readonly MethodInfo _toUpperMethodInfo
[NotNull] private static readonly MethodInfo _trimWithChars = typeof(string).GetRuntimeMethod(nameof(string.Trim), new[] {typeof(char[])}); = typeof(string).GetRequiredRuntimeMethod(nameof(string.ToUpper), Array.Empty<Type>());
// [NotNull] private static readonly MethodInfo _trimWithSingleChar = typeof(string).GetRuntimeMethod(nameof(string.Trim), new[] {typeof(char)}); // Jet TRIM does not take arguments
[NotNull] private static readonly MethodInfo _trimStartWithNoParam = typeof(string).GetRuntimeMethod(nameof(string.TrimStart), new Type[0]); private static readonly MethodInfo _substringMethodInfoWithOneArg
[NotNull] private static readonly MethodInfo _trimStartWithChars = typeof(string).GetRuntimeMethod(nameof(string.TrimStart), new[] {typeof(char[])}); = typeof(string).GetRequiredRuntimeMethod(nameof(string.Substring), typeof(int));
// [NotNull] private static readonly MethodInfo _trimStartWithSingleChar = typeof(string).GetRuntimeMethod(nameof(string.TrimStart), new[] {typeof(char)}); // Jet LTRIM does not take arguments
[NotNull] private static readonly MethodInfo _trimEndWithNoParam = typeof(string).GetRuntimeMethod(nameof(string.TrimEnd), new Type[0]); private static readonly MethodInfo _substringMethodInfoWithTwoArgs
[NotNull] private static readonly MethodInfo _trimEndWithChars = typeof(string).GetRuntimeMethod(nameof(string.TrimEnd), new[] {typeof(char[])}); = typeof(string).GetRequiredRuntimeMethod(nameof(string.Substring), typeof(int), typeof(int));
// [NotNull] private static readonly MethodInfo _trimEndWithSingleChar = typeof(string).GetRuntimeMethod(nameof(string.TrimEnd), new[] {typeof(char)}); // Jet LTRIM does not take arguments
[NotNull] private static readonly MethodInfo _substring = typeof(string).GetTypeInfo() private static readonly MethodInfo _isNullOrEmptyMethodInfo
.GetDeclaredMethods(nameof(string.Substring)) = typeof(string).GetRequiredRuntimeMethod(nameof(string.IsNullOrEmpty), typeof(string));
.Single(
m => m.GetParameters()
.Length == 1);
[NotNull] private static readonly MethodInfo _substringWithLength = typeof(string).GetTypeInfo() private static readonly MethodInfo _isNullOrWhiteSpaceMethodInfo
.GetDeclaredMethods(nameof(string.Substring)) = typeof(string).GetRequiredRuntimeMethod(nameof(string.IsNullOrWhiteSpace), typeof(string));
.Single(
m => m.GetParameters()
.Length == 2);
[NotNull] private static readonly MethodInfo _toLower = typeof(string).GetRuntimeMethod(nameof(string.ToLower), Array.Empty<Type>()); // Method defined in netcoreapp2.0 only
[NotNull] private static readonly MethodInfo _toUpper = typeof(string).GetRuntimeMethod(nameof(string.ToUpper), Array.Empty<Type>()); private static readonly MethodInfo _trimStartMethodInfoWithoutArgs
= typeof(string).GetRequiredRuntimeMethod(nameof(string.TrimStart), Array.Empty<Type>());
[NotNull] private static readonly MethodInfo _replace = typeof(string).GetRuntimeMethod(nameof(string.Replace), new[] {typeof(string), typeof(string)}); private static readonly MethodInfo _trimEndMethodInfoWithoutArgs
= typeof(string).GetRequiredRuntimeMethod(nameof(string.TrimEnd), Array.Empty<Type>());
private static readonly MethodInfo _isNullOrWhiteSpace = typeof(string).GetRuntimeMethod(nameof(string.IsNullOrWhiteSpace), new[] {typeof(string)}); private static readonly MethodInfo _trimMethodInfoWithoutArgs
= typeof(string).GetRequiredRuntimeMethod(nameof(string.Trim), Array.Empty<Type>());
// Method defined in netstandard2.0
private static readonly MethodInfo _trimStartMethodInfoWithCharArrayArg
= typeof(string).GetRequiredRuntimeMethod(nameof(string.TrimStart), typeof(char[]));
private static readonly MethodInfo _trimEndMethodInfoWithCharArrayArg
= typeof(string).GetRequiredRuntimeMethod(nameof(string.TrimEnd), typeof(char[]));
private static readonly MethodInfo _trimMethodInfoWithCharArrayArg
= typeof(string).GetRequiredRuntimeMethod(nameof(string.Trim), typeof(char[]));
private static readonly MethodInfo _startsWithMethodInfo
= typeof(string).GetRequiredRuntimeMethod(nameof(string.StartsWith), typeof(string));
private static readonly MethodInfo _containsMethodInfo
= typeof(string).GetRequiredRuntimeMethod(nameof(string.Contains), typeof(string));
private static readonly MethodInfo _endsWithMethodInfo
= typeof(string).GetRequiredRuntimeMethod(nameof(string.EndsWith), typeof(string));
private static readonly MethodInfo _firstOrDefaultMethodInfoWithoutArgs
= typeof(Enumerable).GetRuntimeMethods().Single(
m => m.Name == nameof(Enumerable.FirstOrDefault)
&& m.GetParameters().Length == 1).MakeGenericMethod(typeof(char));
private static readonly MethodInfo _lastOrDefaultMethodInfoWithoutArgs
= typeof(Enumerable).GetRuntimeMethods().Single(
m => m.Name == nameof(Enumerable.LastOrDefault)
&& m.GetParameters().Length == 1).MakeGenericMethod(typeof(char));
public JetStringMethodTranslator(ISqlExpressionFactory sqlExpressionFactory) public JetStringMethodTranslator(ISqlExpressionFactory sqlExpressionFactory)
@ -65,7 +89,41 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger) public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)
{ {
if (Equals(method, _contains)) if (_indexOfMethodInfo.Equals(method))
{
var argument = arguments[0];
var stringTypeMapping = ExpressionExtensions.InferTypeMapping(instance, argument)!;
argument = _sqlExpressionFactory.ApplyTypeMapping(argument, stringTypeMapping);
SqlExpression charIndexExpression;
var storeType = stringTypeMapping.StoreType;
if (string.Equals(storeType, "nvarchar(max)", StringComparison.OrdinalIgnoreCase)
|| string.Equals(storeType, "varchar(max)", StringComparison.OrdinalIgnoreCase))
{
charIndexExpression = _sqlExpressionFactory.Function(
"INSTR",
new[] { _sqlExpressionFactory.ApplyTypeMapping(instance, stringTypeMapping), argument },
nullable: true,
argumentsPropagateNullability: new[] { true, true },
typeof(long));
charIndexExpression = _sqlExpressionFactory.Convert(charIndexExpression, typeof(int));
}
else
{
charIndexExpression = _sqlExpressionFactory.Function(
"INSTR",
new[] { _sqlExpressionFactory.ApplyTypeMapping(instance, stringTypeMapping), argument },
nullable: true,
argumentsPropagateNullability: new[] { true, true },
method.ReturnType);
}
charIndexExpression = _sqlExpressionFactory.Subtract(charIndexExpression, _sqlExpressionFactory.Constant(1));
return charIndexExpression;
}
if (Equals(method, _containsMethodInfo))
{ {
var patternExpression = arguments[0]; var patternExpression = arguments[0];
var patternConstantExpression = patternExpression as SqlConstantExpression; var patternConstantExpression = patternExpression as SqlConstantExpression;
@ -96,7 +154,7 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
_sqlExpressionFactory.Equal(patternExpression, _sqlExpressionFactory.Constant(string.Empty))); _sqlExpressionFactory.Equal(patternExpression, _sqlExpressionFactory.Constant(string.Empty)));
} }
if (Equals(method, _startsWith)) if (Equals(method, _startsWithMethodInfo))
{ {
return _sqlExpressionFactory.Like( return _sqlExpressionFactory.Like(
// ReSharper disable once AssignNullToNotNullAttribute // ReSharper disable once AssignNullToNotNullAttribute
@ -105,7 +163,7 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
); );
} }
if (Equals(method, _endsWith)) if (Equals(method, _endsWithMethodInfo))
{ {
return _sqlExpressionFactory.Like( return _sqlExpressionFactory.Like(
instance, instance,
@ -114,43 +172,45 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
// Jet TRIM does not take arguments. // Jet TRIM does not take arguments.
// _trimWithNoParam is only available since .NET Core 2.0 (or .NET Standard 2.1). // _trimWithNoParam is only available since .NET Core 2.0 (or .NET Standard 2.1).
if (Equals(method, _trimWithNoParam) || if (Equals(method, _trimMethodInfoWithoutArgs) ||
Equals(method, _trimWithChars) && ((arguments[0] as SqlConstantExpression)?.Value == null || Equals(method, _trimMethodInfoWithCharArrayArg) && ((arguments[0] as SqlConstantExpression)?.Value == null ||
((arguments[0] as SqlConstantExpression)?.Value as Array)?.Length == 0)) ((arguments[0] as SqlConstantExpression)?.Value as Array)?.Length == 0))
{ {
return _sqlExpressionFactory.Function("TRIM", new[] {instance}, false, new[] {false}, method.ReturnType); return _sqlExpressionFactory.Function("TRIM", new[] {instance}, false, new[] {false}, method.ReturnType, instance.TypeMapping);
} }
// Jet LTRIM does not take arguments // Jet LTRIM does not take arguments
// _trimStartWithNoParam is only available since .NET Core 2.0 (or .NET Standard 2.1). // _trimStartWithNoParam is only available since .NET Core 2.0 (or .NET Standard 2.1).
if (Equals(method, _trimStartWithNoParam) || if (Equals(method, _trimStartMethodInfoWithoutArgs) ||
Equals(method, _trimStartWithChars) && ((arguments[0] as SqlConstantExpression)?.Value == null || Equals(method, _trimStartMethodInfoWithCharArrayArg) && ((arguments[0] as SqlConstantExpression)?.Value == null ||
((arguments[0] as SqlConstantExpression)?.Value as Array)?.Length == 0)) ((arguments[0] as SqlConstantExpression)?.Value as Array)?.Length == 0))
{ {
return _sqlExpressionFactory.Function("LTRIM", new[] {instance}, false, new[] {false}, method.ReturnType); return _sqlExpressionFactory.Function("LTRIM", new[] {instance}, false, new[] {false}, method.ReturnType, instance.TypeMapping);
} }
// Jet RTRIM does not take arguments // Jet RTRIM does not take arguments
// _trimEndWithNoParam is only available since .NET Core 2.0 (or .NET Standard 2.1). // _trimEndWithNoParam is only available since .NET Core 2.0 (or .NET Standard 2.1).
if (Equals(method, _trimEndWithNoParam) || if (Equals(method, _trimEndMethodInfoWithoutArgs) ||
Equals(method, _trimEndWithChars) && ((arguments[0] as SqlConstantExpression)?.Value == null || Equals(method, _trimEndMethodInfoWithCharArrayArg) && ((arguments[0] as SqlConstantExpression)?.Value == null ||
((arguments[0] as SqlConstantExpression)?.Value as Array)?.Length == 0)) ((arguments[0] as SqlConstantExpression)?.Value as Array)?.Length == 0))
{ {
return _sqlExpressionFactory.Function("RTRIM", new[] {instance}, false, new[] {false}, method.ReturnType); return _sqlExpressionFactory.Function("RTRIM", new[] {instance}, false, new[] {false}, method.ReturnType, instance.TypeMapping);
} }
if (Equals(method, _toLower)) if (_toLowerMethodInfo.Equals(method)
|| _toUpperMethodInfo.Equals(method))
{ {
return _sqlExpressionFactory.Function("LCASE", new[] {instance}, false, new[] {false}, method.ReturnType); return _sqlExpressionFactory.Function(
} _toLowerMethodInfo.Equals(method) ? "LCASE" : "UCASE",
new[] { instance },
if (Equals(method, _toUpper)) nullable: true,
{ argumentsPropagateNullability: new[] { true },
return _sqlExpressionFactory.Function("UCASE", new[] {instance}, false, new[] {false}, method.ReturnType); method.ReturnType,
instance.TypeMapping);
} }
if (Equals(_substring, _trimEndWithNoParam) || if (_substringMethodInfoWithOneArg.Equals(method) ||
Equals(_substringWithLength, _trimEndWithChars)) _substringMethodInfoWithTwoArgs.Equals(method))
{ {
var parameters = new List<SqlExpression>( var parameters = new List<SqlExpression>(
new[] new[]
@ -161,31 +221,40 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
? (SqlExpression) _sqlExpressionFactory.Constant((int) constantExpression.Value + 1) ? (SqlExpression) _sqlExpressionFactory.Constant((int) constantExpression.Value + 1)
: _sqlExpressionFactory.Add( : _sqlExpressionFactory.Add(
arguments[0], arguments[0],
_sqlExpressionFactory.Constant(1)), _sqlExpressionFactory.Constant(1))
arguments[1]
}); });
// MID can be called with an optional `length` parameter.
if (arguments.Count >= 2) if (arguments.Count >= 2)
{
parameters.Add(arguments[1]); parameters.Add(arguments[1]);
}
return _sqlExpressionFactory.Function( return _sqlExpressionFactory.Function(
"MID", "MID",
parameters, parameters,
false, new[] {false}, false, new[] {false},
method.ReturnType); method.ReturnType,instance.TypeMapping);
} }
if (Equals(method, _replace)) if (_replaceMethodInfo.Equals(method))
{ {
var firstArgument = arguments[0];
var secondArgument = arguments[1];
var stringTypeMapping = ExpressionExtensions.InferTypeMapping(instance, firstArgument, secondArgument);
instance = _sqlExpressionFactory.ApplyTypeMapping(instance, stringTypeMapping);
firstArgument = _sqlExpressionFactory.ApplyTypeMapping(firstArgument, stringTypeMapping);
secondArgument = _sqlExpressionFactory.ApplyTypeMapping(secondArgument, stringTypeMapping);
return _sqlExpressionFactory.Function( return _sqlExpressionFactory.Function(
"REPLACE", "REPLACE",
new[] {instance}.Concat(arguments), new[] { instance, firstArgument, secondArgument },
false, new[] {false}, nullable: true,
method.ReturnType); argumentsPropagateNullability: new[] { true, true, true },
method.ReturnType,
stringTypeMapping);
} }
if (Equals(method, _isNullOrWhiteSpace)) if (Equals(method, _isNullOrWhiteSpaceMethodInfo))
{ {
return _sqlExpressionFactory.OrElse( return _sqlExpressionFactory.OrElse(
_sqlExpressionFactory.IsNull(arguments[0]), _sqlExpressionFactory.IsNull(arguments[0]),
@ -198,6 +267,38 @@ namespace EntityFrameworkCore.Jet.Query.ExpressionTranslators.Internal
_sqlExpressionFactory.Constant(string.Empty))); _sqlExpressionFactory.Constant(string.Empty)));
} }
if (_firstOrDefaultMethodInfoWithoutArgs.Equals(method))
{
var argument = arguments[0];
return _sqlExpressionFactory.Function(
"MID",
new[] { argument, _sqlExpressionFactory.Constant(1), _sqlExpressionFactory.Constant(1) },
nullable: true,
argumentsPropagateNullability: new[] { true, true, true },
method.ReturnType);
}
if (_lastOrDefaultMethodInfoWithoutArgs.Equals(method))
{
var argument = arguments[0];
return _sqlExpressionFactory.Function(
"MID",
new[]
{
argument,
_sqlExpressionFactory.Function(
"LEN",
new[] { argument },
nullable: true,
argumentsPropagateNullability: new[] { true },
typeof(int)),
_sqlExpressionFactory.Constant(1)
},
nullable: true,
argumentsPropagateNullability: new[] { true, true, true },
method.ReturnType);
}
return null; return null;
} }
} }

@ -201,7 +201,7 @@ WHERE `s`.`ParentId` = {AssertSqlHelper.Parameter("@__p_0")}");
base.Lazy_load_many_to_one_reference_to_principal_alternate_key(state); base.Lazy_load_many_to_one_reference_to_principal_alternate_key(state);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT `p`.`Id`, `p`.`AlternateId` SELECT `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
@ -213,7 +213,7 @@ WHERE `p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}");
base.Lazy_load_one_to_one_reference_to_principal_alternate_key(state); base.Lazy_load_one_to_one_reference_to_principal_alternate_key(state);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT `p`.`Id`, `p`.`AlternateId` SELECT `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
@ -225,7 +225,7 @@ WHERE `p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}");
base.Lazy_load_one_to_one_reference_to_dependent_alternate_key(state); base.Lazy_load_one_to_one_reference_to_dependent_alternate_key(state);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT `s`.`Id`, `s`.`ParentId` SELECT `s`.`Id`, `s`.`ParentId`
FROM `SingleAk` AS `s` FROM `SingleAk` AS `s`
@ -313,8 +313,7 @@ WHERE `s`.`ParentId` = {AssertSqlHelper.Parameter("@__p_0")}");
base.Lazy_load_collection_composite_key(state); base.Lazy_load_collection_composite_key(state);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")} {AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")}
SELECT `c`.`Id`, `c`.`ParentAlternateId`, `c`.`ParentId` SELECT `c`.`Id`, `c`.`ParentAlternateId`, `c`.`ParentId`
@ -327,8 +326,7 @@ WHERE (`c`.`ParentAlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`c`
base.Lazy_load_many_to_one_reference_to_principal_composite_key(state); base.Lazy_load_many_to_one_reference_to_principal_composite_key(state);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707'")} {AssertSqlHelper.Declaration("@__p_1='707'")}
SELECT `p`.`Id`, `p`.`AlternateId` SELECT `p`.`Id`, `p`.`AlternateId`
@ -341,8 +339,7 @@ WHERE (`p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`p`.`Id`
base.Lazy_load_one_to_one_reference_to_principal_composite_key(state); base.Lazy_load_one_to_one_reference_to_principal_composite_key(state);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707'")} {AssertSqlHelper.Declaration("@__p_1='707'")}
SELECT `p`.`Id`, `p`.`AlternateId` SELECT `p`.`Id`, `p`.`AlternateId`
@ -355,8 +352,7 @@ WHERE (`p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`p`.`Id`
base.Lazy_load_one_to_one_reference_to_dependent_composite_key(state); base.Lazy_load_one_to_one_reference_to_dependent_composite_key(state);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")} {AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")}
SELECT `s`.`Id`, `s`.`ParentAlternateId`, `s`.`ParentId` SELECT `s`.`Id`, `s`.`ParentAlternateId`, `s`.`ParentId`
@ -543,7 +539,7 @@ WHERE `s`.`Id` = {AssertSqlHelper.Parameter("@__p_0")}");
AssertSql( AssertSql(
$@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` $@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
WHERE False = True"); WHERE 0 = 1");
} }
public override async Task Load_one_to_one_reference_to_principal_using_Query_null_FK(EntityState state, bool async) public override async Task Load_one_to_one_reference_to_principal_using_Query_null_FK(EntityState state, bool async)
@ -553,7 +549,7 @@ WHERE False = True");
AssertSql( AssertSql(
$@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` $@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
WHERE False = True"); WHERE 0 = 1");
} }
public override async Task Load_collection_not_found(EntityState state, bool async) public override async Task Load_collection_not_found(EntityState state, bool async)
@ -1046,7 +1042,7 @@ WHERE `s`.`ParentId` = {AssertSqlHelper.Parameter("@__p_0")}");
await base.Load_collection_alternate_key(state, async); await base.Load_collection_alternate_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT `c`.`Id`, `c`.`ParentId` SELECT `c`.`Id`, `c`.`ParentId`
FROM `ChildAk` AS `c` FROM `ChildAk` AS `c`
@ -1058,7 +1054,7 @@ WHERE `c`.`ParentId` = {AssertSqlHelper.Parameter("@__p_0")}");
await base.Load_many_to_one_reference_to_principal_alternate_key(state, async); await base.Load_many_to_one_reference_to_principal_alternate_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT `p`.`Id`, `p`.`AlternateId` SELECT `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
@ -1070,7 +1066,7 @@ WHERE `p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}");
await base.Load_one_to_one_reference_to_principal_alternate_key(state, async); await base.Load_one_to_one_reference_to_principal_alternate_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT `p`.`Id`, `p`.`AlternateId` SELECT `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
@ -1082,7 +1078,7 @@ WHERE `p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}");
await base.Load_one_to_one_reference_to_dependent_alternate_key(state, async); await base.Load_one_to_one_reference_to_dependent_alternate_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT `s`.`Id`, `s`.`ParentId` SELECT `s`.`Id`, `s`.`ParentId`
FROM `SingleAk` AS `s` FROM `SingleAk` AS `s`
@ -1094,7 +1090,7 @@ WHERE `s`.`ParentId` = {AssertSqlHelper.Parameter("@__p_0")}");
await base.Load_collection_using_Query_alternate_key(state, async); await base.Load_collection_using_Query_alternate_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT `c`.`Id`, `c`.`ParentId` SELECT `c`.`Id`, `c`.`ParentId`
FROM `ChildAk` AS `c` FROM `ChildAk` AS `c`
@ -1106,7 +1102,7 @@ WHERE `c`.`ParentId` = {AssertSqlHelper.Parameter("@__p_0")}");
await base.Load_many_to_one_reference_to_principal_using_Query_alternate_key(state, async); await base.Load_many_to_one_reference_to_principal_using_Query_alternate_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
@ -1118,7 +1114,7 @@ WHERE `p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}");
await base.Load_one_to_one_reference_to_principal_using_Query_alternate_key(state, async); await base.Load_one_to_one_reference_to_principal_using_Query_alternate_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
@ -1130,7 +1126,7 @@ WHERE `p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}");
await base.Load_one_to_one_reference_to_dependent_using_Query_alternate_key(state, async); await base.Load_one_to_one_reference_to_dependent_using_Query_alternate_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
SELECT TOP 2 `s`.`Id`, `s`.`ParentId` SELECT TOP 2 `s`.`Id`, `s`.`ParentId`
FROM `SingleAk` AS `s` FROM `SingleAk` AS `s`
@ -1158,7 +1154,7 @@ WHERE `s`.`ParentId` = {AssertSqlHelper.Parameter("@__p_0")}");
AssertSql( AssertSql(
$@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` $@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
WHERE False = True"); WHERE 0 = 1");
} }
public override async Task Load_one_to_one_reference_to_principal_using_Query_null_FK_alternate_key(EntityState state, bool async) public override async Task Load_one_to_one_reference_to_principal_using_Query_null_FK_alternate_key(EntityState state, bool async)
@ -1168,7 +1164,7 @@ WHERE False = True");
AssertSql( AssertSql(
$@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` $@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
WHERE False = True"); WHERE 0 = 1");
} }
public override async Task Load_collection_shadow_fk(EntityState state, bool async) public override async Task Load_collection_shadow_fk(EntityState state, bool async)
@ -1288,7 +1284,7 @@ WHERE `s`.`ParentId` = {AssertSqlHelper.Parameter("@__p_0")}");
AssertSql( AssertSql(
$@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` $@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
WHERE False = True"); WHERE 0 = 1");
} }
public override async Task Load_one_to_one_reference_to_principal_using_Query_null_FK_shadow_fk(EntityState state, bool async) public override async Task Load_one_to_one_reference_to_principal_using_Query_null_FK_shadow_fk(EntityState state, bool async)
@ -1298,7 +1294,7 @@ WHERE False = True");
AssertSql( AssertSql(
$@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` $@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
WHERE False = True"); WHERE 0 = 1");
} }
public override async Task Load_collection_composite_key(EntityState state, bool async) public override async Task Load_collection_composite_key(EntityState state, bool async)
@ -1306,8 +1302,7 @@ WHERE False = True");
await base.Load_collection_composite_key(state, async); await base.Load_collection_composite_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")} {AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")}
SELECT `c`.`Id`, `c`.`ParentAlternateId`, `c`.`ParentId` SELECT `c`.`Id`, `c`.`ParentAlternateId`, `c`.`ParentId`
@ -1320,8 +1315,7 @@ WHERE (`c`.`ParentAlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`c`
await base.Load_many_to_one_reference_to_principal_composite_key(state, async); await base.Load_many_to_one_reference_to_principal_composite_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707'")} {AssertSqlHelper.Declaration("@__p_1='707'")}
SELECT `p`.`Id`, `p`.`AlternateId` SELECT `p`.`Id`, `p`.`AlternateId`
@ -1334,8 +1328,7 @@ WHERE (`p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`p`.`Id`
await base.Load_one_to_one_reference_to_principal_composite_key(state, async); await base.Load_one_to_one_reference_to_principal_composite_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707'")} {AssertSqlHelper.Declaration("@__p_1='707'")}
SELECT `p`.`Id`, `p`.`AlternateId` SELECT `p`.`Id`, `p`.`AlternateId`
@ -1348,8 +1341,7 @@ WHERE (`p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`p`.`Id`
await base.Load_one_to_one_reference_to_dependent_composite_key(state, async); await base.Load_one_to_one_reference_to_dependent_composite_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")} {AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")}
SELECT `s`.`Id`, `s`.`ParentAlternateId`, `s`.`ParentId` SELECT `s`.`Id`, `s`.`ParentAlternateId`, `s`.`ParentId`
@ -1362,8 +1354,7 @@ WHERE (`s`.`ParentAlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`s`
await base.Load_collection_using_Query_composite_key(state, async); await base.Load_collection_using_Query_composite_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")} {AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")}
SELECT `c`.`Id`, `c`.`ParentAlternateId`, `c`.`ParentId` SELECT `c`.`Id`, `c`.`ParentAlternateId`, `c`.`ParentId`
@ -1376,8 +1367,7 @@ WHERE (`c`.`ParentAlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`c`
await base.Load_many_to_one_reference_to_principal_using_Query_composite_key(state, async); await base.Load_many_to_one_reference_to_principal_using_Query_composite_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707'")} {AssertSqlHelper.Declaration("@__p_1='707'")}
SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
@ -1390,8 +1380,7 @@ WHERE (`p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`p`.`Id`
await base.Load_one_to_one_reference_to_principal_using_Query_composite_key(state, async); await base.Load_one_to_one_reference_to_principal_using_Query_composite_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707'")} {AssertSqlHelper.Declaration("@__p_1='707'")}
SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
@ -1404,8 +1393,7 @@ WHERE (`p`.`AlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`p`.`Id`
await base.Load_one_to_one_reference_to_dependent_using_Query_composite_key(state, async); await base.Load_one_to_one_reference_to_dependent_using_Query_composite_key(state, async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 450)")} $@"{AssertSqlHelper.Declaration("@__p_0='Root' (Size = 255)")}
{AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")} {AssertSqlHelper.Declaration("@__p_1='707' (Nullable = true)")}
SELECT TOP 2 `s`.`Id`, `s`.`ParentAlternateId`, `s`.`ParentId` SELECT TOP 2 `s`.`Id`, `s`.`ParentAlternateId`, `s`.`ParentId`
@ -1434,7 +1422,7 @@ WHERE (`s`.`ParentAlternateId` = {AssertSqlHelper.Parameter("@__p_0")}) AND (`s`
AssertSql( AssertSql(
$@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` $@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
WHERE False = True"); WHERE 0 = 1");
} }
public override async Task Load_one_to_one_reference_to_principal_using_Query_null_FK_composite_key(EntityState state, bool async) public override async Task Load_one_to_one_reference_to_principal_using_Query_null_FK_composite_key(EntityState state, bool async)
@ -1444,7 +1432,7 @@ WHERE False = True");
AssertSql( AssertSql(
$@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId` $@"SELECT TOP 2 `p`.`Id`, `p`.`AlternateId`
FROM `Parent` AS `p` FROM `Parent` AS `p`
WHERE False = True"); WHERE 0 = 1");
} }
protected override void ClearLog() => Fixture.TestSqlLoggerFactory.Clear(); protected override void ClearLog() => Fixture.TestSqlLoggerFactory.Clear();

@ -260,7 +260,7 @@ LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID`");
$@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`
FROM `Orders` AS `o` FROM `Orders` AS `o`
LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID`
WHERE (`c`.`City` = 'Seattle') AND ((`c`.`Phone` <> '555 555 5555') OR `c`.`Phone` IS NULL)"); WHERE (`c`.`City` = 'Seattle') AND ((`c`.`Phone` <> '555 555 5555') OR (`c`.`Phone` IS NULL))");
} }
public override async Task Select_Navigations_Where_Navigations(bool isAsync) public override async Task Select_Navigations_Where_Navigations(bool isAsync)
@ -271,7 +271,7 @@ WHERE (`c`.`City` = 'Seattle') AND ((`c`.`Phone` <> '555 555 5555') OR `c`.`Phon
$@"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 `Orders` AS `o` FROM `Orders` AS `o`
LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID`
WHERE (`c`.`City` = 'Seattle') AND ((`c`.`Phone` <> '555 555 5555') OR `c`.`Phone` IS NULL)"); WHERE (`c`.`City` = 'Seattle') AND ((`c`.`Phone` <> '555 555 5555') OR (`c`.`Phone` IS NULL))");
} }
public override async Task Select_Singleton_Navigation_With_Member_Access(bool isAsync) public override async Task Select_Singleton_Navigation_With_Member_Access(bool isAsync)
@ -282,7 +282,7 @@ WHERE (`c`.`City` = 'Seattle') AND ((`c`.`Phone` <> '555 555 5555') OR `c`.`Phon
$@"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 `Orders` AS `o` FROM `Orders` AS `o`
LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID`
WHERE (`c`.`City` = 'Seattle') AND ((`c`.`Phone` <> '555 555 5555') OR `c`.`Phone` IS NULL)"); WHERE (`c`.`City` = 'Seattle') AND ((`c`.`Phone` <> '555 555 5555') OR (`c`.`Phone` IS NULL))");
} }
public override async Task Select_count_plus_sum(bool isAsync) public override async Task Select_count_plus_sum(bool isAsync)
@ -308,7 +308,7 @@ FROM `Orders` AS `o1`");
$@"SELECT `c`.`City` AS `B` $@"SELECT `c`.`City` AS `B`
FROM `Orders` AS `o` FROM `Orders` AS `o`
LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID`
WHERE (`c`.`City` = 'Seattle') AND ((`c`.`Phone` <> '555 555 5555') OR `c`.`Phone` IS NULL)"); WHERE (`c`.`City` = 'Seattle') AND ((`c`.`Phone` <> '555 555 5555') OR (`c`.`Phone` IS NULL))");
} }
public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(bool isAsync) public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(bool isAsync)
@ -358,8 +358,8 @@ WHERE `e0`.`EmployeeID` IS NULL");
AssertSql( AssertSql(
$@"SELECT `e`.`EmployeeID`, `e`.`City`, `e`.`Country`, `e`.`FirstName`, `e`.`ReportsTo`, `e`.`Title` $@"SELECT `e`.`EmployeeID`, `e`.`City`, `e`.`Country`, `e`.`FirstName`, `e`.`ReportsTo`, `e`.`Title`
FROM `Employees` AS `e` FROM (`Employees` AS `e`
LEFT JOIN `Employees` AS `e0` ON `e`.`ReportsTo` = `e0`.`EmployeeID` LEFT JOIN `Employees` AS `e0` ON `e`.`ReportsTo` = `e0`.`EmployeeID`)
LEFT JOIN `Employees` AS `e1` ON `e0`.`ReportsTo` = `e1`.`EmployeeID` LEFT JOIN `Employees` AS `e1` ON `e0`.`ReportsTo` = `e1`.`EmployeeID`
WHERE `e1`.`EmployeeID` IS NULL"); WHERE `e1`.`EmployeeID` IS NULL");
} }

@ -868,10 +868,7 @@ FROM `Orders` AS `o`");
await base.Select_byte_constant(isAsync); await base.Select_byte_constant(isAsync);
AssertSql( AssertSql(
$@"SELECT CASE $@"SELECT IIF(`c`.`CustomerID` = 'ALFKI', 1, 2)
WHEN `c`.`CustomerID` = 'ALFKI' THEN 1
ELSE 2
END
FROM `Customers` AS `c`"); FROM `Customers` AS `c`");
} }
@ -880,10 +877,7 @@ FROM `Customers` AS `c`");
await base.Select_short_constant(isAsync); await base.Select_short_constant(isAsync);
AssertSql( AssertSql(
$@"SELECT CASE $@"SELECT IIF(`c`.`CustomerID` = 'ALFKI', 1, 2)
WHEN `c`.`CustomerID` = 'ALFKI' THEN 1
ELSE 2
END
FROM `Customers` AS `c`"); FROM `Customers` AS `c`");
} }
@ -892,7 +886,7 @@ FROM `Customers` AS `c`");
await base.Select_bool_constant(isAsync); await base.Select_bool_constant(isAsync);
AssertSql( AssertSql(
$@"SELECT IIF(`c`.`CustomerID` = 'ALFKI', 1, 0) $@"SELECT IIF(`c`.`CustomerID` = 'ALFKI', TRUE, FALSE)
FROM `Customers` AS `c`"); FROM `Customers` AS `c`");
} }
@ -940,7 +934,7 @@ FROM `Orders` AS `o`");
await base.Select_GetValueOrDefault_on_DateTime_with_null_values(isAsync); await base.Select_GetValueOrDefault_on_DateTime_with_null_values(isAsync);
AssertSql( AssertSql(
$@"SELECT IIf(`o`.`OrderDate` IS NULL, '01/01/1753 00:00:00', `o`.`OrderDate`) $@"SELECT IIF(`o`.`OrderDate` IS NULL, '01/01/1753 00:00:00', `o`.`OrderDate`)
FROM `Customers` AS `c` FROM `Customers` AS `c`
LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID`"); LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID`");
} }
@ -950,7 +944,7 @@ LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID`");
await base.Cast_on_top_level_projection_brings_explicit_Cast(isAsync); await base.Cast_on_top_level_projection_brings_explicit_Cast(isAsync);
AssertSql( AssertSql(
$@"SELECT IIf(`o`.`OrderID` IS NULL, NULL, CDBL(`o`.`OrderID`)) $@"SELECT IIF(`o`.`OrderID` IS NULL, NULL, CDBL(`o`.`OrderID`))
FROM `Orders` AS `o`"); FROM `Orders` AS `o`");
} }
@ -969,10 +963,10 @@ FROM `Orders` AS `o`");
AssertSql( 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` FROM (`Customers` AS `c`
INNER JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` INNER JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID`)
INNER JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` INNER JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID`
WHERE IIf(`o0`.`Discount` IS NULL, NULL, CDBL(`o0`.`Discount`)) >= 0.25E0"); WHERE IIF(`o0`.`Discount` IS NULL, NULL, CDBL(`o0`.`Discount`)) >= 0.25");
} }
public override async Task SelectMany_without_result_selector_naked_collection_navigation(bool isAsync) public override async Task SelectMany_without_result_selector_naked_collection_navigation(bool isAsync)

@ -207,11 +207,11 @@ WHERE `e`.`BoolA` <> `e`.`BoolB`",
// //
$@"SELECT `e`.`Id` $@"SELECT `e`.`Id`
FROM `Entities1` AS `e` FROM `Entities1` AS `e`
WHERE (`e`.`BoolA` <> `e`.`NullableBoolB`) OR `e`.`NullableBoolB` IS NULL", WHERE (`e`.`BoolA` <> `e`.`NullableBoolB`) OR (`e`.`NullableBoolB` IS NULL)",
// //
$@"SELECT `e`.`Id` $@"SELECT `e`.`Id`
FROM `Entities1` AS `e` FROM `Entities1` AS `e`
WHERE (`e`.`NullableBoolA` <> `e`.`BoolB`) OR `e`.`NullableBoolA` IS NULL", WHERE (`e`.`NullableBoolA` <> `e`.`BoolB`) OR (`e`.`NullableBoolA` IS NULL)",
// //
$@"SELECT `e`.`Id` $@"SELECT `e`.`Id`
FROM `Entities1` AS `e` FROM `Entities1` AS `e`
@ -673,7 +673,7 @@ WHERE (`e`.`NullableStringA` = 'Foo') OR `e`.`NullableStringA` IS NULL");
await base.Where_multiple_ands_with_nullable_parameter_and_constant(async); await base.Where_multiple_ands_with_nullable_parameter_and_constant(async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__prm3_2='Blah' (Size = 4000)")} $@"{AssertSqlHelper.Declaration("@__prm3_2='Blah' (Size = 255)")}
SELECT `e`.`Id` SELECT `e`.`Id`
FROM `Entities1` AS `e` FROM `Entities1` AS `e`
@ -685,7 +685,7 @@ WHERE ((((`e`.`NullableStringA` <> 'Foo') OR `e`.`NullableStringA` IS NULL) AND
await base.Where_multiple_ands_with_nullable_parameter_and_constant_not_optimized(async); await base.Where_multiple_ands_with_nullable_parameter_and_constant_not_optimized(async);
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@__prm3_2='Blah' (Size = 4000)")} $@"{AssertSqlHelper.Declaration("@__prm3_2='Blah' (Size = 255)")}
SELECT `e`.`Id` SELECT `e`.`Id`
FROM `Entities1` AS `e` FROM `Entities1` AS `e`
@ -896,7 +896,7 @@ WHERE `e`.`NullableBoolA` = `e`.`NullableBoolB`");
AssertSql( AssertSql(
$@"SELECT `e`.`Id` $@"SELECT `e`.`Id`
FROM `Entities1` AS `e` FROM `Entities1` AS `e`
WHERE `e`.`NullableBoolA` = True"); WHERE `e`.`NullableBoolA` = TRUE");
} }
public override async Task Where_nullable_bool_equal_with_constant(bool async) public override async Task Where_nullable_bool_equal_with_constant(bool async)
@ -906,7 +906,7 @@ WHERE `e`.`NullableBoolA` = True");
AssertSql( AssertSql(
$@"SELECT `e`.`Id` $@"SELECT `e`.`Id`
FROM `Entities1` AS `e` FROM `Entities1` AS `e`
WHERE `e`.`NullableBoolA` = True"); WHERE `e`.`NullableBoolA` = TRUE");
} }
public override async Task Where_nullable_bool_with_null_check(bool async) public override async Task Where_nullable_bool_with_null_check(bool async)
@ -1082,7 +1082,7 @@ WHERE `e`.`StringA` = `e`.`StringB`");
await base.Projecting_nullable_bool_with_coalesce(async); await base.Projecting_nullable_bool_with_coalesce(async);
AssertSql( AssertSql(
$@"SELECT `e`.`Id`, IIf(`e`.`NullableBoolA` IS NULL, NULL, `e`.`NullableBoolA`) AS `Coalesce` $@"SELECT `e`.`Id`, IIF(`e`.`NullableBoolA` IS NULL, NULL, `e`.`NullableBoolA`) AS `Coalesce`
FROM `Entities1` AS `e`"); FROM `Entities1` AS `e`");
} }
@ -1091,7 +1091,7 @@ FROM `Entities1` AS `e`");
await base.Projecting_nullable_bool_with_coalesce_nested(async); await base.Projecting_nullable_bool_with_coalesce_nested(async);
AssertSql( AssertSql(
$@"SELECT `e`.`Id`, IIf(`e`.`NullableBoolA` IS NULL, NULL, `e`.`NullableBoolA`)) AS `Coalesce` $@"SELECT `e`.`Id`, IIF(`e`.`NullableBoolA` IS NULL, NULL, `e`.`NullableBoolA`)) AS `Coalesce`
FROM `Entities1` AS `e`"); FROM `Entities1` AS `e`");
} }

@ -1,6 +1,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Data.Common; using System.Data.Common;
using System.Data.Odbc;
using System.Threading.Tasks; using System.Threading.Tasks;
using EntityFrameworkCore.Jet.Data; using EntityFrameworkCore.Jet.Data;
using System.Data.OleDb; using System.Data.OleDb;
@ -53,9 +54,8 @@ namespace EntityFrameworkCore.Jet.FunctionalTests.Query
base.Query_with_parameters(); base.Query_with_parameters();
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@p0='London' (Size = 4000)")} $@"{AssertSqlHelper.Declaration("@p0='London' (Size = 255)")}
{AssertSqlHelper.Declaration("@p1='Sales Representative' (Size = 255)")}
{AssertSqlHelper.Declaration("@p1='Sales Representative' (Size = 4000)")}
SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@p0")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@p1")}"); SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@p0")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@p1")}");
} }
@ -95,15 +95,13 @@ SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("
base.Query_with_dbParameters_mixed(); base.Query_with_dbParameters_mixed();
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@p0='London' (Size = 4000)")} $@"{AssertSqlHelper.Declaration("@p0='London' (Size = 255)")}
{AssertSqlHelper.Declaration("@contactTitle='Sales Representative' (Nullable = false) (Size = 20)")} {AssertSqlHelper.Declaration("@contactTitle='Sales Representative' (Nullable = false) (Size = 20)")}
SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@p0")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@contactTitle")}", SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@p0")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@contactTitle")}",
// //
$@"{AssertSqlHelper.Declaration("@city='London' (Nullable = false) (Size = 6)")} $@"{AssertSqlHelper.Declaration("@city='London' (Nullable = false) (Size = 6)")}
{AssertSqlHelper.Declaration("@p0='Sales Representative' (Size = 255)")}
{AssertSqlHelper.Declaration("@p0='Sales Representative' (Size = 4000)")}
SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@city")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@p0")}"); SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@city")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@p0")}");
} }
@ -113,9 +111,8 @@ SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("
base.Query_with_parameters_interpolated(); base.Query_with_parameters_interpolated();
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@p0='London' (Size = 4000)")} $@"{AssertSqlHelper.Declaration("@p0='London' (Size = 255)")}
{AssertSqlHelper.Declaration("@p1='Sales Representative' (Size = 255)")}
{AssertSqlHelper.Declaration("@p1='Sales Representative' (Size = 4000)")}
SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@p0")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@p1")}"); SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@p0")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@p1")}");
} }
@ -125,9 +122,8 @@ SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("
await base.Query_with_parameters_async(); await base.Query_with_parameters_async();
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@p0='London' (Size = 4000)")} $@"{AssertSqlHelper.Declaration("@p0='London' (Size = 255)")}
{AssertSqlHelper.Declaration("@p1='Sales Representative' (Size = 255)")}
{AssertSqlHelper.Declaration("@p1='Sales Representative' (Size = 4000)")}
SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@p0")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@p1")}"); SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@p0")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@p1")}");
} }
@ -137,15 +133,14 @@ SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("
await base.Query_with_parameters_interpolated_async(); await base.Query_with_parameters_interpolated_async();
AssertSql( AssertSql(
$@"{AssertSqlHelper.Declaration("@p0='London' (Size = 4000)")} $@"{AssertSqlHelper.Declaration("@p0='London' (Size = 255)")}
{AssertSqlHelper.Declaration("@p1='Sales Representative' (Size = 255)")}
{AssertSqlHelper.Declaration("@p1='Sales Representative' (Size = 4000)")}
SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@p0")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@p1")}"); SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter("@p0")} AND ""ContactTitle"" = {AssertSqlHelper.Parameter("@p1")}");
} }
protected override DbParameter CreateDbParameter(string name, object value) protected override DbParameter CreateDbParameter(string name, object value)
=> new OleDbParameter { ParameterName = name, Value = value }; => new OdbcParameter { ParameterName = name, Value = value };
protected override string TenMostExpensiveProductsSproc => "`Ten Most Expensive Products`"; protected override string TenMostExpensiveProductsSproc => "`Ten Most Expensive Products`";
protected override string CustomerOrderHistorySproc => "`CustOrderHist` @CustomerID"; protected override string CustomerOrderHistorySproc => "`CustOrderHist` @CustomerID";

@ -124,6 +124,7 @@ DROP TABLE `JustTableName`;");
#region Table #region Table
//Note - No table or column comments in Jet
[ConditionalFact] [ConditionalFact]
public void Create_columns() public void Create_columns()
{ {
@ -145,15 +146,15 @@ CREATE TABLE `Blogs` (
{ {
Assert.Null(c.Table.Schema); Assert.Null(c.Table.Schema);
Assert.Equal("Blogs", c.Table.Name); Assert.Equal("Blogs", c.Table.Name);
Assert.Equal( /*Assert.Equal(
@"Blog table comment. @"Blog table comment.
On multiple lines.", c.Table.Comment); On multiple lines.", c.Table.Comment);*/
}); });
Assert.Single(table.Columns.Where(c => c.Name == "Id")); Assert.Single(table.Columns.Where(c => c.Name == "Id"));
Assert.Single(table.Columns.Where(c => c.Name == "Name")); Assert.Single(table.Columns.Where(c => c.Name == "Name"));
Assert.Single(table.Columns.Where(c => c.Comment == "Blog.Id column comment.")); //Assert.Single(table.Columns.Where(c => c.Comment == "Blog.Id column comment."));
Assert.Single(table.Columns.Where(c => c.Comment != null)); //Assert.Single(table.Columns.Where(c => c.Comment != null));
}, },
"DROP TABLE `Blogs`"); "DROP TABLE `Blogs`");
} }
@ -332,7 +333,7 @@ DROP TABLE PrincipalTable;");
#region ColumnFacets #region ColumnFacets
[ConditionalFact] [ConditionalFact(Skip = "Jet does not support type aliases")]
public void Column_with_type_alias_assigns_underlying_store_type() public void Column_with_type_alias_assigns_underlying_store_type()
{ {
Fixture.TestStore.ExecuteNonQuery( Fixture.TestStore.ExecuteNonQuery(
@ -813,7 +814,7 @@ DROP TABLE NoFacetTypes;
DROP TABLE RowversionType;"); DROP TABLE RowversionType;");
} }
[ConditionalFact] [ConditionalFact(Skip = "Jet does not support storing computed values")]
public void Default_and_computed_values_are_stored() public void Default_and_computed_values_are_stored()
{ {
Test( Test(

Loading…
Cancel
Save