diff --git a/src/EFCore.Cosmos/Extensions/Internal/CosmosShapedQueryExpressionExtensions.cs b/src/EFCore.Cosmos/Extensions/Internal/CosmosShapedQueryExpressionExtensions.cs index 14f996cb1fe..586f11b0529 100644 --- a/src/EFCore.Cosmos/Extensions/Internal/CosmosShapedQueryExpressionExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/Internal/CosmosShapedQueryExpressionExtensions.cs @@ -214,7 +214,6 @@ public static bool TryExtractArray( Limit: null, Orderings: [], IsDistinct: false, - UsesSingleValueProjection: true, Projection: [{ Expression: var a }] }, } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQuerySqlGenerator.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQuerySqlGenerator.cs index 110caa01760..392b29accb2 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQuerySqlGenerator.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQuerySqlGenerator.cs @@ -209,7 +209,10 @@ protected override Expression VisitScalarSubquery(ScalarSubqueryExpression scala /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override Expression VisitProjection(ProjectionExpression projectionExpression) - => VisitProjection(projectionExpression, objectProjectionStyle: false); + { + GenerateProjection(projectionExpression, objectProjectionStyle: false); + return projectionExpression; + } /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -217,8 +220,17 @@ protected override Expression VisitProjection(ProjectionExpression projectionExp /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - protected virtual Expression VisitProjection(ProjectionExpression projectionExpression, bool objectProjectionStyle) + private void GenerateProjection(ProjectionExpression projectionExpression, bool objectProjectionStyle) { + // If the SELECT has a single projection with IsValueProjection, prepend the VALUE keyword (without VALUE, Cosmos projects a JSON + // object containing the value). + if (projectionExpression.IsValueProjection) + { + _sqlBuilder.Append("VALUE "); + Visit(projectionExpression.Expression); + return; + } + if (objectProjectionStyle) { _sqlBuilder.Append('"').Append(projectionExpression.Alias).Append("\" : "); @@ -232,8 +244,6 @@ protected virtual Expression VisitProjection(ProjectionExpression projectionExpr { _sqlBuilder.Append(" AS " + projectionExpression.Alias); } - - return projectionExpression; } /// @@ -277,34 +287,28 @@ protected override Expression VisitSelect(SelectExpression selectExpression) _sqlBuilder.Append("DISTINCT "); } - if (selectExpression.Projection is { Count: > 0 } projection) + if (selectExpression.Projection is { Count: > 0 } projections) { - // If the SELECT projects a single value out, we just project that with the Cosmos VALUE keyword (without VALUE, - // Cosmos projects a JSON object containing the value). - // TODO: Ideally, just always use VALUE for all single-projection SELECTs - but this like requires shaper changes. - if (selectExpression.UsesSingleValueProjection && projection is [var singleProjection]) - { - _sqlBuilder.Append("VALUE "); + Check.DebugAssert( + projections.Count == 1 || !projections.Any(p => p.IsValueProjection), + "Multiple projections with IsValueProjection"); - Visit(singleProjection.Expression); - } - // Otherwise, we'll project a JSON object; Cosmos has two syntaxes for doing so: + // If there's only one projection, we simply project it directly (SELECT VALUE c["Id"]); this happens in GenerateProjection(). + // Otherwise, we'll project a JSON object wrapping the multiple projections. Cosmos has two syntaxes for doing so: // 1. Project out a JSON object as a value (SELECT VALUE { 'a': a, 'b': b }), or // 2. Project a set of properties with optional AS+aliases (SELECT 'a' AS a, 'b' AS b) // Both methods produce the exact same results; we usually prefer the 1st, but in some cases we use the 2nd. - else if ((projection.Count > 1 - // Cosmos does not support "AS Value" projections, specifically for the alias "Value" - || projection is [{ Alias: string alias }] && alias.Equals("value", StringComparison.OrdinalIgnoreCase)) - && projection.Any(p => !string.IsNullOrEmpty(p.Alias) && p.Alias != p.Name) - && !projection.Any(p => p.Expression is SqlFunctionExpression)) // Aggregates are not allowed + if (projections.Count > 1 + && projections.Any(p => !string.IsNullOrEmpty(p.Alias) && p.Alias != p.Name) + && !projections.Any(p => p.Expression is SqlFunctionExpression)) // Aggregates are not allowed { _sqlBuilder.AppendLine("VALUE").AppendLine("{").IncrementIndent(); - GenerateList(projection, e => VisitProjection(e, objectProjectionStyle: true), joinAction: sql => sql.AppendLine(",")); + GenerateList(projections, e => GenerateProjection(e, objectProjectionStyle: true), joinAction: sql => sql.AppendLine(",")); _sqlBuilder.AppendLine().DecrementIndent().Append("}"); } else { - GenerateList(projection, e => Visit(e)); + GenerateList(projections, e => Visit(e)); } } else @@ -752,7 +756,6 @@ void VisitContainerExpression(Expression containerExpression) Limit: null, Orderings: [], IsDistinct: false, - UsesSingleValueProjection: true, Projection.Count: 1 }; diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitor.cs index b9627f81d97..e02ac1de670 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitor.cs @@ -9,9 +9,9 @@ public partial class CosmosShapedQueryCompilingExpressionVisitor { private sealed class CosmosProjectionBindingRemovingExpressionVisitor( SelectExpression selectExpression, - ParameterExpression jObjectParameter, + ParameterExpression jTokenParameter, bool trackQueryResults) - : CosmosProjectionBindingRemovingExpressionVisitorBase(jObjectParameter, trackQueryResults) + : CosmosProjectionBindingRemovingExpressionVisitorBase(jTokenParameter, trackQueryResults) { protected override ProjectionExpression GetProjection(ProjectionBindingExpression projectionBindingExpression) => selectExpression.Projection[GetProjectionIndex(projectionBindingExpression)]; diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs index 9595903e1f8..7e76f163570 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs @@ -16,7 +16,7 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal; public partial class CosmosShapedQueryCompilingExpressionVisitor { private abstract class CosmosProjectionBindingRemovingExpressionVisitorBase( - ParameterExpression jObjectParameter, + ParameterExpression jTokenParameter, bool trackQueryResults) : ExpressionVisitor { @@ -73,16 +73,40 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) // Values injected by JObjectInjectingExpressionVisitor var projectionExpression = ((UnaryExpression)binaryExpression.Right).Operand; - if (projectionExpression is ProjectionBindingExpression projectionBindingExpression) + + if (projectionExpression is UnaryExpression + { + NodeType: ExpressionType.Convert, + Operand: UnaryExpression operand + }) { - var projection = GetProjection(projectionBindingExpression); - projectionExpression = projection.Expression; - storeName = projection.Alias; + // Unwrap EntityProjectionExpression when the root entity is not projected + // That is, this is handling the projection of a non-root entity type. + projectionExpression = operand.Operand; } - else if (projectionExpression is UnaryExpression { NodeType: ExpressionType.Convert } convertExpression) + + switch (projectionExpression) { - // Unwrap EntityProjectionExpression when the root entity is not projected - projectionExpression = ((UnaryExpression)convertExpression.Operand).Operand; + // ProjectionBindingExpression may represent a named token to be obtained from a containing JObject, or + // it may be that the token is not nested in a JObject if the query was generated using the SQL VALUE clause. + case ProjectionBindingExpression projectionBindingExpression: + { + var projection = GetProjection(projectionBindingExpression); + projectionExpression = projection.Expression; + if (!projection.IsValueProjection) + { + storeName = projection.Alias; + } + break; + } + + case ObjectArrayAccessExpression e: + storeName = e.PropertyName; + break; + + case EntityProjectionExpression e: + storeName = e.PropertyName; + break; } Expression innerAccessExpression; @@ -91,13 +115,11 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) case ObjectArrayAccessExpression objectArrayProjectionExpression: innerAccessExpression = objectArrayProjectionExpression.Object; _projectionBindings[objectArrayProjectionExpression] = parameterExpression; - storeName ??= objectArrayProjectionExpression.PropertyName; break; case EntityProjectionExpression entityProjectionExpression: var accessExpression = entityProjectionExpression.Object; _projectionBindings[accessExpression] = parameterExpression; - storeName ??= entityProjectionExpression.PropertyName; switch (accessExpression) { @@ -107,13 +129,12 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) (innerObjectAccessExpression.Navigation.DeclaringEntityType, innerAccessExpression); break; case ObjectReferenceExpression: - innerAccessExpression = jObjectParameter; + innerAccessExpression = jTokenParameter; break; default: throw new InvalidOperationException( CoreStrings.TranslationFailed(binaryExpression.Print())); } - break; default: @@ -174,7 +195,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp var projection = GetProjection(projectionBindingExpression); innerExpression = Convert( - CreateReadJTokenExpression(jObjectParameter, projection.Alias), + CreateReadJTokenExpression(jTokenParameter, projection.Alias), typeof(JObject)); } else @@ -222,9 +243,10 @@ protected override Expression VisitExtension(Expression extensionExpression) var projection = GetProjection(projectionBindingExpression); return CreateGetValueExpression( - jObjectParameter, - projection.Alias, - projectionBindingExpression.Type, (projection.Expression as SqlExpression)?.TypeMapping); + jTokenParameter, + projection.IsValueProjection ? null : projection.Alias, + projectionBindingExpression.Type, + (projection.Expression as SqlExpression)?.TypeMapping); } case CollectionShaperExpression collectionShaperExpression: @@ -584,13 +606,13 @@ private static Expression CreateReadJTokenExpression(Expression jObjectExpressio => Call(jObjectExpression, GetItemMethodInfo, Constant(propertyName)); private Expression CreateGetValueExpression( - Expression jObjectExpression, + Expression jTokenExpression, IProperty property, Type type) { if (property.Name == StoreKeyConvention.JObjectPropertyName) { - return _projectionBindings[jObjectExpression]; + return _projectionBindings[jTokenExpression]; } var entityType = property.DeclaringType as IEntityType; @@ -603,7 +625,7 @@ private Expression CreateGetValueExpression( { if (ownership is { IsUnique: false } && property.IsOrdinalKeyProperty()) { - var ordinalExpression = _ordinalParameterBindings[jObjectExpression]; + var ordinalExpression = _ordinalParameterBindings[jTokenExpression]; if (ordinalExpression.Type != type) { ordinalExpression = Convert(ordinalExpression, type); @@ -616,7 +638,7 @@ private Expression CreateGetValueExpression( if (principalProperty != null) { Expression ownerJObjectExpression = null; - if (_ownerMappings.TryGetValue(jObjectExpression, out var ownerInfo)) + if (_ownerMappings.TryGetValue(jTokenExpression, out var ownerInfo)) { Check.DebugAssert( principalProperty.DeclaringType.IsAssignableFrom(ownerInfo.EntityType), @@ -624,11 +646,11 @@ private Expression CreateGetValueExpression( ownerJObjectExpression = ownerInfo.JObjectExpression; } - else if (jObjectExpression is ObjectReferenceExpression objectReferenceExpression) + else if (jTokenExpression is ObjectReferenceExpression objectReferenceExpression) { ownerJObjectExpression = objectReferenceExpression; } - else if (jObjectExpression is ObjectAccessExpression objectAccessExpression) + else if (jTokenExpression is ObjectAccessExpression objectAccessExpression) { ownerJObjectExpression = objectAccessExpression.Object; } @@ -653,7 +675,7 @@ private Expression CreateGetValueExpression( && !property.IsShadowProperty()) { var readExpression = CreateGetValueExpression( - jObjectExpression, storeName, type.MakeNullable(), property.GetTypeMapping()); + jTokenExpression, storeName, type.MakeNullable(), property.GetTypeMapping()); var nonNullReadExpression = readExpression; if (nonNullReadExpression.Type != type) @@ -661,7 +683,7 @@ private Expression CreateGetValueExpression( nonNullReadExpression = Convert(nonNullReadExpression, type); } - var ordinalExpression = _ordinalParameterBindings[jObjectExpression]; + var ordinalExpression = _ordinalParameterBindings[jTokenExpression]; if (ordinalExpression.Type != type) { ordinalExpression = Convert(ordinalExpression, type); @@ -674,25 +696,25 @@ private Expression CreateGetValueExpression( } return Convert( - CreateGetValueExpression(jObjectExpression, storeName, type.MakeNullable(), property.GetTypeMapping()), + CreateGetValueExpression(jTokenExpression, storeName, type.MakeNullable(), property.GetTypeMapping()), type); } private Expression CreateGetValueExpression( - Expression jObjectExpression, + Expression jTokenExpression, string storeName, Type type, CoreTypeMapping typeMapping = null) { Check.DebugAssert(type.IsNullableType(), "Must read nullable type from JObject."); - var innerExpression = jObjectExpression switch + var innerExpression = jTokenExpression switch { - _ when _projectionBindings.TryGetValue(jObjectExpression, out var innerVariable) + _ when _projectionBindings.TryGetValue(jTokenExpression, out var innerVariable) => innerVariable, - ObjectReferenceExpression objectReference - => CreateGetValueExpression(jObjectParameter, objectReference.Name, typeof(JObject)), + ObjectReferenceExpression + => jTokenParameter, ObjectAccessExpression objectAccessExpression => CreateGetValueExpression( @@ -700,10 +722,15 @@ ObjectAccessExpression objectAccessExpression ((IAccessExpression)objectAccessExpression.Object).PropertyName, typeof(JObject)), - _ => jObjectExpression + _ => jTokenExpression }; - var jTokenExpression = CreateReadJTokenExpression(innerExpression, storeName); + jTokenExpression = storeName == null + ? innerExpression + : CreateReadJTokenExpression( + innerExpression.Type == typeof(JObject) + ? innerExpression + : Convert(innerExpression, typeof(JObject)), storeName); Expression valueExpression; var converter = typeMapping?.Converter; @@ -774,9 +801,6 @@ private static Expression ConvertJTokenToType(Expression jTokenExpression, Type ToObjectWithSerializerMethodInfo.MakeGenericMethod(type), jTokenExpression); - private static T SafeToObject(JToken token) - => token == null || token.Type == JTokenType.Null ? default : token.ToObject(); - private static T SafeToObjectWithSerializer(JToken token) => token == null || token.Type == JTokenType.Null ? default : token.ToObject(CosmosClientWrapper.Serializer); } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.PagingQueryingEnumerable.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.PagingQueryingEnumerable.cs index 5add7ca24cd..006d87c4645 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.PagingQueryingEnumerable.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.PagingQueryingEnumerable.cs @@ -24,7 +24,7 @@ private sealed class PagingQueryingEnumerable : IAsyncEnumerable _shaper; + private readonly Func _shaper; private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory; private readonly Type _contextType; private readonly string _cosmosContainer; @@ -42,7 +42,7 @@ public PagingQueryingEnumerable( ISqlExpressionFactory sqlExpressionFactory, IQuerySqlGeneratorFactory querySqlGeneratorFactory, SelectExpression selectExpression, - Func shaper, + Func shaper, Type contextType, IEntityType rootEntityType, List partitionKeyPropertyValues, @@ -87,7 +87,7 @@ private sealed class AsyncEnumerator : IAsyncEnumerator> { private readonly PagingQueryingEnumerable _queryingEnumerable; private readonly CosmosQueryContext _cosmosQueryContext; - private readonly Func _shaper; + private readonly Func _shaper; private readonly Type _contextType; private readonly string _cosmosContainer; private readonly PartitionKey _cosmosPartitionKey; diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs index 24e7d4fba29..07b0c22115c 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs @@ -23,7 +23,7 @@ private sealed class QueryingEnumerable : IEnumerable, IAsyncEnumerable private readonly CosmosQueryContext _cosmosQueryContext; private readonly ISqlExpressionFactory _sqlExpressionFactory; private readonly SelectExpression _selectExpression; - private readonly Func _shaper; + private readonly Func _shaper; private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory; private readonly Type _contextType; private readonly string _cosmosContainer; @@ -37,7 +37,7 @@ public QueryingEnumerable( ISqlExpressionFactory sqlExpressionFactory, IQuerySqlGeneratorFactory querySqlGeneratorFactory, SelectExpression selectExpression, - Func shaper, + Func shaper, Type contextType, IEntityType rootEntityType, List partitionKeyPropertyValues, @@ -103,7 +103,7 @@ private sealed class Enumerator : IEnumerator { private readonly QueryingEnumerable _queryingEnumerable; private readonly CosmosQueryContext _cosmosQueryContext; - private readonly Func _shaper; + private readonly Func _shaper; private readonly Type _contextType; private readonly string _cosmosContainer; private readonly PartitionKey _cosmosPartitionKey; @@ -112,7 +112,7 @@ private sealed class Enumerator : IEnumerator private readonly IConcurrencyDetector _concurrencyDetector; private readonly IExceptionDetector _exceptionDetector; - private IEnumerator _enumerator; + private IEnumerator _enumerator; public Enumerator(QueryingEnumerable queryingEnumerable) { @@ -192,7 +192,7 @@ private sealed class AsyncEnumerator : IAsyncEnumerator { private readonly QueryingEnumerable _queryingEnumerable; private readonly CosmosQueryContext _cosmosQueryContext; - private readonly Func _shaper; + private readonly Func _shaper; private readonly Type _contextType; private readonly string _cosmosContainer; private readonly PartitionKey _cosmosPartitionKey; @@ -202,7 +202,7 @@ private sealed class AsyncEnumerator : IAsyncEnumerator private readonly IConcurrencyDetector _concurrencyDetector; private readonly IExceptionDetector _exceptionDetector; - private IAsyncEnumerator _enumerator; + private IAsyncEnumerator _enumerator; public AsyncEnumerator(QueryingEnumerable queryingEnumerable, CancellationToken cancellationToken) { diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs index 9270ae3687b..2ad551a6521 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs @@ -40,7 +40,7 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery throw new UnreachableException("No root entity type was set during query processing."); } - var jObjectParameter = Parameter(typeof(JObject), "jObject"); + var jTokenParameter = Parameter(typeof(JToken), "jToken"); var shaperBody = shapedQueryExpression.ShaperExpression; @@ -69,14 +69,14 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery } shaperBody = new CosmosProjectionBindingRemovingExpressionVisitor( - selectExpression, jObjectParameter, + selectExpression, jTokenParameter, QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.TrackAll) .Visit(shaperBody); var shaperLambda = Lambda( shaperBody, QueryCompilationContext.QueryContextParameter, - jObjectParameter); + jTokenParameter); var cosmosQueryContextConstant = Convert(QueryCompilationContext.QueryContextParameter, typeof(CosmosQueryContext)); var shaperConstant = Constant(shaperLambda.Compile()); diff --git a/src/EFCore.Cosmos/Query/Internal/Expressions/ObjectReferenceExpression.cs b/src/EFCore.Cosmos/Query/Internal/Expressions/ObjectReferenceExpression.cs index c5eb8d958d8..5e5b55e3d36 100644 --- a/src/EFCore.Cosmos/Query/Internal/Expressions/ObjectReferenceExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/Expressions/ObjectReferenceExpression.cs @@ -14,7 +14,7 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal; /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// -public class ObjectReferenceExpression(IEntityType entityType, string name) : Expression, IAccessExpression +public class ObjectReferenceExpression(IEntityType entityType, string name) : Expression, IPrintableExpression, IAccessExpression { /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -72,6 +72,15 @@ string IAccessExpression.PropertyName protected override Expression VisitChildren(ExpressionVisitor visitor) => this; + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + public void Print(ExpressionPrinter expressionPrinter) + => expressionPrinter.Append(Name); + /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in diff --git a/src/EFCore.Cosmos/Query/Internal/Expressions/ProjectionExpression.cs b/src/EFCore.Cosmos/Query/Internal/Expressions/ProjectionExpression.cs index 99724e9465a..3ce6b129add 100644 --- a/src/EFCore.Cosmos/Query/Internal/Expressions/ProjectionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/Expressions/ProjectionExpression.cs @@ -10,9 +10,18 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal; /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// -public class ProjectionExpression(Expression expression, string alias) +[DebuggerDisplay("{Microsoft.EntityFrameworkCore.Query.ExpressionPrinter.Print(this), nq}")] +public class ProjectionExpression(Expression expression, string alias, bool isValueProjection) : Expression, IPrintableExpression { + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + public virtual Expression Expression { get; } = expression; + /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in @@ -27,7 +36,7 @@ public class ProjectionExpression(Expression expression, string alias) /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual Expression Expression { get; } = expression; + public virtual bool IsValueProjection { get; } = isValueProjection; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -73,7 +82,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// public virtual ProjectionExpression Update(Expression expression) => expression != Expression - ? new ProjectionExpression(expression, Alias) + ? new ProjectionExpression(expression, Alias, IsValueProjection) : this; /// diff --git a/src/EFCore.Cosmos/Query/Internal/Expressions/SelectExpression.cs b/src/EFCore.Cosmos/Query/Internal/Expressions/SelectExpression.cs index fc4a2cd3c19..1b90e563fc3 100644 --- a/src/EFCore.Cosmos/Query/Internal/Expressions/SelectExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/Expressions/SelectExpression.cs @@ -96,22 +96,16 @@ public static SelectExpression CreateForCollection(Expression sourceExpression, sourceExpression = new SelectExpression( sources: [], predicate: null, - [new ProjectionExpression(sourceExpression, null!)], + [new ProjectionExpression(sourceExpression, alias: null!, isValueProjection: true)], distinct: false, orderings: [], offset: null, - limit: null) - { - UsesSingleValueProjection = true - }; + limit: null); } var source = new SourceExpression(sourceExpression, sourceAlias, withIn: true); - return new SelectExpression(source, projection) - { - UsesSingleValueProjection = true - }; + return new SelectExpression(source, projection); } /// @@ -123,18 +117,6 @@ [new ProjectionExpression(sourceExpression, null!)], public IReadOnlyList Projection => _projection; - /// - /// If set, indicates that the has a Cosmos VALUE projection, which does not get wrapped in a - /// JSON object. If , must contain a single item. - /// - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// any release. You should only use it directly in your code with extreme caution and knowing that - /// doing so can result in application failures when updating to a new Entity Framework Core release. - /// - public bool UsesSingleValueProjection { get; init; } - /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in @@ -292,6 +274,15 @@ public void ReplaceProjectionMapping(IDictionary p public int AddToProjection(Expression sqlExpression) => AddToProjection(sqlExpression, null); + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + public int AddToProjection(EntityProjectionExpression entityProjection) + => AddToProjection(entityProjection, null); + private int AddToProjection(Expression expression, string? alias) { var existingIndex = _projection.FindIndex(pe => pe.Expression.Equals(expression)); @@ -311,7 +302,14 @@ private int AddToProjection(Expression expression, string? alias) currentAlias = $"{baseAlias}{counter++}"; } - _projection.Add(new ProjectionExpression(expression, currentAlias)); + // Add the projection; if it's the only one, then it's a Cosmos VALUE projection (i.e. SELECT VALUE f). + // If we add a 2nd projection, go back and remove the VALUE modifier from the 1st one. This is also why we need to have a valid + // alias for the 1st projection, even if it's a VALUE projection (where no alias actually gets generated in SQL). + _projection.Add(new ProjectionExpression(expression, currentAlias, isValueProjection: _projection.Count == 0)); + if (_projection.Count == 2) + { + _projection[0] = new ProjectionExpression(_projection[0].Expression, _projection[0].Alias, isValueProjection: false); + } return _projection.Count - 1; } @@ -603,8 +601,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) { var newSelectExpression = new SelectExpression(sources, predicate, projections, IsDistinct, orderings, offset, limit) { - _projectionMapping = projectionMapping, - UsesSingleValueProjection = UsesSingleValueProjection + _projectionMapping = projectionMapping }; return newSelectExpression; @@ -636,7 +633,6 @@ public SelectExpression Update( return new SelectExpression(sources, predicate, projections, IsDistinct, orderings, offset, limit) { _projectionMapping = projectionMapping, - UsesSingleValueProjection = UsesSingleValueProjection, ReadItemInfo = ReadItemInfo }; } @@ -651,7 +647,6 @@ public SelectExpression WithReadItemInfo(ReadItemInfo readItemInfo) => new(Sources.ToList(), Predicate, Projection.ToList(), IsDistinct, Orderings.ToList(), Offset, Limit) { _projectionMapping = _projectionMapping, - UsesSingleValueProjection = UsesSingleValueProjection, ReadItemInfo = readItemInfo }; @@ -671,8 +666,7 @@ public SelectExpression WithSingleValueProjection() return new SelectExpression(Sources.ToList(), Predicate, Projection.ToList(), IsDistinct, Orderings.ToList(), Offset, Limit) { - _projectionMapping = projectionMapping, - UsesSingleValueProjection = true + _projectionMapping = projectionMapping }; } @@ -725,18 +719,18 @@ private void PrintSql(ExpressionPrinter expressionPrinter, bool withTags = true) expressionPrinter.Append("DISTINCT "); } - if (Projection.Any()) + switch (Projection) { - if (UsesSingleValueProjection) - { + case []: + expressionPrinter.Append("1"); + break; + case [{ IsValueProjection: true } valueProjection]: expressionPrinter.Append("VALUE "); - } - - expressionPrinter.VisitCollection(Projection); - } - else - { - expressionPrinter.Append("1"); + expressionPrinter.Visit(valueProjection); + break; + default: + expressionPrinter.VisitCollection(Projection); + break; } if (Sources.Count > 0) diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs index c2c64c84460..6fae101e89f 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; -using System.Diagnostics.CodeAnalysis; using System.Net; using System.Runtime.CompilerServices; using System.Text; @@ -76,9 +75,41 @@ public CosmosClientWrapper( _enableContentResponseOnWrite = options.EnableContentResponseOnWrite; } + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// private CosmosClient Client => _singletonWrapper.Client; + private static bool TryDeserializeNextToken(JsonTextReader jsonReader, out JToken? token) + { + switch (jsonReader.TokenType) + { + case JsonToken.StartObject: + token = Serializer.Deserialize(jsonReader); + return true; + case JsonToken.StartArray: + token = Serializer.Deserialize(jsonReader); + return true; + case JsonToken.Date: + case JsonToken.Bytes: + case JsonToken.Float: + case JsonToken.String: + case JsonToken.Boolean: + case JsonToken.Integer: + case JsonToken.Null: + token = Serializer.Deserialize(jsonReader); + return true; + case JsonToken.EndArray: + default: + token = null; + return false; + } + } + /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in @@ -525,7 +556,7 @@ private static void ProcessResponse(ResponseMessage response, IUpdateEntry entry /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IEnumerable ExecuteSqlQuery( + public virtual IEnumerable ExecuteSqlQuery( string containerId, PartitionKey partitionKeyValue, CosmosSqlQuery query) @@ -543,7 +574,7 @@ public virtual IEnumerable ExecuteSqlQuery( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IAsyncEnumerable ExecuteSqlQueryAsync( + public virtual IAsyncEnumerable ExecuteSqlQueryAsync( string containerId, PartitionKey partitionKeyValue, CosmosSqlQuery query) @@ -645,9 +676,7 @@ private static Task CreateSingleItemQueryAsync( using var reader = new StreamReader(responseStream); using var jsonReader = new JsonTextReader(reader); - var jObject = Serializer.Deserialize(jsonReader); - - return new JObject(new JProperty("c", jObject)); + return Serializer.Deserialize(jsonReader); } /// @@ -677,6 +706,7 @@ public virtual FeedIterator CreateQuery( private static JsonTextReader CreateJsonReader(TextReader reader) { var jsonReader = new JsonTextReader(reader); + jsonReader.DateParseHandling = DateParseHandling.None; while (jsonReader.Read()) { @@ -695,55 +725,38 @@ private static JsonTextReader CreateJsonReader(TextReader reader) return jsonReader; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool TryReadJObject(JsonTextReader jsonReader, [NotNullWhen(true)] out JObject? jObject) - { - jObject = null; - - while (jsonReader.Read()) - { - if (jsonReader.TokenType == JsonToken.StartObject) - { - jObject = Serializer.Deserialize(jsonReader); - return true; - } - } - - return false; - } - private sealed class DocumentEnumerable( CosmosClientWrapper cosmosClient, string containerId, PartitionKey partitionKeyValue, CosmosSqlQuery cosmosSqlQuery) - : IEnumerable + : IEnumerable { private readonly CosmosClientWrapper _cosmosClient = cosmosClient; private readonly string _containerId = containerId; private readonly PartitionKey _partitionKeyValue = partitionKeyValue; private readonly CosmosSqlQuery _cosmosSqlQuery = cosmosSqlQuery; - public IEnumerator GetEnumerator() + public IEnumerator GetEnumerator() => new Enumerator(this); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - private sealed class Enumerator(DocumentEnumerable documentEnumerable) : IEnumerator + private sealed class Enumerator(DocumentEnumerable documentEnumerable) : IEnumerator { private readonly CosmosClientWrapper _cosmosClientWrapper = documentEnumerable._cosmosClient; private readonly string _containerId = documentEnumerable._containerId; private readonly PartitionKey _partitionKeyValue = documentEnumerable._partitionKeyValue; private readonly CosmosSqlQuery _cosmosSqlQuery = documentEnumerable._cosmosSqlQuery; - private JObject? _current; + private JToken? _current; private ResponseMessage? _responseMessage; - private IEnumerator? _responseMessageEnumerator; + private IEnumerator? _responseMessageEnumerator; private FeedIterator? _query; - public JObject Current + public JToken Current => _current ?? throw new InvalidOperationException(); object IEnumerator.Current @@ -821,31 +834,31 @@ private sealed class DocumentAsyncEnumerable( string containerId, PartitionKey partitionKeyValue, CosmosSqlQuery cosmosSqlQuery) - : IAsyncEnumerable + : IAsyncEnumerable { private readonly CosmosClientWrapper _cosmosClient = cosmosClient; private readonly string _containerId = containerId; private readonly PartitionKey _partitionKeyValue = partitionKeyValue; private readonly CosmosSqlQuery _cosmosSqlQuery = cosmosSqlQuery; - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) => new AsyncEnumerator(this, cancellationToken); private sealed class AsyncEnumerator(DocumentAsyncEnumerable documentEnumerable, CancellationToken cancellationToken) - : IAsyncEnumerator + : IAsyncEnumerator { private readonly CosmosClientWrapper _cosmosClientWrapper = documentEnumerable._cosmosClient; private readonly string _containerId = documentEnumerable._containerId; private readonly PartitionKey _partitionKeyValue = documentEnumerable._partitionKeyValue; private readonly CosmosSqlQuery _cosmosSqlQuery = documentEnumerable._cosmosSqlQuery; - private JObject? _current; + private JToken? _current; private ResponseMessage? _responseMessage; - private IAsyncEnumerator? _responseMessageEnumerator; + private IAsyncEnumerator? _responseMessageEnumerator; private FeedIterator? _query; - public JObject Current + public JToken Current => _current ?? throw new InvalidOperationException(); [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -926,28 +939,28 @@ public async ValueTask DisposeAsync() /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual IEnumerable GetResponseMessageEnumerable(ResponseMessage responseMessage) + public virtual IEnumerable GetResponseMessageEnumerable(ResponseMessage responseMessage) => new ResponseMessageEnumerable(responseMessage); - private sealed class ResponseMessageEnumerable(ResponseMessage responseMessage) : IEnumerable, IAsyncEnumerable + private sealed class ResponseMessageEnumerable(ResponseMessage responseMessage) : IEnumerable, IAsyncEnumerable { - public IEnumerator GetEnumerator() + public IEnumerator GetEnumerator() => new ResponseMessageEnumerator(responseMessage); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) => new ResponseMessageAsyncEnumerator(responseMessage); } - private sealed class ResponseMessageEnumerator : IEnumerator + private sealed class ResponseMessageEnumerator : IEnumerator { private readonly Stream _responseStream; private readonly StreamReader _reader; private readonly JsonTextReader _jsonReader; - private JObject? _current; + private JToken? _current; public ResponseMessageEnumerator(ResponseMessage responseMessage) { @@ -960,17 +973,13 @@ public bool MoveNext() { while (_jsonReader.Read()) { - if (_jsonReader.TokenType == JsonToken.StartObject) - { - _current = Serializer.Deserialize(_jsonReader); - return true; - } + return TryDeserializeNextToken(_jsonReader, out _current); } return false; } - public JObject Current + public JToken Current => _current ?? throw new InvalidOperationException(); object IEnumerator.Current @@ -987,13 +996,13 @@ public void Reset() => throw new NotSupportedException(); } - private sealed class ResponseMessageAsyncEnumerator : IAsyncEnumerator + private sealed class ResponseMessageAsyncEnumerator : IAsyncEnumerator { private readonly Stream _responseStream; private readonly StreamReader _reader; private readonly JsonTextReader _jsonReader; - private JObject? _current; + private JToken? _current; public ResponseMessageAsyncEnumerator(ResponseMessage responseMessage) { @@ -1006,17 +1015,13 @@ public async ValueTask MoveNextAsync() { while (await _jsonReader.ReadAsync().ConfigureAwait(false)) { - if (_jsonReader.TokenType == JsonToken.StartObject) - { - _current = Serializer.Deserialize(_jsonReader); - return true; - } + return TryDeserializeNextToken(_jsonReader, out _current); } return false; } - public JObject Current + public JToken Current => _current ?? throw new InvalidOperationException(); public async ValueTask DisposeAsync() diff --git a/src/EFCore.Cosmos/Storage/Internal/ICosmosClientWrapper.cs b/src/EFCore.Cosmos/Storage/Internal/ICosmosClientWrapper.cs index 20bb42fa670..dc24ec0ab8f 100644 --- a/src/EFCore.Cosmos/Storage/Internal/ICosmosClientWrapper.cs +++ b/src/EFCore.Cosmos/Storage/Internal/ICosmosClientWrapper.cs @@ -170,7 +170,7 @@ FeedIterator CreateQuery( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - IEnumerable ExecuteSqlQuery( + IEnumerable ExecuteSqlQuery( string containerId, PartitionKey partitionKeyValue, CosmosSqlQuery query); @@ -181,7 +181,7 @@ IEnumerable ExecuteSqlQuery( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - IAsyncEnumerable ExecuteSqlQueryAsync( + IAsyncEnumerable ExecuteSqlQueryAsync( string containerId, PartitionKey partitionKeyValue, CosmosSqlQuery query); @@ -192,5 +192,5 @@ IAsyncEnumerable ExecuteSqlQueryAsync( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - IEnumerable GetResponseMessageEnumerable(ResponseMessage responseMessage); + IEnumerable GetResponseMessageEnumerable(ResponseMessage responseMessage); } diff --git a/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs index d1e2fcf12ad..359f3f66f4c 100644 --- a/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/CustomConvertersCosmosTest.cs @@ -74,7 +74,7 @@ public override async Task Where_bool_gets_converted_to_equality_when_value_conv AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Blog", "RssBlog") AND (c["IsVisible"] = "Y")) """); @@ -87,7 +87,7 @@ public override async Task Where_negated_bool_gets_converted_to_equality_when_va AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Blog", "RssBlog") AND NOT((c["IsVisible"] = "Y"))) """); @@ -100,7 +100,7 @@ public override async Task Where_bool_gets_converted_to_equality_when_value_conv AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Blog", "RssBlog") AND (c["IsVisible"] = "Y")) """); @@ -113,7 +113,7 @@ public override async Task Where_bool_gets_converted_to_equality_when_value_conv AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Blog", "RssBlog") AND NOT((c["IndexerVisible"] = "Aye"))) """); diff --git a/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs b/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs index 03669349a81..7626d17a243 100644 --- a/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/EmbeddedDocumentsTest.cs @@ -533,7 +533,7 @@ public virtual async Task Can_query_and_modify_nested_embedded_types() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Vehicle", "PoweredVehicle") AND (c["Name"] = "AIM-9M Sidewinder")) OFFSET 0 LIMIT 1 diff --git a/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs index 97436ab1408..521db9b9360 100644 --- a/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/EndToEndCosmosTest.cs @@ -1342,7 +1342,7 @@ public async Task Can_read_with_find_with_partition_key_without_value_generator( """ @__p_3='42' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Id"] = @__p_3) OFFSET 0 LIMIT 1 @@ -1487,7 +1487,7 @@ public async Task Can_read_with_find_with_PK_resource_id() """ @__p_0='42' -SELECT c +SELECT VALUE c FROM root c WHERE (c["id"] = @__p_0) OFFSET 0 LIMIT 1 diff --git a/test/EFCore.Cosmos.FunctionalTests/FindCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/FindCosmosTest.cs index bc3d0a2f63e..f7e11ba4efc 100644 --- a/test/EFCore.Cosmos.FunctionalTests/FindCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/FindCosmosTest.cs @@ -297,7 +297,7 @@ public override async Task Find_base_type_from_store_async(CancellationType canc """ @__p_0='77' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("BaseType", "DerivedType") AND (c["Id"] = @__p_0)) OFFSET 0 LIMIT 1 @@ -311,7 +311,7 @@ public override async Task Returns_null_for_base_type_not_in_store_async(Cancell AssertSql(""" @__p_0='99' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("BaseType", "DerivedType") AND (c["Id"] = @__p_0)) OFFSET 0 LIMIT 1 diff --git a/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs b/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs index c6d0b31e748..09e0df1b715 100644 --- a/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/HierarchicalPartitionKeyTest.cs @@ -27,7 +27,7 @@ public virtual async Task Can_add_update_delete_end_to_end_with_partition_key() { const string read1Sql = """ -SELECT c +SELECT VALUE c FROM root c ORDER BY c["PartitionKey1"] OFFSET 0 LIMIT 1 @@ -37,7 +37,7 @@ OFFSET 0 LIMIT 1 """ @__p_0='1' -SELECT c +SELECT VALUE c FROM root c ORDER BY c["PartitionKey1"] OFFSET @__p_0 LIMIT 1 @@ -58,7 +58,7 @@ public virtual async Task Can_add_update_delete_end_to_end_with_with_partition_k { const string readSql = """ -SELECT c +SELECT VALUE c FROM root c OFFSET 0 LIMIT 2 """; @@ -78,7 +78,7 @@ public async Task Can_query_with_implicit_partition_key_filter() { const string readSql = """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Id"] = 42) OR (c["Name"] = "John Snow")) OFFSET 0 LIMIT 2 diff --git a/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs b/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs index 5af5a4b0dde..c5302dabee6 100644 --- a/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/PartitionKeyTest.cs @@ -29,7 +29,7 @@ public virtual async Task Can_add_update_delete_end_to_end_with_partition_key() { const string readSql = """ -SELECT c +SELECT VALUE c FROM root c ORDER BY c["PartitionKey"] OFFSET 0 LIMIT 1 @@ -48,7 +48,7 @@ public virtual async Task Can_add_update_delete_end_to_end_with_with_partition_k { const string readSql = """ -SELECT c +SELECT VALUE c FROM root c OFFSET 0 LIMIT 2 """; @@ -66,7 +66,7 @@ public async Task Can_query_with_implicit_partition_key_filter() { const string readSql = """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Id"] = 42) OR (c["Name"] = "John Snow")) OFFSET 0 LIMIT 1 @@ -120,7 +120,6 @@ protected virtual async Task PartitionKeyTestAsync( var customerFromStore = await readSingleTask(innerContext); AssertSql(readSql); - Assert.Equal(42, customerFromStore.Id); Assert.Equal("Theon", customerFromStore.Name); Assert.Equal(1, customerFromStore.PartitionKey); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/FromSqlQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/FromSqlQueryCosmosTest.cs index 8f5be39c0bc..eb5773c663d 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/FromSqlQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/FromSqlQueryCosmosTest.cs @@ -40,7 +40,7 @@ public Task FromSqlRaw_queryable_simple(bool async) AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" AND c["ContactName"] LIKE '%z%' ) s @@ -83,7 +83,7 @@ public Task FromSqlRaw_queryable_simple_columns_out_of_order(bool async) AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT c["id"], c["Discriminator"], c["Region"], c["PostalCode"], c["Phone"], c["Fax"], c["CustomerID"], c["Country"], c["ContactTitle"], c["ContactName"], c["CompanyName"], c["City"], c["Address"] FROM root c WHERE c["Discriminator"] = "Customer" ) s @@ -111,7 +111,7 @@ public Task FromSqlRaw_queryable_simple_columns_out_of_order_and_extra_columns(b AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT c["id"], c["Discriminator"], c["Region"], c["PostalCode"], c["PostalCode"] AS Foo, c["Phone"], c["Fax"], c["CustomerID"], c["Country"], c["ContactTitle"], c["ContactName"], c["CompanyName"], c["City"], c["Address"] FROM root c WHERE c["Discriminator"] = "Customer" ) s @@ -141,7 +141,7 @@ public Task FromSqlRaw_queryable_composed(bool async) AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" ) s @@ -168,7 +168,7 @@ public virtual Task FromSqlRaw_queryable_composed_after_removing_whitespaces(boo AssertSql( """ -SELECT s +SELECT VALUE s FROM ( @@ -222,7 +222,7 @@ public Task FromSqlRaw_queryable_composed_compiled(bool async) AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" ) s @@ -267,7 +267,7 @@ public virtual Task FromSqlRaw_queryable_composed_compiled_with_parameter(bool a AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" AND c["CustomerID"] = "CONSH" ) s @@ -298,7 +298,7 @@ FROM root c AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c @@ -331,7 +331,7 @@ FROM root c AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c @@ -369,7 +369,7 @@ public Task FromSqlRaw_queryable_with_parameters(bool async) @p0='London' @p1='Sales Representative' -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" AND c["City"] = @p0 AND c["ContactTitle"] = @p1 ) s @@ -401,7 +401,7 @@ public Task FromSqlRaw_queryable_with_parameters_inline(bool async) @p0='London' @p1='Sales Representative' -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" AND c["City"] = @p0 AND c["ContactTitle"] = @p1 ) s @@ -431,7 +431,7 @@ public Task FromSqlRaw_queryable_with_null_parameter(bool async) """ @p0=null -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Employee" AND c["ReportsTo"] = @p0 OR (IS_NULL(c["ReportsTo"]) AND IS_NULL(@p0)) ) s @@ -466,7 +466,7 @@ public Task FromSqlRaw_queryable_with_parameters_and_closure(bool async) @p0='London' @__contactTitle_1='Sales Representative' -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" AND c["City"] = @p0 ) s @@ -503,14 +503,14 @@ public virtual Task FromSqlRaw_queryable_simple_cache_key_includes_query_string( AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" AND c["City"] = 'London' ) s """, // """ -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" AND c["City"] = 'Seattle' ) s @@ -557,7 +557,7 @@ public virtual Task FromSqlRaw_queryable_with_parameters_cache_key_includes_para @p0='London' @p1='Sales Representative' -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" AND c["City"] = @p0 AND c["ContactTitle"] = @p1 ) s @@ -567,7 +567,7 @@ SELECT s @p0='Madrid' @p1='Accounting Manager' -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" AND c["City"] = @p0 AND c["ContactTitle"] = @p1 ) s @@ -595,7 +595,7 @@ public virtual Task FromSqlRaw_queryable_simple_as_no_tracking_not_composed(bool AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" ) s @@ -625,7 +625,7 @@ FROM root c AssertSql( """ -SELECT s["ProductName"] +SELECT VALUE s["ProductName"] FROM ( SELECT * FROM root c @@ -654,7 +654,7 @@ public virtual Task FromSqlRaw_composed_with_nullable_predicate(bool async) AssertSql( """ -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["Discriminator"] = "Customer" ) s @@ -748,7 +748,7 @@ await AssertQuery( @p0='London' @p1='Sales Representative' -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["City"] = @p0 AND c["ContactTitle"] = @p1 ) s @@ -772,7 +772,7 @@ await AssertQuery( @p0='London' @p1='Sales Representative' -SELECT s +SELECT VALUE s FROM ( SELECT * FROM root c WHERE c["City"] = @p0 AND c["ContactTitle"] = @p1 ) s diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs index 6b468bf6e68..e069d65d502 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/InheritanceQueryCosmosTest.cs @@ -22,21 +22,21 @@ public override Task Can_query_when_shared_column(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = 1) OFFSET 0 LIMIT 2 """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = 2) OFFSET 0 LIMIT 2 """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = 3) OFFSET 0 LIMIT 2 @@ -51,7 +51,7 @@ public override Task Can_query_all_types_when_shared_column(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN (0, 1, 2, 3) """); @@ -65,7 +65,7 @@ public override Task Can_use_of_type_animal(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("Eagle", "Kiwi") ORDER BY c["Species"] @@ -80,7 +80,7 @@ public override Task Can_use_is_kiwi(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) """); @@ -94,10 +94,7 @@ public override Task Can_use_is_kiwi_with_cast(bool async) AssertSql( """ -SELECT VALUE -{ - "Value" : ((c["Discriminator"] = "Kiwi") ? c["FoundOn"] : 0) -} +SELECT VALUE ((c["Discriminator"] = "Kiwi") ? c["FoundOn"] : 0) FROM root c WHERE c["Discriminator"] IN ("Eagle", "Kiwi") """); @@ -111,7 +108,7 @@ public override Task Can_use_backwards_is_animal(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Kiwi") """); @@ -125,7 +122,7 @@ public override Task Can_use_is_kiwi_with_other_predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND ((c["Discriminator"] = "Kiwi") AND (c["CountryId"] = 1))) """); @@ -139,7 +136,7 @@ public override Task Can_use_is_kiwi_in_projection(bool async) AssertSql( """ -SELECT (c["Discriminator"] = "Kiwi") AS c +SELECT VALUE (c["Discriminator"] = "Kiwi") FROM root c WHERE c["Discriminator"] IN ("Eagle", "Kiwi") """); @@ -153,7 +150,7 @@ public override Task Can_use_of_type_bird(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("Eagle", "Kiwi") ORDER BY c["Species"] @@ -168,7 +165,7 @@ public override Task Can_use_of_type_bird_predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["CountryId"] = 1)) AND c["Discriminator"] IN ("Eagle", "Kiwi")) ORDER BY c["Species"] @@ -183,7 +180,7 @@ public override Task Can_use_of_type_bird_with_projection(bool async) AssertSql( """ -SELECT c["EagleId"] +SELECT VALUE c["EagleId"] FROM root c WHERE c["Discriminator"] IN ("Eagle", "Kiwi") """); @@ -197,7 +194,7 @@ public override Task Can_use_of_type_bird_first(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("Eagle", "Kiwi") ORDER BY c["Species"] @@ -213,7 +210,7 @@ public override Task Can_use_of_type_kiwi(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) """); @@ -227,7 +224,7 @@ public override Task Can_use_backwards_of_type_animal(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Kiwi") """); @@ -241,7 +238,7 @@ public override Task Can_use_of_type_rose(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Daisy", "Rose") AND (c["Discriminator"] = "Rose")) """); @@ -255,7 +252,7 @@ public override Task Can_query_all_animals(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("Eagle", "Kiwi") ORDER BY c["Species"] @@ -278,7 +275,7 @@ public override Task Can_query_all_plants(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("Daisy", "Rose") ORDER BY c["Species"] @@ -293,7 +290,7 @@ public override Task Can_filter_all_animals(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Name"] = "Great spotted kiwi")) ORDER BY c["Species"] @@ -308,7 +305,7 @@ public override Task Can_query_all_birds(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("Eagle", "Kiwi") ORDER BY c["Species"] @@ -323,7 +320,7 @@ public override Task Can_query_just_kiwis(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Kiwi") OFFSET 0 LIMIT 2 @@ -338,7 +335,7 @@ public override Task Can_query_just_roses(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Rose") OFFSET 0 LIMIT 2 @@ -369,7 +366,7 @@ public override Task Can_use_of_type_kiwi_where_south_on_derived_property(bool a AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) AND (c["FoundOn"] = 1)) """); @@ -383,7 +380,7 @@ public override Task Can_use_of_type_kiwi_where_north_on_derived_property(bool a AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) AND (c["FoundOn"] = 0)) """); @@ -397,7 +394,7 @@ public override Task Discriminator_used_when_projection_over_derived_type(bool a AssertSql( """ -SELECT c["FoundOn"] +SELECT VALUE c["FoundOn"] FROM root c WHERE (c["Discriminator"] = "Kiwi") """); @@ -425,7 +422,7 @@ public override Task Discriminator_with_cast_in_shadow_property(bool async) AssertSql( """ -SELECT c["Name"] AS Predator +SELECT VALUE c["Name"] FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND ("Kiwi" = c["Discriminator"])) """); @@ -439,7 +436,7 @@ public override Task Discriminator_used_when_projection_over_of_type(bool async) AssertSql( """ -SELECT c["FoundOn"] +SELECT VALUE c["FoundOn"] FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) """); @@ -484,7 +481,7 @@ public override Task Subquery_OfType(bool async) """ @__p_0='5' -SELECT DISTINCT c +SELECT DISTINCT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) ORDER BY c["Species"] @@ -505,7 +502,7 @@ public override async Task Setting_foreign_key_to_a_different_type_throws() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Kiwi") OFFSET 0 LIMIT 2 @@ -520,7 +517,7 @@ public override Task Byte_enum_value_constant_used_in_projection(bool async) AssertSql( """ -SELECT (c["IsFlightless"] ? 0 : 1) AS c +SELECT VALUE (c["IsFlightless"] ? 0 : 1) FROM root c WHERE (c["Discriminator"] = "Kiwi") """); @@ -532,7 +529,7 @@ public override async Task Member_access_on_intermediate_type_works() AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE (c["Discriminator"] = "Kiwi") ORDER BY c["Name"] @@ -555,7 +552,7 @@ public override Task Selecting_only_base_properties_on_base_type(bool async) AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE c["Discriminator"] IN ("Eagle", "Kiwi") """); @@ -569,7 +566,7 @@ public override Task Selecting_only_base_properties_on_derived_type(bool async) AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE c["Discriminator"] IN ("Eagle", "Kiwi") """); @@ -583,7 +580,7 @@ public override Task GetType_in_hierarchy_in_abstract_base_type(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -597,7 +594,7 @@ public override Task GetType_in_hierarchy_in_intermediate_type(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -611,7 +608,7 @@ public override Task GetType_in_hierarchy_in_leaf_type_with_sibling(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Eagle")) """); @@ -625,7 +622,7 @@ public override Task GetType_in_hierarchy_in_leaf_type_with_sibling2(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) """); @@ -639,7 +636,7 @@ public override Task GetType_in_hierarchy_in_leaf_type_with_sibling2_reverse(boo AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) """); @@ -653,7 +650,7 @@ public override Task GetType_in_hierarchy_in_leaf_type_with_sibling2_not_equal(b AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] != "Kiwi")) """); @@ -667,7 +664,7 @@ public override Task Using_is_operator_on_multiple_type_with_no_result(bool asyn AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) AND (c["Discriminator"] = "Eagle")) """); @@ -681,7 +678,7 @@ public override Task Using_is_operator_with_of_type_on_multiple_type_with_no_res AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) AND (c["Discriminator"] = "Eagle")) """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryCosmosTest.cs index 8af321be555..e62ce8293ac 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryCosmosTest.cs @@ -13,7 +13,7 @@ public override async Task Array_of_string() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -29,7 +29,7 @@ public override async Task Array_of_int() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -45,7 +45,7 @@ public override async Task Array_of_long() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -61,7 +61,7 @@ public override async Task Array_of_short() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -82,7 +82,7 @@ public override async Task Array_of_double() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -98,7 +98,7 @@ public override async Task Array_of_float() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -114,7 +114,7 @@ public override async Task Array_of_decimal() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -130,7 +130,7 @@ public override async Task Array_of_DateTime() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -146,7 +146,7 @@ public override async Task Array_of_DateTime_with_milliseconds() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -162,7 +162,7 @@ public override async Task Array_of_DateTime_with_microseconds() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -178,7 +178,7 @@ public override async Task Array_of_DateOnly() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -194,7 +194,7 @@ public override async Task Array_of_TimeOnly() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -210,7 +210,7 @@ public override async Task Array_of_TimeOnly_with_milliseconds() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -226,7 +226,7 @@ public override async Task Array_of_TimeOnly_with_microseconds() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -242,7 +242,7 @@ public override async Task Array_of_DateTimeOffset() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -258,7 +258,7 @@ public override async Task Array_of_bool() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -274,7 +274,7 @@ public override async Task Array_of_Guid() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -291,7 +291,7 @@ public override async Task Array_of_byte_array() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -307,7 +307,7 @@ public override async Task Array_of_enum() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -331,7 +331,7 @@ public override async Task Column_with_custom_converter() """ @__ints_0='1,2,3' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Ints"] = @__ints_0) OFFSET 0 LIMIT 2 @@ -359,7 +359,7 @@ public override async Task Inline_collection_in_query_filter() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -375,7 +375,7 @@ public override async Task Project_collection_from_entity_type_with_owned() AssertSql( """ -SELECT c["Ints"] +SELECT VALUE c["Ints"] FROM root c WHERE (c["Discriminator"] = "TestEntityWithOwned") """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs index 8d6afb928ae..d97e0bc94c6 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindAggregateOperatorsQueryCosmosTest.cs @@ -35,7 +35,7 @@ public override Task Average_over_default_returns_default(bool async) AssertSql( """ -SELECT AVG((c["OrderID"] - 10248)) AS c +SELECT VALUE AVG((c["OrderID"] - 10248)) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10248)) """); @@ -63,7 +63,7 @@ public override Task Contains_with_local_non_primitive_list_closure_mix(bool asy """ @__Select_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__Select_0, c["CustomerID"])) """); @@ -79,7 +79,7 @@ public override Task Contains_with_local_non_primitive_list_inline_closure_mix(b """ @__Select_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__Select_0, c["CustomerID"])) """, @@ -87,7 +87,7 @@ FROM root c """ @__Select_0='["ABCDE","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__Select_0, c["CustomerID"])) """); @@ -101,19 +101,19 @@ public override Task Count_on_projection_with_client_eval(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE (c["Discriminator"] = "Order") """, // """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE (c["Discriminator"] = "Order") """, // """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -127,7 +127,7 @@ public override Task First(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["ContactName"] @@ -143,7 +143,7 @@ public override Task Max_over_default_returns_default(bool async) AssertSql( """ -SELECT MAX((c["OrderID"] - 10248)) AS c +SELECT VALUE MAX((c["OrderID"] - 10248)) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10248)) """); @@ -157,7 +157,7 @@ public override Task Min_over_default_returns_default(bool async) AssertSql( """ -SELECT MIN((c["OrderID"] - 10248)) AS c +SELECT VALUE MIN((c["OrderID"] - 10248)) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10248)) """); @@ -171,7 +171,7 @@ public override Task Sum_over_empty_returns_zero(bool async) AssertSql( """ -SELECT SUM(c["OrderID"]) AS c +SELECT VALUE SUM(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 42)) """); @@ -185,7 +185,7 @@ public override Task First_Predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) ORDER BY c["ContactName"] @@ -202,7 +202,7 @@ public override async Task Single_Throws(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") OFFSET 0 LIMIT 2 @@ -218,7 +218,7 @@ public override Task Where_First(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) ORDER BY c["ContactName"] @@ -243,7 +243,7 @@ public override Task FirstOrDefault(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["ContactName"] @@ -259,7 +259,7 @@ public override Task Array_cast_to_IEnumerable_Contains_with_constant(bool async AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN ("ALFKI", "WRONG")) """); @@ -273,7 +273,7 @@ public override Task FirstOrDefault_Predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) ORDER BY c["ContactName"] @@ -299,7 +299,7 @@ public override async Task SingleOrDefault_Throws(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") OFFSET 0 LIMIT 2 @@ -315,7 +315,7 @@ public override Task Where_FirstOrDefault(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) ORDER BY c["ContactName"] @@ -352,7 +352,7 @@ public override Task Sum_with_no_arg(bool async) AssertSql( """ -SELECT SUM(c["OrderID"]) AS c +SELECT VALUE SUM(c["OrderID"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -366,7 +366,7 @@ public override Task Sum_with_no_data_cast_to_nullable(bool async) AssertSql( """ -SELECT SUM(c["OrderID"]) AS c +SELECT VALUE SUM(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] < 0)) """); @@ -380,7 +380,7 @@ public override Task Sum_with_binary_expression(bool async) AssertSql( """ -SELECT SUM((c["OrderID"] * 2)) AS c +SELECT VALUE SUM((c["OrderID"] * 2)) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -394,7 +394,7 @@ public override Task Sum_with_no_arg_empty(bool async) AssertSql( """ -SELECT SUM(c["OrderID"]) AS c +SELECT VALUE SUM(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 42)) """); @@ -408,7 +408,7 @@ public override Task Sum_with_no_data_nullable(bool async) AssertSql( """ -SELECT SUM(c["SupplierID"]) AS c +SELECT VALUE SUM(c["SupplierID"]) FROM root c WHERE (c["Discriminator"] = "Product") """); @@ -422,7 +422,7 @@ public override Task Sum_with_arg(bool async) AssertSql( """ -SELECT SUM(c["OrderID"]) AS c +SELECT VALUE SUM(c["OrderID"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -436,7 +436,7 @@ public override Task Sum_with_arg_expression(bool async) AssertSql( """ -SELECT SUM((c["OrderID"] + c["OrderID"])) AS c +SELECT VALUE SUM((c["OrderID"] + c["OrderID"])) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -467,7 +467,7 @@ public override Task Sum_with_coalesce(bool async) AssertSql( """ -SELECT SUM(((c["UnitPrice"] != null) ? c["UnitPrice"] : 0.0)) AS c +SELECT VALUE SUM(((c["UnitPrice"] != null) ? c["UnitPrice"] : 0.0)) FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["ProductID"] < 40)) """); @@ -505,7 +505,7 @@ public override Task Sum_on_float_column(bool async) AssertSql( """ -SELECT SUM(c["Discount"]) AS c +SELECT VALUE SUM(c["Discount"]) FROM root c WHERE ((c["Discriminator"] = "OrderDetail") AND (c["ProductID"] = 1)) """); @@ -528,40 +528,56 @@ public override async Task Average_no_data(bool async) AssertSql( """ -SELECT AVG(c["OrderID"]) AS c +SELECT VALUE AVG(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = -1)) """); } } - public override Task Average_no_data_nullable(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Average_no_data_nullable(a); + public override async Task Average_no_data_nullable(bool async) + { + // Sync always throws before getting to exception being tested. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + Assert.Equal( + CoreStrings.SequenceContainsNoElements, + (await Assert.ThrowsAsync(() => base.Average_no_data_nullable(a))).Message); - AssertSql( - """ -SELECT AVG(c["SupplierID"]) AS c + AssertSql( + """ +SELECT VALUE AVG(c["SupplierID"]) FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["SupplierID"] = -1)) """); - }); + }); + } + } - public override Task Average_no_data_cast_to_nullable(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Average_no_data_cast_to_nullable(a); + public override async Task Average_no_data_cast_to_nullable(bool async) + { + // Sync always throws before getting to exception being tested. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + Assert.Equal( + CoreStrings.SequenceContainsNoElements, + (await Assert.ThrowsAsync(() => base.Average_no_data_cast_to_nullable(a))).Message); - AssertSql( - """ -SELECT AVG(c["OrderID"]) AS c + AssertSql( + """ +SELECT VALUE AVG(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = -1)) """); - }); + }); + } + } public override async Task Min_no_data(bool async) { @@ -572,7 +588,7 @@ public override async Task Min_no_data(bool async) AssertSql( """ -SELECT MIN(c["OrderID"]) AS c +SELECT VALUE MIN(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = -1)) """); @@ -588,7 +604,7 @@ public override async Task Max_no_data(bool async) AssertSql( """ -SELECT MAX(c["OrderID"]) AS c +SELECT VALUE MAX(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = -1)) """); @@ -611,33 +627,49 @@ public override async Task Max_no_data_subquery(bool async) AssertSql(); } - public override Task Max_no_data_nullable(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Max_no_data_nullable(a); + public override async Task Max_no_data_nullable(bool async) + { + // Sync always throws before getting to exception being tested. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + Assert.Equal( + CoreStrings.SequenceContainsNoElements, + (await Assert.ThrowsAsync(() => base.Max_no_data_nullable(a))).Message); - AssertSql( - """ -SELECT MAX(c["SupplierID"]) AS c + AssertSql( + """ +SELECT VALUE MAX(c["SupplierID"]) FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["SupplierID"] = -1)) """); - }); + }); + } + } - public override Task Max_no_data_cast_to_nullable(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Max_no_data_cast_to_nullable(a); + public override async Task Max_no_data_cast_to_nullable(bool async) + { + // Sync always throws before getting to exception being tested. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + Assert.Equal( + CoreStrings.SequenceContainsNoElements, + (await Assert.ThrowsAsync(() => base.Max_no_data_cast_to_nullable(a))).Message); - AssertSql( - """ -SELECT MAX(c["OrderID"]) AS c + AssertSql( + """ +SELECT VALUE MAX(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = -1)) """); - }); + }); + } + } public override async Task Min_no_data_subquery(bool async) { @@ -657,7 +689,7 @@ public override async Task Average_with_no_arg(bool async) AssertSql( """ -SELECT AVG(c["OrderID"]) AS c +SELECT VALUE AVG(c["OrderID"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -672,7 +704,7 @@ public override Task Average_with_binary_expression(bool async) AssertSql( """ -SELECT AVG((c["OrderID"] * 2)) AS c +SELECT VALUE AVG((c["OrderID"] * 2)) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -688,7 +720,7 @@ public override async Task Average_with_arg(bool async) AssertSql( """ -SELECT AVG(c["OrderID"]) AS c +SELECT VALUE AVG(c["OrderID"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -703,7 +735,7 @@ public override Task Average_with_arg_expression(bool async) AssertSql( """ -SELECT AVG((c["OrderID"] + c["OrderID"])) AS c +SELECT VALUE AVG((c["OrderID"] + c["OrderID"])) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -734,7 +766,7 @@ public override Task Average_with_coalesce(bool async) AssertSql( """ -SELECT AVG(((c["UnitPrice"] != null) ? c["UnitPrice"] : 0.0)) AS c +SELECT VALUE AVG(((c["UnitPrice"] != null) ? c["UnitPrice"] : 0.0)) FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["ProductID"] < 40)) """); @@ -772,7 +804,7 @@ public override Task Average_on_float_column(bool async) AssertSql( """ -SELECT AVG(c["Discount"]) AS c +SELECT VALUE AVG(c["Discount"]) FROM root c WHERE ((c["Discriminator"] = "OrderDetail") AND (c["ProductID"] = 1)) """); @@ -802,7 +834,7 @@ public override Task Min_with_no_arg(bool async) AssertSql( """ -SELECT MIN(c["OrderID"]) AS c +SELECT VALUE MIN(c["OrderID"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -816,39 +848,55 @@ public override Task Min_with_arg(bool async) AssertSql( """ -SELECT MIN(c["OrderID"]) AS c +SELECT VALUE MIN(c["OrderID"]) FROM root c WHERE (c["Discriminator"] = "Order") """); }); - public override Task Min_no_data_nullable(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Min_no_data_nullable(a); + public override async Task Min_no_data_nullable(bool async) + { + // Sync always throws before getting to exception being tested. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + Assert.Equal( + CoreStrings.SequenceContainsNoElements, + (await Assert.ThrowsAsync(() => base.Min_no_data_nullable(a))).Message); - AssertSql( - """ -SELECT MIN(c["SupplierID"]) AS c + AssertSql( + """ +SELECT VALUE MIN(c["SupplierID"]) FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["SupplierID"] = -1)) """); - }); + }); + } + } - public override Task Min_no_data_cast_to_nullable(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Min_no_data_cast_to_nullable(a); + public override async Task Min_no_data_cast_to_nullable(bool async) + { + // Sync always throws before getting to exception being tested. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + Assert.Equal( + CoreStrings.SequenceContainsNoElements, + (await Assert.ThrowsAsync(() => base.Min_no_data_cast_to_nullable(a))).Message); - AssertSql( - """ -SELECT MIN(c["OrderID"]) AS c + AssertSql( + """ +SELECT VALUE MIN(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = -1)) """); - }); + }); + } + } public override Task Min_with_coalesce(bool async) => Fixture.NoSyncTest( @@ -858,7 +906,7 @@ public override Task Min_with_coalesce(bool async) AssertSql( """ -SELECT MIN(((c["UnitPrice"] != null) ? c["UnitPrice"] : 0.0)) AS c +SELECT VALUE MIN(((c["UnitPrice"] != null) ? c["UnitPrice"] : 0.0)) FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["ProductID"] < 40)) """); @@ -896,7 +944,7 @@ public override Task Max_with_no_arg(bool async) AssertSql( """ -SELECT MAX(c["OrderID"]) AS c +SELECT VALUE MAX(c["OrderID"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -910,7 +958,7 @@ public override Task Max_with_arg(bool async) AssertSql( """ -SELECT MAX(c["OrderID"]) AS c +SELECT VALUE MAX(c["OrderID"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -924,7 +972,7 @@ public override Task Max_with_coalesce(bool async) AssertSql( """ -SELECT MAX(((c["UnitPrice"] != null) ? c["UnitPrice"] : 0.0)) AS c +SELECT VALUE MAX(((c["UnitPrice"] != null) ? c["UnitPrice"] : 0.0)) FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["ProductID"] < 40)) """); @@ -962,7 +1010,7 @@ public override Task Count_with_no_predicate(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -976,7 +1024,7 @@ public override Task Count_with_predicate(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) """); @@ -990,7 +1038,7 @@ public override Task Count_with_order_by(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -1004,7 +1052,7 @@ public override Task Where_OrderBy_Count(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) """); @@ -1018,7 +1066,7 @@ public override Task OrderBy_Where_Count(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) """); @@ -1032,7 +1080,7 @@ public override Task OrderBy_Count_with_predicate(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) """); @@ -1046,7 +1094,7 @@ public override Task OrderBy_Where_Count_with_predicate(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE (((c["Discriminator"] = "Order") AND (c["OrderID"] > 10)) AND (c["CustomerID"] != "ALFKI")) """); @@ -1129,7 +1177,7 @@ await Assert.ThrowsAsync( """ @__p_0='10' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Employee") ORDER BY 42 @@ -1146,7 +1194,7 @@ public override Task Distinct(bool async) AssertSql( """ -SELECT DISTINCT c +SELECT DISTINCT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -1262,7 +1310,7 @@ public override Task Last(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["ContactName"] DESC @@ -1296,7 +1344,7 @@ public override Task Last_Predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) ORDER BY c["ContactName"] DESC @@ -1312,7 +1360,7 @@ public override Task Where_Last(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) ORDER BY c["ContactName"] DESC @@ -1328,7 +1376,7 @@ public override Task LastOrDefault(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["ContactName"] DESC @@ -1344,7 +1392,7 @@ public override Task LastOrDefault_Predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) ORDER BY c["ContactName"] DESC @@ -1360,7 +1408,7 @@ public override Task Where_LastOrDefault(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) ORDER BY c["ContactName"] DESC @@ -1386,7 +1434,7 @@ public override Task Contains_with_local_array_closure(bool async) """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """, @@ -1394,7 +1442,7 @@ FROM root c """ @__ids_0='["ABCDE"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1418,7 +1466,7 @@ public override Task Contains_with_local_uint_array_closure(bool async) """ @__ids_0='[0,1]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND ARRAY_CONTAINS(@__ids_0, c["EmployeeID"])) """, @@ -1426,7 +1474,7 @@ FROM root c """ @__ids_0='[0]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND ARRAY_CONTAINS(@__ids_0, c["EmployeeID"])) """); @@ -1442,7 +1490,7 @@ public override Task Contains_with_local_nullable_uint_array_closure(bool async) """ @__ids_0='[0,1]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND ARRAY_CONTAINS(@__ids_0, c["EmployeeID"])) """, @@ -1450,7 +1498,7 @@ FROM root c """ @__ids_0='[0]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND ARRAY_CONTAINS(@__ids_0, c["EmployeeID"])) """); @@ -1464,7 +1512,7 @@ public override Task Contains_with_local_array_inline(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN ("ABCDE", "ALFKI")) """); @@ -1480,7 +1528,7 @@ public override Task Contains_with_local_list_closure(bool async) """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1496,7 +1544,7 @@ public override Task Contains_with_local_object_list_closure(bool async) """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1512,7 +1560,7 @@ public override Task Contains_with_local_list_closure_all_null(bool async) """ @__ids_0='[null,null]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1526,7 +1574,7 @@ public override Task Contains_with_local_list_inline(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN ("ABCDE", "ALFKI")) """); @@ -1542,7 +1590,7 @@ public override Task Contains_with_local_list_inline_closure_mix(bool async) """ @__p_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__p_0, c["CustomerID"])) """, @@ -1550,7 +1598,7 @@ FROM root c """ @__p_0='["ABCDE","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__p_0, c["CustomerID"])) """); @@ -1565,7 +1613,7 @@ public override Task Contains_with_local_enumerable_closure(bool async) """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """, @@ -1573,7 +1621,7 @@ FROM root c """ @__ids_0='["ABCDE"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1589,7 +1637,7 @@ public override Task Contains_with_local_object_enumerable_closure(bool async) """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1605,7 +1653,7 @@ public override Task Contains_with_local_enumerable_closure_all_null(bool async) """ @__ids_0='[]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1619,7 +1667,7 @@ public override Task Contains_with_local_enumerable_inline(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND EXISTS ( SELECT 1 @@ -1638,7 +1686,7 @@ public override Task Contains_with_local_enumerable_inline_closure_mix(bool asyn """ @__p_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND EXISTS ( SELECT 1 @@ -1649,7 +1697,7 @@ FROM p IN (SELECT VALUE @__p_0) """ @__p_0='["ABCDE","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND EXISTS ( SELECT 1 @@ -1668,7 +1716,7 @@ public override Task Contains_with_local_ordered_enumerable_closure(bool async) """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """, @@ -1676,7 +1724,7 @@ FROM root c """ @__ids_0='["ABCDE"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1692,7 +1740,7 @@ public override Task Contains_with_local_object_ordered_enumerable_closure(bool """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1708,7 +1756,7 @@ public override Task Contains_with_local_ordered_enumerable_closure_all_null(boo """ @__ids_0='[null,null]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1722,7 +1770,7 @@ public override Task Contains_with_local_ordered_enumerable_inline(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN ("ABCDE", "ALFKI")) """); @@ -1738,7 +1786,7 @@ public override Task Contains_with_local_ordered_enumerable_inline_closure_mix(b """ @__Order_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__Order_0, c["CustomerID"])) """, @@ -1746,7 +1794,7 @@ FROM root c """ @__Order_0='["ABCDE","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__Order_0, c["CustomerID"])) """); @@ -1762,7 +1810,7 @@ public override Task Contains_with_local_read_only_collection_closure(bool async """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """, @@ -1770,7 +1818,7 @@ FROM root c """ @__ids_0='["ABCDE"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1786,7 +1834,7 @@ public override Task Contains_with_local_object_read_only_collection_closure(boo """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1802,7 +1850,7 @@ public override Task Contains_with_local_ordered_read_only_collection_all_null(b """ @__ids_0='[null,null]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1816,7 +1864,7 @@ public override Task Contains_with_local_read_only_collection_inline(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN ("ABCDE", "ALFKI")) """); @@ -1832,7 +1880,7 @@ public override Task Contains_with_local_read_only_collection_inline_closure_mix """ @__AsReadOnly_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__AsReadOnly_0, c["CustomerID"])) """, @@ -1840,7 +1888,7 @@ FROM root c """ @__AsReadOnly_0='["ABCDE","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__AsReadOnly_0, c["CustomerID"])) """); @@ -1856,7 +1904,7 @@ public override Task Contains_with_local_collection_false(bool async) """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND NOT(ARRAY_CONTAINS(@__ids_0, c["CustomerID"]))) """); @@ -1872,7 +1920,7 @@ public override Task Contains_with_local_collection_complex_predicate_and(bool a """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["CustomerID"] = "ALFKI") OR (c["CustomerID"] = "ABCDE")) AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"]))) """); @@ -1888,7 +1936,7 @@ public override Task Contains_with_local_collection_complex_predicate_or(bool as """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (ARRAY_CONTAINS(@__ids_0, c["CustomerID"]) OR ((c["CustomerID"] = "ALFKI") OR (c["CustomerID"] = "ABCDE")))) """); @@ -1904,7 +1952,7 @@ public override Task Contains_with_local_collection_complex_predicate_not_matchi """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["CustomerID"] = "ALFKI") OR (c["CustomerID"] = "ABCDE")) OR NOT(ARRAY_CONTAINS(@__ids_0, c["CustomerID"])))) """); @@ -1920,7 +1968,7 @@ public override Task Contains_with_local_collection_complex_predicate_not_matchi """ @__ids_0='["ABCDE","ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (ARRAY_CONTAINS(@__ids_0, c["CustomerID"]) AND ((c["CustomerID"] != "ALFKI") AND (c["CustomerID"] != "ABCDE")))) """); @@ -1936,7 +1984,7 @@ public override Task Contains_with_local_collection_sql_injection(bool async) """ @__ids_0='["ALFKI","ABC')); GO; DROP TABLE Orders; GO; --"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (ARRAY_CONTAINS(@__ids_0, c["CustomerID"]) OR ((c["CustomerID"] = "ALFKI") OR (c["CustomerID"] = "ABCDE")))) """); @@ -1952,7 +2000,7 @@ public override Task Contains_with_local_collection_empty_closure(bool async) """ @__ids_0='[]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -1966,7 +2014,7 @@ public override Task Contains_with_local_collection_empty_inline(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND NOT(false)) """); @@ -1986,10 +2034,10 @@ public override async Task Contains_top_level(bool async) """ @__p_0='ALFKI' -SELECT EXISTS ( +SELECT VALUE EXISTS ( SELECT 1 FROM root c - WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = @__p_0))) AS c + WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = @__p_0))) """); } } @@ -2112,7 +2160,7 @@ public override Task List_Contains_with_constant_list(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN ("ALFKI", "ANATR")) """); @@ -2126,7 +2174,7 @@ public override Task List_Contains_with_parameter_list(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN ("ALFKI", "ANATR")) """); @@ -2140,7 +2188,7 @@ public override Task Contains_with_parameter_list_value_type_id(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND c["OrderID"] IN (10248, 10249)) """); @@ -2154,7 +2202,7 @@ public override Task Contains_with_constant_list_value_type_id(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND c["OrderID"] IN (10248, 10249)) """); @@ -2168,7 +2216,7 @@ public override Task IImmutableSet_Contains_with_parameter(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -2182,7 +2230,7 @@ public override Task IReadOnlySet_Contains_with_parameter(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -2198,7 +2246,7 @@ public override Task HashSet_Contains_with_parameter(bool async) """ @__ids_0='["ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -2214,7 +2262,7 @@ public override Task ImmutableHashSet_Contains_with_parameter(bool async) """ @__ids_0='["ALFKI"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -2235,10 +2283,10 @@ public override async Task Contains_over_entityType_with_null_should_rewrite_to_ """ @__entity_equality_p_0_OrderID=null -SELECT EXISTS ( +SELECT VALUE EXISTS ( SELECT 1 FROM root c - WHERE (((c["Discriminator"] = "Order") AND (c["CustomerID"] = "VINET")) AND (c["OrderID"] = @__entity_equality_p_0_OrderID))) AS c + WHERE (((c["Discriminator"] = "Order") AND (c["CustomerID"] = "VINET")) AND (c["OrderID"] = @__entity_equality_p_0_OrderID))) """); } } @@ -2259,7 +2307,7 @@ public override Task String_FirstOrDefault_in_projection_does_not_do_client_eval AssertSql( """ -SELECT LEFT(c["CustomerID"], 1) AS c +SELECT VALUE LEFT(c["CustomerID"], 1) FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -2273,7 +2321,7 @@ public override Task Project_constant_Sum(bool async) AssertSql( """ -SELECT SUM(1) AS c +SELECT VALUE SUM(1) FROM root c WHERE (c["Discriminator"] = "Employee") """); @@ -2289,7 +2337,7 @@ public override Task Where_subquery_any_equals_operator(bool async) """ @__ids_0='["ABCDE","ALFKI","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -2303,7 +2351,7 @@ public override Task Where_subquery_any_equals(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN ("ABCDE", "ALFKI", "ANATR")) """); @@ -2319,7 +2367,7 @@ public override Task Where_subquery_any_equals_static(bool async) """ @__ids_0='["ABCDE","ALFKI","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -2335,7 +2383,7 @@ public override Task Where_subquery_where_any(bool async) """ @__ids_0='["ABCDE","ALFKI","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "Customer") AND (c["City"] = "México D.F.")) AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """, @@ -2343,7 +2391,7 @@ FROM root c """ @__ids_0='["ABCDE","ALFKI","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "Customer") AND (c["City"] = "México D.F.")) AND ARRAY_CONTAINS(@__ids_0, c["CustomerID"])) """); @@ -2359,7 +2407,7 @@ public override Task Where_subquery_all_not_equals_operator(bool async) """ @__ids_0='["ABCDE","ALFKI","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND NOT(ARRAY_CONTAINS(@__ids_0, c["CustomerID"]))) """); @@ -2373,7 +2421,7 @@ public override Task Where_subquery_all_not_equals(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] NOT IN ("ABCDE", "ALFKI", "ANATR")) """); @@ -2389,7 +2437,7 @@ public override Task Where_subquery_all_not_equals_static(bool async) """ @__ids_0='["ABCDE","ALFKI","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND NOT(ARRAY_CONTAINS(@__ids_0, c["CustomerID"]))) """); @@ -2405,7 +2453,7 @@ public override Task Where_subquery_where_all(bool async) """ @__ids_0='["ABCDE","ALFKI","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "Customer") AND (c["City"] = "México D.F.")) AND NOT(ARRAY_CONTAINS(@__ids_0, c["CustomerID"]))) """, @@ -2413,7 +2461,7 @@ FROM root c """ @__ids_0='["ABCDE","ALFKI","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "Customer") AND (c["City"] = "México D.F.")) AND NOT(ARRAY_CONTAINS(@__ids_0, c["CustomerID"]))) """); @@ -2427,7 +2475,7 @@ public override Task Cast_to_same_Type_Count_works(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -2637,7 +2685,7 @@ public override Task Contains_inside_Average_without_GroupBy(bool async) """ @__cities_0='["London","Berlin"]' -SELECT AVG((ARRAY_CONTAINS(@__cities_0, c["City"]) ? 1.0 : 0.0)) AS c +SELECT VALUE AVG((ARRAY_CONTAINS(@__cities_0, c["City"]) ? 1.0 : 0.0)) FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -2653,7 +2701,7 @@ public override Task Contains_inside_Sum_without_GroupBy(bool async) """ @__cities_0='["London","Berlin"]' -SELECT SUM((ARRAY_CONTAINS(@__cities_0, c["City"]) ? 1 : 0)) AS c +SELECT VALUE SUM((ARRAY_CONTAINS(@__cities_0, c["City"]) ? 1 : 0)) FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -2669,7 +2717,7 @@ public override Task Contains_inside_Count_without_GroupBy(bool async) """ @__cities_0='["London","Berlin"]' -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__cities_0, c["City"])) """); @@ -2685,7 +2733,7 @@ public override Task Contains_inside_LongCount_without_GroupBy(bool async) """ @__cities_0='["London","Berlin"]' -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__cities_0, c["City"])) """); @@ -2701,7 +2749,7 @@ public override Task Contains_inside_Max_without_GroupBy(bool async) """ @__cities_0='["London","Berlin"]' -SELECT MAX((ARRAY_CONTAINS(@__cities_0, c["City"]) ? 1 : 0)) AS c +SELECT VALUE MAX((ARRAY_CONTAINS(@__cities_0, c["City"]) ? 1 : 0)) FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -2717,7 +2765,7 @@ public override Task Contains_inside_Min_without_GroupBy(bool async) """ @__cities_0='["London","Berlin"]' -SELECT MIN((ARRAY_CONTAINS(@__cities_0, c["City"]) ? 1 : 0)) AS c +SELECT VALUE MIN((ARRAY_CONTAINS(@__cities_0, c["City"]) ? 1 : 0)) FROM root c WHERE (c["Discriminator"] = "Customer") """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs index f763a2682ad..22679641139 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindDbFunctionsQueryCosmosTest.cs @@ -62,7 +62,7 @@ public override Task Random_return_less_than_1(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Order") AND (RAND() < 1.0)) """); @@ -76,7 +76,7 @@ public override Task Random_return_greater_than_0(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Order") AND (RAND() >= 0.0)) """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs index c02d55e4a7a..c50c3d01e5d 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs @@ -34,7 +34,7 @@ public override Task String_StartsWith_Literal(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["ContactName"], "M")) """); @@ -50,7 +50,7 @@ public override Task String_StartsWith_Parameter(bool async) """ @__pattern_0='M' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["ContactName"], @__pattern_0)) """); @@ -64,7 +64,7 @@ public override Task String_StartsWith_Identity(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["ContactName"], c["ContactName"])) """); @@ -78,7 +78,7 @@ public override Task String_StartsWith_Column(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["ContactName"], c["ContactName"])) """); @@ -92,7 +92,7 @@ public override Task String_StartsWith_MethodCall(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["ContactName"], "M")) """); @@ -106,7 +106,7 @@ public override Task String_StartsWith_with_StringComparison_Ordinal(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CompanyName"], "Qu", false)) """); @@ -120,7 +120,7 @@ public override Task String_StartsWith_with_StringComparison_OrdinalIgnoreCase(b AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CompanyName"], "Qu", true)) """); @@ -147,7 +147,7 @@ public override Task String_EndsWith_Literal(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ENDSWITH(c["ContactName"], "b")) """); @@ -163,7 +163,7 @@ public override Task String_EndsWith_Parameter(bool async) """ @__pattern_0='b' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ENDSWITH(c["ContactName"], @__pattern_0)) """); @@ -177,7 +177,7 @@ public override Task String_EndsWith_Identity(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ENDSWITH(c["ContactName"], c["ContactName"])) """); @@ -191,7 +191,7 @@ public override Task String_EndsWith_Column(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ENDSWITH(c["ContactName"], c["ContactName"])) """); @@ -205,7 +205,7 @@ public override Task String_EndsWith_MethodCall(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ENDSWITH(c["ContactName"], "m")) """); @@ -219,7 +219,7 @@ public override Task String_EndsWith_with_StringComparison_Ordinal(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ENDSWITH(c["ContactName"], "DY", false)) """); @@ -233,7 +233,7 @@ public override Task String_EndsWith_with_StringComparison_OrdinalIgnoreCase(boo AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ENDSWITH(c["ContactName"], "DY", true)) """); @@ -260,7 +260,7 @@ public override Task String_Contains_Literal(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND CONTAINS(c["ContactName"], "M")) """); @@ -273,7 +273,7 @@ public override Task String_Contains_Identity(bool async) await base.String_Contains_Identity(a); AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND CONTAINS(c["ContactName"], c["ContactName"])) """); @@ -287,7 +287,7 @@ public override Task String_Contains_Column(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND CONTAINS(c["CompanyName"], c["ContactName"])) """); @@ -301,7 +301,7 @@ public override Task String_Contains_with_StringComparison_Ordinal(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND CONTAINS(c["ContactName"], "M", false)) """); @@ -315,7 +315,7 @@ public override Task String_Contains_with_StringComparison_OrdinalIgnoreCase(boo AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND CONTAINS(c["ContactName"], "M", true)) """); @@ -340,7 +340,7 @@ public override Task String_FirstOrDefault_MethodCall(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (LEFT(c["ContactName"], 1) = "A")) """); @@ -354,7 +354,7 @@ public override Task String_LastOrDefault_MethodCall(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (RIGHT(c["ContactName"], 1) = "s")) """); @@ -368,7 +368,7 @@ public override Task String_Contains_MethodCall(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND CONTAINS(c["ContactName"], "M")) """); @@ -478,7 +478,7 @@ public override Task Where_math_abs1(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (ABS(c["ProductID"]) > 10)) """); @@ -492,7 +492,7 @@ public override Task Where_math_abs2(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["UnitPrice"] < 7.0)) AND (ABS(c["Quantity"]) > 10)) """); @@ -506,7 +506,7 @@ public override Task Where_math_abs3(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["Quantity"] < 5)) AND (ABS(c["UnitPrice"]) > 10.0)) """); @@ -520,7 +520,7 @@ public override Task Where_math_abs_uncorrelated(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["UnitPrice"] < 7.0)) AND (10 < c["ProductID"])) """); @@ -542,7 +542,7 @@ public override Task Where_math_ceiling2(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["Quantity"] < 5)) AND (CEILING(c["UnitPrice"]) > 10.0)) """); @@ -556,7 +556,7 @@ public override Task Where_math_floor(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["Quantity"] < 5)) AND (FLOOR(c["UnitPrice"]) > 10.0)) """); @@ -586,7 +586,7 @@ public override Task Where_math_round(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["Quantity"] < 5)) AND (ROUND(c["UnitPrice"]) > 10.0)) """); @@ -612,7 +612,7 @@ public override Task Select_math_round_int(bool async) AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] < 10250)) """); @@ -626,7 +626,7 @@ public override Task Select_math_truncate_int(bool async) AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] < 10250)) """); @@ -648,7 +648,7 @@ public override Task Where_math_truncate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["Quantity"] < 5)) AND (TRUNC(c["UnitPrice"]) > 10.0)) """); @@ -758,7 +758,7 @@ public override Task Where_math_sign(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (SIGN(c["Discount"]) > 0)) """); @@ -844,7 +844,7 @@ public override Task Where_mathf_ceiling1(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["UnitPrice"] < 7.0)) AND (CEILING(c["Discount"]) > 0.0)) """); @@ -866,7 +866,7 @@ public override Task Where_mathf_power(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "OrderDetail") AND (POWER(c["Discount"], 3.0) > 0.005)) """); @@ -880,7 +880,7 @@ public override Task Where_mathf_square(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "OrderDetail") AND (POWER(c["Discount"], 2.0) > 0.05)) """); @@ -910,7 +910,7 @@ public override Task Where_mathf_exp(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (EXP(c["Discount"]) > 1.0)) """); @@ -924,7 +924,7 @@ public override Task Where_mathf_log10(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND ((c["OrderID"] = 11077) AND (c["Discount"] > 0.0))) AND (LOG10(c["Discount"]) < 0.0)) """); @@ -938,7 +938,7 @@ public override Task Where_mathf_log(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND ((c["OrderID"] = 11077) AND (c["Discount"] > 0.0))) AND (LOG(c["Discount"]) < 0.0)) """); @@ -952,7 +952,7 @@ public override Task Where_mathf_log_new_base(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND ((c["OrderID"] = 11077) AND (c["Discount"] > 0.0))) AND (LOG(c["Discount"], 7.0) < -1.0)) """); @@ -966,7 +966,7 @@ public override Task Where_mathf_sqrt(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (SQRT(c["Discount"]) > 0.0)) """); @@ -980,7 +980,7 @@ public override Task Where_mathf_acos(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (ACOS(c["Discount"]) > 1.0)) """); @@ -994,7 +994,7 @@ public override Task Where_mathf_asin(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (ASIN(c["Discount"]) > 0.0)) """); @@ -1008,7 +1008,7 @@ public override Task Where_mathf_atan(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (ATAN(c["Discount"]) > 0.0)) """); @@ -1022,7 +1022,7 @@ public override Task Where_mathf_atan2(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (ATN2(c["Discount"], 1.0) > 0.0)) """); @@ -1036,7 +1036,7 @@ public override Task Where_mathf_cos(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (COS(c["Discount"]) > 0.0)) """); @@ -1050,7 +1050,7 @@ public override Task Where_mathf_sin(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (SIN(c["Discount"]) > 0.0)) """); @@ -1064,7 +1064,7 @@ public override Task Where_mathf_tan(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (TAN(c["Discount"]) > 0.0)) """); @@ -1078,7 +1078,7 @@ public override Task Where_mathf_sign(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (SIGN(c["Discount"]) > 0)) """); @@ -1092,7 +1092,7 @@ public override Task Where_mathf_degrees(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (DEGREES(c["Discount"]) > 0.0)) """); @@ -1106,7 +1106,7 @@ public override Task Where_mathf_radians(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (RADIANS(c["Discount"]) > 0.0)) """); @@ -1128,7 +1128,7 @@ public override Task Where_string_to_upper(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (UPPER(c["CustomerID"]) = "ALFKI")) """); @@ -1142,7 +1142,7 @@ public override Task Where_string_to_lower(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (LOWER(c["CustomerID"]) = "alfki")) """); @@ -1228,7 +1228,7 @@ public override Task Indexof_with_emptystring(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (INDEX_OF(c["Region"], "") = 0)) """); @@ -1242,7 +1242,7 @@ public override Task Indexof_with_one_constant_arg(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (INDEX_OF(c["ContactName"], "a") = 1)) """); @@ -1258,7 +1258,7 @@ public override Task Indexof_with_one_parameter_arg(bool async) """ @__pattern_0='a' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (INDEX_OF(c["ContactName"], @__pattern_0) = 1)) """); @@ -1272,7 +1272,7 @@ public override Task Indexof_with_constant_starting_position(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (INDEX_OF(c["ContactName"], "a", 2) = 4)) """); @@ -1288,7 +1288,7 @@ public override Task Indexof_with_parameter_starting_position(bool async) """ @__start_0='2' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (INDEX_OF(c["ContactName"], "a", @__start_0) = 4)) """); @@ -1302,7 +1302,7 @@ public override Task Replace_with_emptystring(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (REPLACE(c["ContactName"], "ia", "") = "Mar Anders")) """); @@ -1316,7 +1316,7 @@ public override Task Replace_using_property_arguments(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (REPLACE(c["ContactName"], c["ContactName"], c["CustomerID"]) = c["CustomerID"])) """); @@ -1330,7 +1330,7 @@ public override Task Substring_with_one_arg_with_zero_startindex(bool async) AssertSql( """ -SELECT c["ContactName"] +SELECT VALUE c["ContactName"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (SUBSTRING(c["CustomerID"], 0, LENGTH(c["CustomerID"])) = "ALFKI")) """); @@ -1344,7 +1344,7 @@ public override Task Substring_with_one_arg_with_constant(bool async) AssertSql( """ -SELECT c["ContactName"] +SELECT VALUE c["ContactName"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (SUBSTRING(c["CustomerID"], 1, LENGTH(c["CustomerID"])) = "LFKI")) """); @@ -1360,7 +1360,7 @@ public override Task Substring_with_one_arg_with_closure(bool async) """ @__start_0='2' -SELECT c["ContactName"] +SELECT VALUE c["ContactName"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (SUBSTRING(c["CustomerID"], @__start_0, LENGTH(c["CustomerID"])) = "FKI")) """); @@ -1374,7 +1374,7 @@ public override Task Substring_with_two_args_with_zero_startindex(bool async) AssertSql( """ -SELECT LEFT(c["ContactName"], 3) AS c +SELECT VALUE LEFT(c["ContactName"], 3) FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -1388,7 +1388,7 @@ public override Task Substring_with_two_args_with_zero_length(bool async) AssertSql( """ -SELECT SUBSTRING(c["ContactName"], 2, 0) AS c +SELECT VALUE SUBSTRING(c["ContactName"], 2, 0) FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -1402,7 +1402,7 @@ public override Task Substring_with_two_args_with_constant(bool async) AssertSql( """ -SELECT SUBSTRING(c["ContactName"], 1, 3) AS c +SELECT VALUE SUBSTRING(c["ContactName"], 1, 3) FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -1418,7 +1418,7 @@ public override Task Substring_with_two_args_with_closure(bool async) """ @__start_0='2' -SELECT SUBSTRING(c["ContactName"], @__start_0, 3) AS c +SELECT VALUE SUBSTRING(c["ContactName"], @__start_0, 3) FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -1432,7 +1432,7 @@ public override Task Substring_with_two_args_with_Index_of(bool async) AssertSql( """ -SELECT SUBSTRING(c["ContactName"], INDEX_OF(c["ContactName"], "a"), 3) AS c +SELECT VALUE SUBSTRING(c["ContactName"], INDEX_OF(c["ContactName"], "a"), 3) FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -1506,7 +1506,7 @@ public override Task TrimStart_without_arguments_in_predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (LTRIM(c["ContactTitle"]) = "Owner")) """); @@ -1536,7 +1536,7 @@ public override Task TrimEnd_without_arguments_in_predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (RTRIM(c["ContactTitle"]) = "Owner")) """); @@ -1566,7 +1566,7 @@ public override Task Trim_without_argument_in_predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (TRIM(c["ContactTitle"]) = "Owner")) """); @@ -1598,7 +1598,7 @@ public override async Task Order_by_length_twice(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY LENGTH(c["CustomerID"]), c["CustomerID"] @@ -1634,7 +1634,7 @@ public override Task Static_equals_nullable_datetime_compared_to_non_nullable(bo """ @__arg_0='1996-07-04T00:00:00' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] = @__arg_0)) """); @@ -1648,7 +1648,7 @@ public override Task Static_equals_int_compared_to_long(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -1710,7 +1710,7 @@ public override Task Regex_IsMatch_MethodCall(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND RegexMatch(c["CustomerID"], "^T")) """); @@ -1724,7 +1724,7 @@ public override Task Regex_IsMatch_MethodCall_constant_input(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND RegexMatch("ALFKI", c["CustomerID"])) """); @@ -1742,7 +1742,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND RegexMatch(c["CustomerID"], "^T")) """); @@ -1760,7 +1760,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND RegexMatch(c["CustomerID"], "^T", "i")) """); @@ -1778,7 +1778,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND RegexMatch(c["CustomerID"], "^T", "m")) """); @@ -1796,7 +1796,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND RegexMatch(c["CustomerID"], "^T", "s")) """); @@ -1814,7 +1814,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND RegexMatch(c["CustomerID"], "^T", "x")) """); @@ -1833,7 +1833,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND RegexMatch(c["CustomerID"], "^T", "ix")) """); @@ -1868,7 +1868,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STRINGEQUALS(c["CustomerID"], "alFkI", true)) """); @@ -1886,7 +1886,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STRINGEQUALS(c["CustomerID"], "alFkI", true)) """); @@ -1904,7 +1904,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STRINGEQUALS(c["CustomerID"], "ALFKI")) """); @@ -1922,7 +1922,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STRINGEQUALS(c["CustomerID"], "ALFKI")) """); @@ -1944,7 +1944,7 @@ public override Task String_Contains_constant_with_whitespace(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND CONTAINS(c["ContactName"], " ")) """); @@ -1960,7 +1960,7 @@ public override Task String_Contains_parameter_with_whitespace(bool async) """ @__pattern_0=' ' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND CONTAINS(c["ContactName"], @__pattern_0)) """); @@ -1974,7 +1974,7 @@ public override Task Select_mathf_round(bool async) AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] < 10250)) """); @@ -1988,7 +1988,7 @@ public override Task Select_mathf_round2(bool async) AssertSql( """ -SELECT c["UnitPrice"] +SELECT VALUE c["UnitPrice"] FROM root c WHERE ((c["Discriminator"] = "OrderDetail") AND (c["Quantity"] < 5)) """); @@ -2002,7 +2002,7 @@ public override Task Select_mathf_truncate(bool async) AssertSql( """ -SELECT c["UnitPrice"] +SELECT VALUE c["UnitPrice"] FROM root c WHERE ((c["Discriminator"] = "OrderDetail") AND (c["Quantity"] < 5)) """); @@ -2016,7 +2016,7 @@ public override Task String_Contains_negated_in_predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND NOT(CONTAINS(c["CompanyName"], c["ContactName"]))) """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs index e1266a09bf3..0a602698988 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindKeylessEntitiesQueryCosmosTest.cs @@ -31,7 +31,7 @@ public override Task KeylessEntity_simple(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -45,7 +45,7 @@ public override Task KeylessEntity_where_simple(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) """); @@ -62,7 +62,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "ProductView") """); @@ -87,7 +87,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["OrderCount"] > 0)) """); @@ -118,7 +118,7 @@ public override Task KeylessEntity_with_defining_query(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) """); @@ -180,7 +180,7 @@ public override Task Auto_initialized_view_set(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -194,7 +194,7 @@ public override Task Count_over_keyless_entity(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE (c["Discriminator"] = "Customer") """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs index bb174e94fb5..dcd18a3c5ca 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindMiscellaneousQueryCosmosTest.cs @@ -39,7 +39,7 @@ public virtual Task Simple_IQueryable(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -53,13 +53,13 @@ public override Task Shaper_command_caching_when_parameter_names_different(bool AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """, // """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -98,7 +98,7 @@ public override Task Entity_equality_self(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = c["CustomerID"])) """); @@ -114,7 +114,7 @@ public override Task Entity_equality_local(bool async) """ @__entity_equality_local_0_CustomerID='ANATR' -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = @__entity_equality_local_0_CustomerID)) """); @@ -145,7 +145,7 @@ public override Task Entity_equality_local_inline(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ANATR")) """); @@ -168,7 +168,7 @@ public override Task Entity_equality_null(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = null)) """); @@ -182,7 +182,7 @@ public override Task Entity_equality_not_null(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] != null)) """); @@ -476,7 +476,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Employee") ORDER BY (c["EmployeeID"] - c["EmployeeID"]) @@ -495,7 +495,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Product") ORDER BY (c["UnitsInStock"] > 0), c["ProductID"] @@ -514,7 +514,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Product") ORDER BY ((c["UnitsInStock"] > 10) ? (c["ProductID"] > 40) : (c["ProductID"] <= 40)), c["ProductID"] @@ -561,7 +561,7 @@ public override Task Skip_Take(bool async) @__p_0='5' @__p_1='10' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["ContactName"] @@ -652,7 +652,7 @@ public override Task Queryable_simple(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -666,7 +666,7 @@ public override Task Queryable_simple_anonymous(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -680,7 +680,7 @@ public override Task Queryable_nested_simple(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -696,7 +696,7 @@ public override Task Queryable_simple_anonymous_projection_subquery(bool async) """ @__p_0='91' -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") OFFSET 0 LIMIT @__p_0 @@ -713,7 +713,7 @@ public override Task Queryable_simple_anonymous_subquery(bool async) """ @__p_0='91' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") OFFSET 0 LIMIT @__p_0 @@ -730,7 +730,7 @@ public override Task Take_simple(bool async) """ @__p_0='10' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -748,7 +748,7 @@ public override Task Take_simple_parameterized(bool async) """ @__p_0='10' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -766,7 +766,7 @@ public override Task Take_simple_projection(bool async) """ @__p_0='10' -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -784,7 +784,7 @@ public override Task Take_subquery_projection(bool async) """ @__p_0='2' -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -821,10 +821,10 @@ public override async Task Any_simple(bool async) AssertSql( """ -SELECT EXISTS ( +SELECT VALUE EXISTS ( SELECT 1 FROM root c - WHERE (c["Discriminator"] = "Customer")) AS c + WHERE (c["Discriminator"] = "Customer")) """); } } @@ -841,10 +841,10 @@ public override async Task Any_predicate(bool async) AssertSql( """ -SELECT EXISTS ( +SELECT VALUE EXISTS ( SELECT 1 FROM root c - WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["ContactName"], "A"))) AS c + WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["ContactName"], "A"))) """); } } @@ -1290,7 +1290,7 @@ public override Task Skip_Take_Distinct(bool async) @__p_0='5' @__p_1='10' -SELECT DISTINCT c +SELECT DISTINCT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["ContactName"] @@ -1313,12 +1313,12 @@ public override async Task Skip_Take_Any(bool async) @__p_0='5' @__p_1='10' -SELECT EXISTS ( +SELECT VALUE EXISTS ( SELECT 1 FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["ContactName"] - OFFSET @__p_0 LIMIT @__p_1) AS c + OFFSET @__p_0 LIMIT @__p_1) """); } } @@ -1354,12 +1354,12 @@ public override async Task Skip_Take_Any_with_predicate(bool async) @__p_0='5' @__p_1='7' -SELECT EXISTS ( +SELECT VALUE EXISTS ( SELECT 1 FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "C")) ORDER BY c["CustomerID"] - OFFSET @__p_0 LIMIT @__p_1) AS c + OFFSET @__p_0 LIMIT @__p_1) """); } } @@ -1378,12 +1378,12 @@ public override async Task Take_Any_with_predicate(bool async) """ @__p_0='5' -SELECT EXISTS ( +SELECT VALUE EXISTS ( SELECT 1 FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "B")) ORDER BY c["CustomerID"] - OFFSET 0 LIMIT @__p_0) AS c + OFFSET 0 LIMIT @__p_0) """); } } @@ -1396,7 +1396,7 @@ public override Task OrderBy(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -1414,7 +1414,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY true @@ -1433,7 +1433,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY 3 @@ -1454,7 +1454,7 @@ await Assert.ThrowsAsync( """ @__param_0='5' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY @__param_0 @@ -1470,7 +1470,7 @@ public override Task OrderBy_anon(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -1485,7 +1485,7 @@ public override Task OrderBy_anon2(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -1516,7 +1516,7 @@ public override Task Take_Distinct(bool async) """ @__p_0='5' -SELECT DISTINCT c +SELECT DISTINCT VALUE c FROM root c WHERE (c["Discriminator"] = "Order") ORDER BY c["OrderID"] @@ -1553,7 +1553,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Employee") ORDER BY c["Title"], c["EmployeeID"] @@ -1572,7 +1572,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A")) ORDER BY c["Country"], c["City"] @@ -1592,10 +1592,10 @@ public override async Task OrderBy_ThenBy_Any(bool async) AssertSql( """ -SELECT EXISTS ( +SELECT VALUE EXISTS ( SELECT 1 FROM root c - WHERE (c["Discriminator"] = "Customer")) AS c + WHERE (c["Discriminator"] = "Customer")) """); } } @@ -1694,7 +1694,7 @@ public override Task Select_DTO_constructor_distinct_translated_to_server(bool a AssertSql( """ -SELECT DISTINCT c["CustomerID"] +SELECT DISTINCT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] < 10300)) """); @@ -1810,7 +1810,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY ((c["Region"] != null) ? c["Region"] : "ZZ"), c["CustomerID"] @@ -1853,7 +1853,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY ((c["Region"] = null) ? "ZZ" : c["Region"]), c["CustomerID"] @@ -1869,7 +1869,7 @@ public override Task OrderBy_conditional_operator_where_condition_false(bool asy AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["City"] @@ -1887,7 +1887,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY (c["Region"] = "ASK") @@ -1922,7 +1922,7 @@ public override Task Filter_coalesce_operator(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["ContactName"] != null) ? c["ContactName"] : c["CompanyName"]) = "Liz Nixon")) """); @@ -2002,7 +2002,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY ((c["Region"] != null) ? c["Region"] : "ZZ") @@ -2018,7 +2018,7 @@ public override Task DateTime_parse_is_inlined(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] > "1998-01-01T12:00:00")) """); @@ -2034,7 +2034,7 @@ public override Task DateTime_parse_is_parameterized_when_from_closure(bool asyn """ @__Parse_0='1998-01-01T12:00:00' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] > @__Parse_0)) """); @@ -2048,7 +2048,7 @@ public override Task New_DateTime_is_inlined(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] > "1998-01-01T12:00:00")) """); @@ -2064,7 +2064,7 @@ public override Task New_DateTime_is_parameterized_when_from_closure(bool async) """ @__p_0='1998-01-01T12:00:00' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] > @__p_0)) """, @@ -2072,7 +2072,7 @@ FROM root c """ @__p_0='1998-01-01T11:00:00' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] > @__p_0)) """); @@ -2138,7 +2138,7 @@ public override Task Environment_newline_is_funcletized(bool async) """ ' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND CONTAINS(c["CustomerID"], @__NewLine_0)) """, @@ -2259,7 +2259,7 @@ public override async Task Where_bitwise_or_with_logical_or(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["CustomerID"] = "ALFKI") | (c["CustomerID"] = "ANATR")) OR (c["CustomerID"] = "ANTON"))) """); @@ -2274,7 +2274,7 @@ public override Task Where_bitwise_and_with_logical_and(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["CustomerID"] = "ALFKI") & (c["CustomerID"] = "ANATR")) AND (c["CustomerID"] = "ANTON"))) """); @@ -2290,7 +2290,7 @@ public override async Task Where_bitwise_or_with_logical_and(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["CustomerID"] = "ALFKI") | (c["CustomerID"] = "ANATR")) AND (c["Country"] = "Germany"))) """); @@ -2305,7 +2305,7 @@ public override Task Where_bitwise_and_with_logical_or(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["CustomerID"] = "ALFKI") & (c["CustomerID"] = "ANATR")) OR (c["CustomerID"] = "ANTON"))) """); @@ -2321,7 +2321,7 @@ public override Task Where_bitwise_binary_not(bool async) """ @__negatedId_0='-10249' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (~(c["OrderID"]) = @__negatedId_0)) """); @@ -2335,7 +2335,7 @@ public override Task Where_bitwise_binary_and(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] & 10248) = 10248)) """); @@ -2349,7 +2349,7 @@ public override Task Where_bitwise_binary_or(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] | 10248) = 10248)) """); @@ -2363,7 +2363,7 @@ public override Task Where_bitwise_binary_xor(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] ^ 1) = 10249)) """); @@ -2433,13 +2433,13 @@ public override Task Parameter_extraction_short_circuits_1(bool async) @__dateFilter_Value_Month_0='7' @__dateFilter_Value_Year_1='1996' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] < 10400) AND (((c["OrderDate"] != null) AND (DateTimePart("mm", c["OrderDate"]) = @__dateFilter_Value_Month_0)) AND (DateTimePart("yyyy", c["OrderDate"]) = @__dateFilter_Value_Year_1)))) """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] < 10400)) """); @@ -2457,13 +2457,13 @@ public override Task Parameter_extraction_short_circuits_2(bool async) @__dateFilter_Value_Month_0='7' @__dateFilter_Value_Year_1='1996' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] < 10400) AND (((c["OrderDate"] != null) AND (DateTimePart("mm", c["OrderDate"]) = @__dateFilter_Value_Month_0)) AND (DateTimePart("yyyy", c["OrderDate"]) = @__dateFilter_Value_Year_1)))) """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -2481,13 +2481,13 @@ public override Task Parameter_extraction_short_circuits_3(bool async) @__dateFilter_Value_Month_0='7' @__dateFilter_Value_Year_1='1996' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] < 10400) OR (((c["OrderDate"] != null) AND (DateTimePart("mm", c["OrderDate"]) = @__dateFilter_Value_Month_0)) AND (DateTimePart("yyyy", c["OrderDate"]) = @__dateFilter_Value_Year_1)))) """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -2517,7 +2517,7 @@ public override Task Select_expression_long_to_string(bool async) AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2531,7 +2531,7 @@ public override Task Select_expression_int_to_string(bool async) AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2545,13 +2545,13 @@ public override Task ToString_with_formatter_is_evaluated_on_the_client(bool asy AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """, // """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2565,7 +2565,7 @@ public override Task Select_expression_other_to_string(bool async) AssertSql( """ -SELECT c["OrderDate"] +SELECT VALUE c["OrderDate"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2579,7 +2579,7 @@ public override Task Select_expression_date_add_year(bool async) AssertSql( """ -SELECT DateTimeAdd("yyyy", 1, c["OrderDate"]) AS c +SELECT VALUE DateTimeAdd("yyyy", 1, c["OrderDate"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2593,7 +2593,7 @@ public override Task Select_expression_datetime_add_month(bool async) AssertSql( """ -SELECT DateTimeAdd("mm", 1, c["OrderDate"]) AS c +SELECT VALUE DateTimeAdd("mm", 1, c["OrderDate"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2607,7 +2607,7 @@ public override Task Select_expression_datetime_add_hour(bool async) AssertSql( """ -SELECT DateTimeAdd("hh", 1.0, c["OrderDate"]) AS c +SELECT VALUE DateTimeAdd("hh", 1.0, c["OrderDate"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2621,7 +2621,7 @@ public override Task Select_expression_datetime_add_minute(bool async) AssertSql( """ -SELECT DateTimeAdd("mi", 1.0, c["OrderDate"]) AS c +SELECT VALUE DateTimeAdd("mi", 1.0, c["OrderDate"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2635,7 +2635,7 @@ public override Task Select_expression_datetime_add_second(bool async) AssertSql( """ -SELECT DateTimeAdd("ss", 1.0, c["OrderDate"]) AS c +SELECT VALUE DateTimeAdd("ss", 1.0, c["OrderDate"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2649,7 +2649,7 @@ public override Task Select_expression_date_add_milliseconds_above_the_range(boo AssertSql( """ -SELECT DateTimeAdd("ms", 1000000000000.0, c["OrderDate"]) AS c +SELECT VALUE DateTimeAdd("ms", 1000000000000.0, c["OrderDate"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2663,7 +2663,7 @@ public override Task Select_expression_date_add_milliseconds_below_the_range(boo AssertSql( """ -SELECT DateTimeAdd("ms", -1000000000000.0, c["OrderDate"]) AS c +SELECT VALUE DateTimeAdd("ms", -1000000000000.0, c["OrderDate"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -2691,7 +2691,7 @@ public override Task Add_minutes_on_constant_value(bool async) AssertSql( """ -SELECT (c["OrderID"] % 25) AS c +SELECT VALUE (c["OrderID"] % 25) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] < 10500)) ORDER BY c["OrderID"] @@ -2708,7 +2708,7 @@ public override Task Select_expression_references_are_updated_correctly_with_sub """ @__nextYear_0='2017' -SELECT DISTINCT DateTimePart("yyyy", c["OrderDate"]) AS c +SELECT DISTINCT VALUE DateTimePart("yyyy", c["OrderDate"]) FROM root c WHERE (((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) AND (DateTimePart("yyyy", c["OrderDate"]) < @__nextYear_0)) """); @@ -2768,7 +2768,7 @@ await Assert.ThrowsAsync( @__p_0='5' @__p_1='8' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["ContactTitle"], c["ContactName"] @@ -2827,7 +2827,7 @@ await Assert.ThrowsAsync( @__p_0='5' @__p_1='15' -SELECT DISTINCT c +SELECT DISTINCT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["ContactTitle"], c["ContactName"] @@ -2849,7 +2849,7 @@ await Assert.ThrowsAsync( """ @__p_0='15' -SELECT DISTINCT c +SELECT DISTINCT VALUE c FROM root c WHERE (c["Discriminator"] = "Product") ORDER BY ((c["UnitPrice"] != null) ? c["UnitPrice"] : 0.0) @@ -2872,7 +2872,7 @@ await Assert.ThrowsAsync( @__p_0='5' @__p_1='15' -SELECT DISTINCT c +SELECT DISTINCT VALUE c FROM root c WHERE (c["Discriminator"] = "Product") ORDER BY ((c["UnitPrice"] != null) ? c["UnitPrice"] : 0.0) @@ -2977,7 +2977,7 @@ public override Task Anonymous_member_distinct_where(bool async) AssertSql( """ -SELECT DISTINCT c["CustomerID"] +SELECT DISTINCT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -3009,7 +3009,7 @@ public override Task Anonymous_complex_distinct_where(bool async) AssertSql( """ -SELECT DISTINCT (c["CustomerID"] || c["City"]) AS A +SELECT DISTINCT VALUE (c["CustomerID"] || c["City"]) FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] || c["City"]) = "ALFKIBerlin")) """); @@ -3043,7 +3043,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT (c["CustomerID"] || c["City"]) AS A +SELECT VALUE (c["CustomerID"] || c["City"]) FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY (c["CustomerID"] || c["City"]) @@ -3067,7 +3067,7 @@ public override Task DTO_member_distinct_where(bool async) AssertSql( """ -SELECT DISTINCT c["CustomerID"] AS Property +SELECT DISTINCT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -3099,7 +3099,7 @@ public override Task DTO_complex_distinct_where(bool async) AssertSql( """ -SELECT DISTINCT (c["CustomerID"] || c["City"]) AS Property +SELECT DISTINCT VALUE (c["CustomerID"] || c["City"]) FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] || c["City"]) = "ALFKIBerlin")) """); @@ -3134,7 +3134,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT (c["CustomerID"] || c["City"]) AS Property +SELECT VALUE (c["CustomerID"] || c["City"]) FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY (c["CustomerID"] || c["City"]) @@ -3374,7 +3374,7 @@ public override Task Comparing_to_fixed_string_parameter(bool async) """ @__prefix_0='A' -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], @__prefix_0)) """); @@ -3404,7 +3404,7 @@ public override Task Comparing_entity_to_null_using_Equals(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE (((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A")) AND NOT((c["CustomerID"] = null))) ORDER BY c["CustomerID"] @@ -3451,7 +3451,7 @@ public override Task Comparing_collection_navigation_to_null(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = null)) """); @@ -3473,7 +3473,7 @@ public override Task Compare_collection_navigation_with_itself(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE (((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A")) AND (c["CustomerID"] = c["CustomerID"])) """); @@ -3511,7 +3511,7 @@ public override Task OrderBy_ThenBy_same_column_different_direction(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A")) ORDER BY c["CustomerID"] @@ -3526,7 +3526,7 @@ public override Task OrderBy_OrderBy_same_column_different_direction(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A")) ORDER BY c["CustomerID"] DESC @@ -3562,7 +3562,7 @@ public override Task OrderBy_Dto_projection_skip_take(bool async) @__p_0='5' @__p_1='10' -SELECT c["CustomerID"] AS Id +SELECT VALUE c["CustomerID"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -3590,7 +3590,7 @@ await Assert.ThrowsAsync( """ @__list_0='[]' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY ARRAY_CONTAINS(@__list_0, c["CustomerID"]) @@ -3610,7 +3610,7 @@ await Assert.ThrowsAsync( """ @__list_0='[]' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY NOT(ARRAY_CONTAINS(@__list_0, c["CustomerID"])) @@ -3712,13 +3712,13 @@ public override Task Can_convert_manually_build_expression_with_default(bool asy AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] != null)) """, // """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] != null)) """); @@ -3735,7 +3735,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "OrderDetail") ORDER BY c["OrderID"] DESC, c["ProductID"] DESC @@ -3778,7 +3778,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] DESC, c["Country"] @@ -3797,7 +3797,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] DESC, c["Country"] DESC @@ -3824,7 +3824,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"], c["Country"] @@ -3843,7 +3843,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) ORDER BY c["City"], c["CustomerID"] @@ -3924,7 +3924,7 @@ public override Task Select_Property_when_shadow_unconstrained_generic_method(bo AssertSql( """ -SELECT c["Title"] +SELECT VALUE c["Title"] FROM root c WHERE (c["Discriminator"] = "Employee") """); @@ -3950,7 +3950,7 @@ public override Task Where_Property_when_shadow_unconstrained_generic_method(boo """ @__value_0='Sales Representative' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["Title"] = @__value_0)) """); @@ -4154,7 +4154,7 @@ public override Task Checked_context_with_arithmetic_does_not_fail(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "OrderDetail") AND ((((c["Quantity"] + 1) = 5) AND ((c["Quantity"] - 1) = 3)) AND ((c["Quantity"] * 1) = c["Quantity"]))) ORDER BY c["OrderID"] @@ -4169,7 +4169,7 @@ public override Task Checked_context_with_case_to_same_nullable_type_does_not_fa AssertSql( """ -SELECT MAX(c["Quantity"]) AS c +SELECT VALUE MAX(c["Quantity"]) FROM root c WHERE (c["Discriminator"] = "OrderDetail") """); @@ -4192,7 +4192,7 @@ public override Task Entity_equality_contains_with_list_of_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND c["CustomerID"] IN (null, "ALFKI")) """); @@ -4395,7 +4395,7 @@ public override Task AsEnumerable_over_string(bool async) AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -4410,7 +4410,7 @@ public override Task Select_Property_when_non_shadow(bool async) AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -4424,7 +4424,7 @@ public override Task Cast_results_to_object(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -4438,7 +4438,7 @@ public override Task Null_Coalesce_Short_Circuit_with_server_correlated_leftover AssertSql( """ -SELECT false AS Result +SELECT VALUE false FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -4466,7 +4466,7 @@ public override Task Select_expression_datetime_add_ticks(bool async) AssertSql( """ -SELECT c["OrderDate"] +SELECT VALUE c["OrderDate"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderDate"] != null)) """); @@ -4481,7 +4481,7 @@ public override async Task Throws_on_concurrent_query_first(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -4496,7 +4496,7 @@ public override Task Entity_equality_through_include(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = null)) """); @@ -4510,7 +4510,7 @@ public override Task Concat_constant_string_int(bool async) AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -4524,7 +4524,7 @@ public override Task OrderBy_scalar_primitive(bool async) AssertSql( """ -SELECT c["EmployeeID"] +SELECT VALUE c["EmployeeID"] FROM root c WHERE (c["Discriminator"] = "Employee") ORDER BY c["EmployeeID"] @@ -4548,7 +4548,7 @@ public override Task OrderBy_Select(bool async) AssertSql( """ -SELECT c["ContactName"] +SELECT VALUE c["ContactName"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -4574,11 +4574,14 @@ public override async Task Non_nullable_property_through_optional_navigation(boo // Always throws for sync. if (async) { - await base.Non_nullable_property_through_optional_navigation(async); + await AssertQuery( + async, + ss => ss.Set().Select(e => new { e.Region.Length }), + ss => ss.Set().Where(e => e.Region != null).Select(e => new { e.Region.Length })); AssertSql( """ -SELECT LENGTH(c["Region"]) AS Length +SELECT VALUE LENGTH(c["Region"]) FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -4593,7 +4596,7 @@ public override Task ToList_over_string(bool async) AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -4608,7 +4611,7 @@ public override Task Entity_equality_not_null_composite_key(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "OrderDetail") AND ((c["OrderID"] != null) AND (c["ProductID"] != null))) """); @@ -4629,7 +4632,7 @@ public override Task ToListAsync_with_canceled_token() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Employee") """); @@ -4661,7 +4664,7 @@ public override Task Entity_equality_orderby(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -4676,7 +4679,7 @@ public override Task Load_should_track_results(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -4701,7 +4704,7 @@ public override Task Where_Property_shadow_closure(bool async) """ @__value_0='Sales Representative' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["Title"] = @__value_0)) """, @@ -4709,7 +4712,7 @@ FROM root c """ @__value_0='Steven' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["FirstName"] = @__value_0)) """); @@ -4725,7 +4728,7 @@ public override Task Entity_equality_local_double_check(bool async) """ @__entity_equality_local_0_CustomerID='ANATR' -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] = @__entity_equality_local_0_CustomerID) AND (@__entity_equality_local_0_CustomerID = c["CustomerID"]))) """); @@ -4739,7 +4742,7 @@ public override Task ToArray_over_string(bool async) AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -4754,7 +4757,7 @@ public override Task MemberInitExpression_NewExpression_is_funcletized_even_when AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A")) """); @@ -4768,7 +4771,7 @@ public override Task Entity_equality_null_composite_key(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "OrderDetail") AND ((c["OrderID"] = null) OR (c["ProductID"] = null))) """); @@ -4782,7 +4785,7 @@ public override Task Concat_parameter_string_int(bool async) AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -4801,7 +4804,7 @@ public override Task Where_Property_when_shadow(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["Title"] = "Sales Representative")) """); @@ -4816,7 +4819,7 @@ public override async Task Throws_on_concurrent_query_list(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -4831,7 +4834,7 @@ public override Task Convert_to_nullable_on_nullable_value_is_ignored(bool async AssertSql( """ -SELECT c["OrderDate"] +SELECT VALUE c["OrderDate"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -4845,7 +4848,7 @@ public override Task Ternary_should_not_evaluate_both_sides_with_parameter(bool AssertSql( """ -SELECT true AS Data1 +SELECT VALUE true FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -4859,13 +4862,13 @@ public override Task Context_based_client_method(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -4879,7 +4882,7 @@ public override Task OrderByDescending(bool async) AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] DESC @@ -4894,7 +4897,7 @@ public override Task Select_Property_when_shadow(bool async) AssertSql( """ -SELECT c["Title"] +SELECT VALUE c["Title"] FROM root c WHERE (c["Discriminator"] = "Employee") """); @@ -4910,7 +4913,7 @@ public override Task Skip_0_Take_0_works_when_parameter(bool async) """ @__p_0='0' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -4920,7 +4923,7 @@ OFFSET @__p_0 LIMIT @__p_0 """ @__p_0='1' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -5183,7 +5186,7 @@ public override Task Contains_over_concatenated_columns_with_different_sizes(boo """ @__data_0='["ALFKIAlfreds Futterkiste","ANATRAna Trujillo Emparedados y helados"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__data_0, (c["CustomerID"] || c["CompanyName"]))) """); @@ -5199,7 +5202,7 @@ public override Task Contains_over_concatenated_column_and_constant(bool async) """ @__data_0='["ALFKISomeConstant","ANATRSomeConstant","ALFKIX"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__data_0, (c["CustomerID"] || "SomeConstant"))) """); @@ -5224,7 +5227,7 @@ public override Task Contains_over_concatenated_column_and_parameter(bool async) @__data_1='["ALFKISomeVariable","ANATRSomeVariable","ALFKIX"]' @__someVariable_0='SomeVariable' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__data_1, (c["CustomerID"] || @__someVariable_0))) """); @@ -5240,7 +5243,7 @@ public override Task Contains_over_concatenated_parameter_and_constant(bool asyn """ @__Contains_0='true' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND @__Contains_0) """); @@ -5257,7 +5260,7 @@ public override Task Compiler_generated_local_closure_produces_valid_parameter_n @__customerId_0='ALFKI' @__details_City_1='Berlin' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] = @__customerId_0) AND (c["City"] = @__details_City_1))) """); @@ -5272,6 +5275,8 @@ public override Task Static_member_access_gets_parameterized_within_larger_evalu AssertSql("ReadItem(None, Customer|ALFKI)"); }); + #region ToPageAsync + [ConditionalFact] public virtual async Task ToPageAsync() { @@ -5304,27 +5309,89 @@ public virtual async Task ToPageAsync() AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE (c["Discriminator"] = "Customer") """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] """, // """ -SELECT c +SELECT VALUE c +FROM root c +WHERE (c["Discriminator"] = "Customer") +ORDER BY c["CustomerID"] +"""); + } + + [ConditionalFact] + public virtual async Task ToPageAsync_with_scalar() + { + await using var context = CreateContext(); + + var totalCustomers = await context.Set().CountAsync(); + + var page1 = await context.Set() + .Select(c => c.CustomerID) + .OrderBy(id => id) + .ToPageAsync(pageSize: 1, continuationToken: null); + + var id1 = Assert.Single(page1.Values); + Assert.Equal("ALFKI", id1); + + var page2 = await context.Set() + .Select(c => c.CustomerID) + .OrderBy(id => id) + .ToPageAsync(pageSize: 2, page1.ContinuationToken); + + Assert.Collection( + page2.Values, + id => Assert.Equal("ANATR", id), + id => Assert.Equal("ANTON", id)); + + var page3 = await context.Set() + .Select(c => c.CustomerID) + .OrderBy(id => id) + .ToPageAsync(pageSize: totalCustomers, page2.ContinuationToken); + + Assert.Equal(totalCustomers - 3, page3.Values.Count); + Assert.Null(page3.ContinuationToken); + + AssertSql( + """ +SELECT VALUE COUNT(1) +FROM root c +WHERE (c["Discriminator"] = "Customer") +""", + // + """ +SELECT VALUE c["CustomerID"] +FROM root c +WHERE (c["Discriminator"] = "Customer") +ORDER BY c["CustomerID"] +""", + // + """ +SELECT VALUE c["CustomerID"] +FROM root c +WHERE (c["Discriminator"] = "Customer") +ORDER BY c["CustomerID"] +""", + // + """ +SELECT VALUE c["CustomerID"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -5348,13 +5415,13 @@ public virtual async Task ToPageAsync_with_exact_maxItemCount() AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE (c["Discriminator"] = "Customer") """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -5375,7 +5442,7 @@ public virtual async Task ToPageAsync_does_not_use_ReadItem() AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -5389,6 +5456,8 @@ public virtual async Task ToPageAsync_in_subquery_throws() ss => ss.Set().Where(c => c.Orders.AsQueryable().ToPageAsync(1, null, null, default) == default)), CosmosStrings.ToPageAsyncAtTopLevelOnly); + #endregion ToPageAsync + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs index dff9c2e0838..730c21306e6 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindSelectQueryCosmosTest.cs @@ -4,6 +4,7 @@ using Microsoft.Azure.Cosmos; using Microsoft.EntityFrameworkCore.Cosmos.Internal; using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Xunit.Sdk; namespace Microsoft.EntityFrameworkCore.Query; @@ -31,16 +32,13 @@ public virtual Task Projection_with_Value_Property(bool async) async, async a => { await AssertQuery( - async, + a, ss => ss.Set().Select(o => new { Value = o.OrderID }), e => e.Value); AssertSql( """ -SELECT VALUE -{ - "Value" : c["OrderID"] -} +SELECT VALUE c["OrderID"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -111,7 +109,7 @@ public override Task Projection_when_null_value(bool async) AssertSql( """ -SELECT c["Region"] +SELECT VALUE c["Region"] FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -147,7 +145,7 @@ public override Task Projection_of_entity_type_into_object_array(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A")) ORDER BY c["CustomerID"] @@ -170,7 +168,7 @@ public override Task Projection_of_entity_type_into_object_list(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -185,7 +183,7 @@ public override Task Project_to_int_array(bool async) AssertSql( """ -SELECT [c["EmployeeID"], c["ReportsTo"]] AS c +SELECT VALUE [c["EmployeeID"], c["ReportsTo"]] FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["EmployeeID"] = 1)) """); @@ -211,7 +209,7 @@ await Assert.ThrowsAsync( """ @__boolean_0='false' -SELECT @__boolean_0 AS c +SELECT VALUE @__boolean_0 FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY @__boolean_0 @@ -227,7 +225,7 @@ public override Task Select_scalar(bool async) AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -241,7 +239,7 @@ public override Task Select_anonymous_one(bool async) AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -351,7 +349,7 @@ public override Task Select_constant_int(bool async) AssertSql( """ -SELECT 0 AS c +SELECT VALUE 0 FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -365,7 +363,7 @@ public override Task Select_constant_null_string(bool async) AssertSql( """ -SELECT null AS c +SELECT VALUE null FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -381,7 +379,7 @@ public override Task Select_local(bool async) """ @__x_0='10' -SELECT @__x_0 AS c +SELECT VALUE @__x_0 FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -397,7 +395,7 @@ public override Task Select_scalar_primitive_after_take(bool async) """ @__p_0='9' -SELECT c["EmployeeID"] +SELECT VALUE c["EmployeeID"] FROM root c WHERE (c["Discriminator"] = "Employee") OFFSET 0 LIMIT @__p_0 @@ -412,7 +410,7 @@ public override Task Select_project_filter(bool async) AssertSql( """ -SELECT c["CompanyName"] +SELECT VALUE c["CompanyName"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) """); @@ -426,7 +424,7 @@ public override Task Select_project_filter2(bool async) AssertSql( """ -SELECT c["City"] +SELECT VALUE c["City"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) """); @@ -518,7 +516,7 @@ public override Task Select_non_matching_value_types_int_to_long_introduces_expl AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -533,7 +531,7 @@ public override Task Select_non_matching_value_types_nullable_int_to_long_introd AssertSql( """ -SELECT c["EmployeeID"] +SELECT VALUE c["EmployeeID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -548,7 +546,7 @@ public override Task Select_non_matching_value_types_nullable_int_to_int_doesnt_ AssertSql( """ -SELECT c["EmployeeID"] +SELECT VALUE c["EmployeeID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -563,7 +561,7 @@ public override Task Select_non_matching_value_types_int_to_nullable_int_doesnt_ AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -578,7 +576,7 @@ public override Task Select_non_matching_value_types_from_binary_expression_intr AssertSql( """ -SELECT (c["OrderID"] + c["OrderID"]) AS c +SELECT VALUE (c["OrderID"] + c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -594,7 +592,7 @@ public override Task Select_non_matching_value_types_from_binary_expression_nest AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -609,7 +607,7 @@ public override Task Select_non_matching_value_types_from_unary_expression_intro AssertSql( """ -SELECT -(c["OrderID"]) AS c +SELECT VALUE -(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -624,7 +622,7 @@ public override Task Select_non_matching_value_types_from_unary_expression_intro AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -639,7 +637,7 @@ public override Task Select_non_matching_value_types_from_length_introduces_expl AssertSql( """ -SELECT LENGTH(c["CustomerID"]) AS c +SELECT VALUE LENGTH(c["CustomerID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -654,7 +652,7 @@ public override Task Select_non_matching_value_types_from_method_call_introduces AssertSql( """ -SELECT ABS(c["OrderID"]) AS c +SELECT VALUE ABS(c["OrderID"]) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -669,7 +667,7 @@ public override Task Select_non_matching_value_types_from_anonymous_type_introdu AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) ORDER BY c["OrderID"] @@ -695,7 +693,7 @@ public override Task Select_conditional_with_null_comparison_in_test(bool async) AssertSql( """ -SELECT ((c["CustomerID"] = null) ? true : (c["OrderID"] < 100)) AS c +SELECT VALUE ((c["CustomerID"] = null) ? true : (c["OrderID"] < 100)) FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "ALFKI")) """); @@ -813,7 +811,7 @@ public override Task Select_datetime_year_component(bool async) AssertSql( """ -SELECT DateTimePart("yyyy", c["OrderDate"]) AS c +SELECT VALUE DateTimePart("yyyy", c["OrderDate"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -827,7 +825,7 @@ public override Task Select_datetime_month_component(bool async) AssertSql( """ -SELECT DateTimePart("mm", c["OrderDate"]) AS c +SELECT VALUE DateTimePart("mm", c["OrderDate"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -842,7 +840,7 @@ public override Task Select_datetime_day_of_year_component(bool async) AssertSql( """ -SELECT c["OrderDate"] +SELECT VALUE c["OrderDate"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -856,7 +854,7 @@ public override Task Select_datetime_day_component(bool async) AssertSql( """ -SELECT DateTimePart("dd", c["OrderDate"]) AS c +SELECT VALUE DateTimePart("dd", c["OrderDate"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -870,7 +868,7 @@ public override Task Select_datetime_hour_component(bool async) AssertSql( """ -SELECT DateTimePart("hh", c["OrderDate"]) AS c +SELECT VALUE DateTimePart("hh", c["OrderDate"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -884,7 +882,7 @@ public override Task Select_datetime_minute_component(bool async) AssertSql( """ -SELECT DateTimePart("mi", c["OrderDate"]) AS c +SELECT VALUE DateTimePart("mi", c["OrderDate"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -898,7 +896,7 @@ public override Task Select_datetime_second_component(bool async) AssertSql( """ -SELECT DateTimePart("ss", c["OrderDate"]) AS c +SELECT VALUE DateTimePart("ss", c["OrderDate"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -912,7 +910,7 @@ public override Task Select_datetime_millisecond_component(bool async) AssertSql( """ -SELECT DateTimePart("ms", c["OrderDate"]) AS c +SELECT VALUE DateTimePart("ms", c["OrderDate"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -926,7 +924,7 @@ public override Task Select_byte_constant(bool async) AssertSql( """ -SELECT ((c["CustomerID"] = "ALFKI") ? 1 : 2) AS c +SELECT VALUE ((c["CustomerID"] = "ALFKI") ? 1 : 2) FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -940,7 +938,7 @@ public override Task Select_short_constant(bool async) AssertSql( """ -SELECT ((c["CustomerID"] = "ALFKI") ? 1 : 2) AS c +SELECT VALUE ((c["CustomerID"] = "ALFKI") ? 1 : 2) FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -954,7 +952,7 @@ public override Task Select_bool_constant(bool async) AssertSql( """ -SELECT ((c["CustomerID"] = "ALFKI") ? true : false) AS c +SELECT VALUE ((c["CustomerID"] = "ALFKI") ? true : false) FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -968,7 +966,7 @@ public override Task Anonymous_projection_AsNoTracking_Selector(bool async) AssertSql( """ -SELECT c["OrderDate"] +SELECT VALUE c["OrderDate"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -982,7 +980,7 @@ public override Task Anonymous_projection_with_repeated_property_being_ordered(b AssertSql( """ -SELECT c["CustomerID"] AS A +SELECT VALUE c["CustomerID"] FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -1005,7 +1003,7 @@ public override Task Select_GetValueOrDefault_on_DateTime(bool async) AssertSql( """ -SELECT c["OrderDate"] +SELECT VALUE c["OrderDate"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -1027,7 +1025,7 @@ public override Task Client_method_in_projection_requiring_materialization_1(boo AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A")) """); @@ -1041,7 +1039,7 @@ public override Task Client_method_in_projection_requiring_materialization_2(boo AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A")) """); @@ -1265,7 +1263,7 @@ public override Task Coalesce_over_nullable_uint(bool async) AssertSql( """ -SELECT ((c["EmployeeID"] != null) ? c["EmployeeID"] : 0) AS c +SELECT VALUE ((c["EmployeeID"] != null) ? c["EmployeeID"] : 0) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -1295,7 +1293,7 @@ public override Task Reverse_changes_asc_order_to_desc(bool async) AssertSql( """ -SELECT c["EmployeeID"] +SELECT VALUE c["EmployeeID"] FROM root c WHERE (c["Discriminator"] = "Employee") ORDER BY c["EmployeeID"] DESC @@ -1310,7 +1308,7 @@ public override Task Reverse_changes_desc_order_to_asc(bool async) AssertSql( """ -SELECT c["EmployeeID"] +SELECT VALUE c["EmployeeID"] FROM root c WHERE (c["Discriminator"] = "Employee") ORDER BY c["EmployeeID"] @@ -1333,7 +1331,7 @@ public override Task Projection_custom_type_in_both_sides_of_ternary(bool async) AssertSql( """ -SELECT (c["City"] = "Seattle") AS c +SELECT VALUE (c["City"] = "Seattle") FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -1434,7 +1432,7 @@ public override Task Projection_take_predicate_projection(bool async) """ @__p_0='10' -SELECT ((c["CustomerID"] || " ") || c["City"]) AS Aggregate +SELECT VALUE ((c["CustomerID"] || " ") || c["City"]) FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "A")) ORDER BY c["CustomerID"] @@ -1452,7 +1450,7 @@ public override Task Projection_take_projection_doesnt_project_intermittent_colu """ @__p_0='10' -SELECT ((c["CustomerID"] || " ") || c["City"]) AS Aggregate +SELECT VALUE ((c["CustomerID"] || " ") || c["City"]) FROM root c WHERE (c["Discriminator"] = "Customer") ORDER BY c["CustomerID"] @@ -1703,7 +1701,7 @@ await Assert.ThrowsAsync( AssertSql( """ -SELECT c["EmployeeID"] +SELECT VALUE c["EmployeeID"] FROM root c WHERE (c["Discriminator"] = "Employee") ORDER BY c["EmployeeID"] DESC, c["City"] @@ -1767,7 +1765,7 @@ public override Task Select_datetime_DayOfWeek_component(bool async) AssertSql( """ -SELECT c["OrderDate"] +SELECT VALUE c["OrderDate"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -1781,7 +1779,7 @@ public override Task Reverse_after_multiple_orderbys(bool async) AssertSql( """ -SELECT c["EmployeeID"] +SELECT VALUE c["EmployeeID"] FROM root c WHERE (c["Discriminator"] = "Employee") ORDER BY c["EmployeeID"] @@ -1827,7 +1825,7 @@ public override Task Select_customer_identity(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -1841,7 +1839,7 @@ public override Task Projection_with_parameterized_constructor(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -1869,7 +1867,7 @@ public override Task Cast_on_top_level_projection_brings_explicit_Cast(bool asyn AssertSql( """ -SELECT c["OrderID"] +SELECT VALUE c["OrderID"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -1897,7 +1895,7 @@ public override Task Select_scalar_primitive(bool async) AssertSql( """ -SELECT c["EmployeeID"] +SELECT VALUE c["EmployeeID"] FROM root c WHERE (c["Discriminator"] = "Employee") """); @@ -1911,7 +1909,7 @@ public override Task Select_into(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); @@ -1939,25 +1937,28 @@ public override Task Select_datetime_TimeOfDay_component(bool async) AssertSql( """ -SELECT c["OrderDate"] +SELECT VALUE c["OrderDate"] FROM root c WHERE (c["Discriminator"] = "Order") """); }); - public override Task Select_with_complex_expression_that_can_be_funcletized(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Select_with_complex_expression_that_can_be_funcletized(a); + public override async Task Select_with_complex_expression_that_can_be_funcletized(bool async) + { + // Always throws for sync. + if (async) + { + await Assert.ThrowsAsync( + () => base.Select_with_complex_expression_that_can_be_funcletized(true)); - AssertSql( - """ -SELECT INDEX_OF(c["Region"], "") AS c + AssertSql( + """ +SELECT VALUE INDEX_OF(c["Region"], "") FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = "ALFKI")) """); - }); + } + } public override Task Select_datetime_Ticks_component(bool async) => Fixture.NoSyncTest( @@ -1967,7 +1968,7 @@ public override Task Select_datetime_Ticks_component(bool async) AssertSql( """ -SELECT c["OrderDate"] +SELECT VALUE c["OrderDate"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -1981,7 +1982,7 @@ public override Task Select_anonymous_literal(bool async) AssertSql( """ -SELECT 10 AS X +SELECT VALUE 10 FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -1995,7 +1996,7 @@ public override Task Select_customer_table(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -2009,7 +2010,7 @@ public override Task Select_over_10_nested_ternary_condition(bool async) AssertSql( """ -SELECT ((c["CustomerID"] = "1") ? "01" : ((c["CustomerID"] = "2") ? "02" : ((c["CustomerID"] = "3") ? "03" : ((c["CustomerID"] = "4") ? "04" : ((c["CustomerID"] = "5") ? "05" : ((c["CustomerID"] = "6") ? "06" : ((c["CustomerID"] = "7") ? "07" : ((c["CustomerID"] = "8") ? "08" : ((c["CustomerID"] = "9") ? "09" : ((c["CustomerID"] = "10") ? "10" : ((c["CustomerID"] = "11") ? "11" : null))))))))))) AS c +SELECT VALUE ((c["CustomerID"] = "1") ? "01" : ((c["CustomerID"] = "2") ? "02" : ((c["CustomerID"] = "3") ? "03" : ((c["CustomerID"] = "4") ? "04" : ((c["CustomerID"] = "5") ? "05" : ((c["CustomerID"] = "6") ? "06" : ((c["CustomerID"] = "7") ? "07" : ((c["CustomerID"] = "8") ? "08" : ((c["CustomerID"] = "9") ? "09" : ((c["CustomerID"] = "10") ? "10" : ((c["CustomerID"] = "11") ? "11" : null))))))))))) FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -2023,7 +2024,7 @@ public override Task Select_conditional_drops_false(bool async) AssertSql( """ -SELECT (((c["OrderID"] % 2) = 0) ? c["OrderID"] : -(c["OrderID"])) AS c +SELECT VALUE (((c["OrderID"] % 2) = 0) ? c["OrderID"] : -(c["OrderID"])) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -2037,7 +2038,7 @@ public override Task Select_conditional_terminates_at_true(bool async) AssertSql( """ -SELECT (((c["OrderID"] % 2) = 0) ? c["OrderID"] : 0) AS c +SELECT VALUE (((c["OrderID"] % 2) = 0) ? c["OrderID"] : 0) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -2051,7 +2052,7 @@ public override Task Select_conditional_flatten_nested_results(bool async) AssertSql( """ -SELECT (((c["OrderID"] % 2) = 0) ? (((c["OrderID"] % 5) = 0) ? -(c["OrderID"]) : c["OrderID"]) : c["OrderID"]) AS c +SELECT VALUE (((c["OrderID"] % 2) = 0) ? (((c["OrderID"] % 5) = 0) ? -(c["OrderID"]) : c["OrderID"]) : c["OrderID"]) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -2065,7 +2066,7 @@ public override Task Select_conditional_flatten_nested_tests(bool async) AssertSql( """ -SELECT ((((c["OrderID"] % 2) = 0) ? false : true) ? c["OrderID"] : -(c["OrderID"])) AS c +SELECT VALUE ((((c["OrderID"] % 2) = 0) ? false : true) ? c["OrderID"] : -(c["OrderID"])) FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -2079,7 +2080,7 @@ public override Task Using_enumerable_parameter_in_projection(bool async) AssertSql( """ -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND STARTSWITH(c["CustomerID"], "F")) """); @@ -2105,7 +2106,7 @@ public override Task Entity_passed_to_DTO_constructor_works(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs index 94ae70d42f3..e6d3e7f5bf1 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs @@ -37,7 +37,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] + 10) = 10258)) """); @@ -55,7 +55,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] - 10) = 10238)) """); @@ -73,7 +73,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] * 1) = 10248)) """); @@ -91,7 +91,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] / 1) = 10248)) """); @@ -109,7 +109,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] % 10248) = 0)) """); @@ -128,7 +128,7 @@ await Fixture.NoSyncTest( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] = "ALFKI") | (c["CustomerID"] = "ANATR"))) """); @@ -144,7 +144,7 @@ public override Task Where_bitwise_and(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] = "ALFKI") & (c["CustomerID"] = "ANATR"))) """); @@ -160,7 +160,7 @@ public override Task Where_bitwise_xor(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] = "ALFKI") != true)) """); @@ -178,7 +178,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] << 1) = 20496)) """); @@ -196,7 +196,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ((c["OrderID"] >> 1) = 5124)) """); @@ -214,7 +214,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["City"] = "Seattle") AND (c["ContactTitle"] = "Owner"))) """); @@ -232,7 +232,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] = "ALFKI") OR (c["CustomerID"] = "ANATR"))) """); @@ -250,7 +250,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND NOT((c["City"] != "Seattle"))) """); @@ -268,7 +268,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] = 2)) """); @@ -286,7 +286,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] != 2)) """); @@ -304,7 +304,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] > 2)) """); @@ -322,7 +322,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] >= 2)) """); @@ -340,7 +340,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] < 3)) """); @@ -358,7 +358,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] <= 2)) """); @@ -376,7 +376,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["CustomerID"] || "END") = "ALFKIEND")) """); @@ -394,7 +394,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (-(c["OrderID"]) = -10248)) """); @@ -412,7 +412,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (~(c["OrderID"]) = -10249)) """); @@ -432,7 +432,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["Region"] != null) ? c["Region"] : "SP") = "BC")) """); @@ -450,7 +450,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["Region"] != null) ? c["Region"] : "SP") = "BC")) """); @@ -464,7 +464,7 @@ public override Task Where_simple(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) """); @@ -491,7 +491,7 @@ await Fixture.NoSyncTest( """ @__city_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_0)) """); @@ -510,7 +510,7 @@ public override Task Where_indexer_closure(bool async) """ @__p_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__p_0)) """); @@ -526,7 +526,7 @@ public override Task Where_dictionary_key_access_closure(bool async) """ @__get_Item_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__get_Item_0)) """); @@ -542,7 +542,7 @@ public override Task Where_tuple_item_closure(bool async) """ @__predicateTuple_Item2_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__predicateTuple_Item2_0)) """); @@ -558,7 +558,7 @@ public override Task Where_named_tuple_item_closure(bool async) """ @__predicateTuple_Item2_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__predicateTuple_Item2_0)) """); @@ -574,7 +574,7 @@ public override Task Where_simple_closure_constant(bool async) """ @__predicate_0='true' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND @__predicate_0) """); @@ -590,7 +590,7 @@ public override Task Where_simple_closure_via_query_cache(bool async) """ @__city_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_0)) """, @@ -598,7 +598,7 @@ FROM root c """ @__city_0='Seattle' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_0)) """); @@ -630,7 +630,7 @@ public override Task Where_method_call_closure_via_query_cache(bool async) """ @__GetCity_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__GetCity_0)) """, @@ -638,7 +638,7 @@ FROM root c """ @__GetCity_0='Seattle' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__GetCity_0)) """); @@ -654,7 +654,7 @@ public override Task Where_field_access_closure_via_query_cache(bool async) """ @__city_InstanceFieldValue_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_InstanceFieldValue_0)) """, @@ -662,7 +662,7 @@ FROM root c """ @__city_InstanceFieldValue_0='Seattle' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_InstanceFieldValue_0)) """); @@ -678,7 +678,7 @@ public override Task Where_property_access_closure_via_query_cache(bool async) """ @__city_InstancePropertyValue_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_InstancePropertyValue_0)) """, @@ -686,7 +686,7 @@ FROM root c """ @__city_InstancePropertyValue_0='Seattle' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_InstancePropertyValue_0)) """); @@ -702,7 +702,7 @@ public override Task Where_static_field_access_closure_via_query_cache(bool asyn """ @__StaticFieldValue_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__StaticFieldValue_0)) """, @@ -710,7 +710,7 @@ FROM root c """ @__StaticFieldValue_0='Seattle' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__StaticFieldValue_0)) """); @@ -726,7 +726,7 @@ public override Task Where_static_property_access_closure_via_query_cache(bool a """ @__StaticPropertyValue_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__StaticPropertyValue_0)) """, @@ -734,7 +734,7 @@ FROM root c """ @__StaticPropertyValue_0='Seattle' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__StaticPropertyValue_0)) """); @@ -750,7 +750,7 @@ public override Task Where_nested_field_access_closure_via_query_cache(bool asyn """ @__city_Nested_InstanceFieldValue_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_Nested_InstanceFieldValue_0)) """, @@ -758,7 +758,7 @@ FROM root c """ @__city_Nested_InstanceFieldValue_0='Seattle' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_Nested_InstanceFieldValue_0)) """); @@ -774,7 +774,7 @@ public override Task Where_nested_property_access_closure_via_query_cache(bool a """ @__city_Nested_InstancePropertyValue_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_Nested_InstancePropertyValue_0)) """, @@ -782,7 +782,7 @@ FROM root c """ @__city_Nested_InstancePropertyValue_0='Seattle' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_Nested_InstancePropertyValue_0)) """); @@ -798,7 +798,7 @@ public override Task Where_new_instance_field_access_query_cache(bool async) """ @__InstanceFieldValue_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__InstanceFieldValue_0)) """, @@ -806,7 +806,7 @@ FROM root c """ @__InstanceFieldValue_0='Seattle' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__InstanceFieldValue_0)) """); @@ -822,7 +822,7 @@ public override Task Where_new_instance_field_access_closure_via_query_cache(boo """ @__InstanceFieldValue_0='London' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__InstanceFieldValue_0)) """, @@ -830,7 +830,7 @@ FROM root c """ @__InstanceFieldValue_0='Seattle' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__InstanceFieldValue_0)) """); @@ -864,7 +864,7 @@ public override Task Where_simple_shadow(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["Title"] = "Sales Representative")) """); @@ -878,7 +878,7 @@ public override Task Where_simple_shadow_projection(bool async) AssertSql( """ -SELECT c["Title"] +SELECT VALUE c["Title"] FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["Title"] = "Sales Representative")) """); @@ -898,7 +898,7 @@ await Fixture.NoSyncTest( """ @__p_0='5' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["Title"] = "Sales Representative")) ORDER BY c["EmployeeID"] @@ -974,7 +974,7 @@ public override Task Where_equals_method_string(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) """); @@ -988,7 +988,7 @@ public override Task Where_equals_method_string_with_ignore_case(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND STRINGEQUALS(c["City"], "London", true)) """); @@ -1011,7 +1011,7 @@ public override Task Where_equals_using_object_overload_on_mismatched_types(bool AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -1034,13 +1034,13 @@ public override Task Where_equals_on_mismatched_types_nullable_int_long(bool asy AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -1054,13 +1054,13 @@ public override Task Where_equals_on_mismatched_types_nullable_long_nullable_int AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -1076,7 +1076,7 @@ public override Task Where_equals_on_mismatched_types_int_nullable_int(bool asyn """ @__intPrm_0='2' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] = @__intPrm_0)) """, @@ -1084,7 +1084,7 @@ FROM root c """ @__intPrm_0='2' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (@__intPrm_0 = c["ReportsTo"])) """); @@ -1100,7 +1100,7 @@ public override Task Where_equals_on_matched_nullable_int_types(bool async) """ @__nullableIntPrm_0='2' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (@__nullableIntPrm_0 = c["ReportsTo"])) """, @@ -1108,7 +1108,7 @@ FROM root c """ @__nullableIntPrm_0='2' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] = @__nullableIntPrm_0)) """); @@ -1124,7 +1124,7 @@ public override Task Where_equals_on_null_nullable_int_types(bool async) """ @__nullableIntPrm_0=null -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (@__nullableIntPrm_0 = c["ReportsTo"])) """, @@ -1132,7 +1132,7 @@ FROM root c """ @__nullableIntPrm_0=null -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] = @__nullableIntPrm_0)) """); @@ -1146,7 +1146,7 @@ public override Task Where_comparison_nullable_type_not_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] = 2)) """); @@ -1160,7 +1160,7 @@ public override Task Where_comparison_nullable_type_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["ReportsTo"] = null)) """); @@ -1174,7 +1174,7 @@ public override Task Where_string_length(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (LENGTH(c["City"]) = 6)) """); @@ -1188,7 +1188,7 @@ public override Task Where_string_indexof(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (INDEX_OF(c["City"], "Sea") != -1)) """); @@ -1202,7 +1202,7 @@ public override Task Where_string_replace(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (REPLACE(c["City"], "Sea", "Rea") = "Reattle")) """); @@ -1216,7 +1216,7 @@ public override Task Where_string_substring(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (SUBSTRING(c["City"], 1, 2) = "ea")) """); @@ -1240,7 +1240,7 @@ public override Task Where_datetime_utcnow(bool async) """ @__myDatetime_0='2015-04-10T00:00:00' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (GetCurrentDateTime() != @__myDatetime_0)) """); @@ -1256,7 +1256,7 @@ public override Task Where_datetimeoffset_utcnow(bool async) """ @__myDatetimeOffset_0='2015-04-10T00:00:00-08:00' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (GetCurrentDateTime() != @__myDatetimeOffset_0)) """); @@ -1286,7 +1286,7 @@ public override Task Where_date_add_year_constant_component(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (DateTimePart("yyyy", DateTimeAdd("yyyy", -1, c["OrderDate"])) = 1997)) """); @@ -1300,7 +1300,7 @@ public override Task Where_datetime_year_component(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (DateTimePart("yyyy", c["OrderDate"]) = 1998)) """); @@ -1314,7 +1314,7 @@ public override Task Where_datetime_month_component(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (DateTimePart("mm", c["OrderDate"]) = 4)) """); @@ -1336,7 +1336,7 @@ public override Task Where_datetime_day_component(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (DateTimePart("dd", c["OrderDate"]) = 4)) """); @@ -1350,7 +1350,7 @@ public override Task Where_datetime_hour_component(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (DateTimePart("hh", c["OrderDate"]) = 0)) """); @@ -1364,7 +1364,7 @@ public override Task Where_datetime_minute_component(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (DateTimePart("mi", c["OrderDate"]) = 0)) """); @@ -1378,7 +1378,7 @@ public override Task Where_datetime_second_component(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (DateTimePart("ss", c["OrderDate"]) = 0)) """); @@ -1392,7 +1392,7 @@ public override Task Where_datetime_millisecond_component(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (DateTimePart("ms", c["OrderDate"]) = 0)) """); @@ -1422,7 +1422,7 @@ public override Task Where_simple_reversed(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ("London" = c["City"])) """); @@ -1436,7 +1436,7 @@ public override Task Where_is_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["Region"] = null)) """); @@ -1450,7 +1450,7 @@ public override Task Where_null_is_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -1464,7 +1464,7 @@ public override Task Where_constant_is_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -1478,7 +1478,7 @@ public override Task Where_is_not_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] != null)) """); @@ -1492,7 +1492,7 @@ public override Task Where_null_is_not_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -1506,7 +1506,7 @@ public override Task Where_constant_is_not_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -1520,7 +1520,7 @@ public override Task Where_identity_comparison(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = c["City"])) """); @@ -1584,7 +1584,7 @@ public override Task Where_primitive(bool async) """ @__p_0='9' -SELECT c["EmployeeID"] +SELECT VALUE c["EmployeeID"] FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["EmployeeID"] = 5)) OFFSET 0 LIMIT @__p_0 @@ -1599,7 +1599,7 @@ public override Task Where_bool_member(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND c["Discontinued"]) """); @@ -1613,7 +1613,7 @@ public override Task Where_bool_member_false(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND NOT(c["Discontinued"])) """); @@ -1635,7 +1635,7 @@ public override Task Where_bool_member_negated_twice(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND NOT(NOT((c["Discontinued"] = true)))) """); @@ -1649,7 +1649,7 @@ public override Task Where_bool_member_shadow(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND c["Discontinued"]) """); @@ -1663,7 +1663,7 @@ public override Task Where_bool_member_false_shadow(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND NOT(c["Discontinued"])) """); @@ -1677,7 +1677,7 @@ public override Task Where_bool_member_equals_constant(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["Discontinued"] = true)) """); @@ -1691,7 +1691,7 @@ public override Task Where_bool_member_in_complex_predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (((c["ProductID"] > 100) AND c["Discontinued"]) OR (c["Discontinued"] = true))) """); @@ -1705,7 +1705,7 @@ public override Task Where_bool_member_compared_to_binary_expression(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["Discontinued"] = (c["ProductID"] > 50))) """); @@ -1719,7 +1719,7 @@ public override Task Where_not_bool_member_compared_to_not_bool_member(bool asyn AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (NOT(c["Discontinued"]) = NOT(c["Discontinued"]))) """); @@ -1733,7 +1733,7 @@ public override Task Where_negated_boolean_expression_compared_to_another_negate AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (NOT((c["ProductID"] > 50)) = NOT((c["ProductID"] > 20)))) """); @@ -1747,7 +1747,7 @@ public override Task Where_not_bool_member_compared_to_binary_expression(bool as AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (NOT(c["Discontinued"]) = (c["ProductID"] > 50))) """); @@ -1763,7 +1763,7 @@ public override Task Where_bool_parameter(bool async) """ @__prm_0='true' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND @__prm_0) """); @@ -1779,7 +1779,7 @@ public override Task Where_bool_parameter_compared_to_binary_expression(bool asy """ @__prm_0='true' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND ((c["ProductID"] > 50) != @__prm_0)) """); @@ -1795,7 +1795,7 @@ public override Task Where_bool_member_and_parameter_compared_to_binary_expressi """ @__prm_0='true' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["Discontinued"] = ((c["ProductID"] > 50) != @__prm_0))) """); @@ -1809,7 +1809,7 @@ public override Task Where_de_morgan_or_optimized(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND NOT((c["Discontinued"] OR (c["ProductID"] < 20)))) """); @@ -1823,7 +1823,7 @@ public override Task Where_de_morgan_and_optimized(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND NOT((c["Discontinued"] AND (c["ProductID"] < 20)))) """); @@ -1837,7 +1837,7 @@ public override Task Where_complex_negated_expression_optimized(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND NOT((NOT((NOT(c["Discontinued"]) AND (c["ProductID"] < 60))) OR NOT((c["ProductID"] > 30))))) """); @@ -1851,7 +1851,7 @@ public override Task Where_short_member_comparison(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["UnitsInStock"] > 10)) """); @@ -1865,7 +1865,7 @@ public override Task Where_comparison_to_nullable_bool(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (ENDSWITH(c["CustomerID"], "KI") = true)) """); @@ -1879,7 +1879,7 @@ public override Task Where_true(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -1893,7 +1893,7 @@ public override Task Where_false(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -1907,7 +1907,7 @@ public override Task Where_bool_closure(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """, @@ -1917,7 +1917,7 @@ WHERE false "ReadItem(None, Customer|ALFKI)", // """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -1931,7 +1931,7 @@ public override Task Where_default(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["Fax"] = null)) """); @@ -2005,7 +2005,7 @@ public override Task Where_string_concat_method_comparison(bool async) """ @__i_0='A' -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((@__i_0 || c["CustomerID"]) = "AAROUT")) """); @@ -2022,7 +2022,7 @@ public override Task Where_string_concat_method_comparison_2(bool async) @__i_0='A' @__j_1='B' -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((@__i_0 || (@__j_1 || c["CustomerID"])) = "ABANATR")) """); @@ -2040,7 +2040,7 @@ public override Task Where_string_concat_method_comparison_3(bool async) @__j_1='B' @__k_2='C' -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((@__i_0 || (@__j_1 || (@__k_2 || c["CustomerID"]))) = "ABCANTON")) """); @@ -2054,7 +2054,7 @@ public override Task Where_ternary_boolean_condition_true(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["UnitsInStock"] >= 20)) """); @@ -2068,7 +2068,7 @@ public override Task Where_ternary_boolean_condition_false(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["UnitsInStock"] < 20)) """); @@ -2084,7 +2084,7 @@ public override Task Where_ternary_boolean_condition_with_another_condition(bool """ @__productId_0='15' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND ((c["ProductID"] < @__productId_0) AND (c["UnitsInStock"] >= 20))) """); @@ -2098,7 +2098,7 @@ public override Task Where_ternary_boolean_condition_with_false_as_result_true(b AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (c["UnitsInStock"] >= 20)) """); @@ -2112,7 +2112,7 @@ public override Task Where_ternary_boolean_condition_with_false_as_result_false( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -2126,7 +2126,7 @@ public override Task Where_ternary_boolean_condition_negated(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND NOT(((c["UnitsInStock"] >= 20) ? false : true))) """); @@ -2212,7 +2212,7 @@ public override Task Where_compare_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((c["Region"] = null) AND (c["Country"] = "UK"))) """); @@ -2226,7 +2226,7 @@ public override Task Where_Is_on_same_type(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -2240,7 +2240,7 @@ public override Task Where_chain(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (((c["Discriminator"] = "Order") AND (c["CustomerID"] = "QUICK")) AND (c["OrderDate"] > "1998-01-01T00:00:00")) """); @@ -2316,7 +2316,7 @@ public override Task Time_of_day_datetime(bool async) AssertSql( """ -SELECT c["OrderDate"] +SELECT VALUE c["OrderDate"] FROM root c WHERE (c["Discriminator"] = "Order") """); @@ -2332,7 +2332,7 @@ public override Task TypeBinary_short_circuit(bool async) """ @__p_0='false' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND @__p_0) """); @@ -2354,7 +2354,7 @@ public override Task Where_is_conditional(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Product") AND (true ? false : true)) """); @@ -2538,7 +2538,7 @@ public override Task Where_list_object_contains_over_value_type(bool async) """ @__orderIds_0='[10248,10249]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ARRAY_CONTAINS(@__orderIds_0, c["OrderID"])) """); @@ -2554,7 +2554,7 @@ public override Task Where_array_of_object_contains_over_value_type(bool async) """ @__orderIds_0='[10248,10249]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND ARRAY_CONTAINS(@__orderIds_0, c["OrderID"])) """); @@ -2716,7 +2716,7 @@ public override Task Where_Contains_and_comparison(bool async) """ @__customerIds_0='["ALFKI","FISSA","WHITC"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (ARRAY_CONTAINS(@__customerIds_0, c["CustomerID"]) AND (c["City"] = "Seattle"))) """); @@ -2732,7 +2732,7 @@ public override Task Where_Contains_or_comparison(bool async) """ @__customerIds_0='["ALFKI","FISSA"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (ARRAY_CONTAINS(@__customerIds_0, c["CustomerID"]) OR (c["City"] = "Seattle"))) """); @@ -2760,7 +2760,7 @@ public override Task GetType_on_non_hierarchy1(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -2774,7 +2774,7 @@ public override Task GetType_on_non_hierarchy2(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -2788,7 +2788,7 @@ public override Task GetType_on_non_hierarchy3(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -2802,7 +2802,7 @@ public override Task GetType_on_non_hierarchy4(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """); @@ -2816,7 +2816,7 @@ public override Task Case_block_simplification_works_correctly(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["Region"] = null) ? "OR" : c["Region"]) = "OR")) """); @@ -2830,7 +2830,7 @@ public override Task Where_compare_null_with_cast_to_object(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["Region"] = null)) """); @@ -2844,7 +2844,7 @@ public override Task Where_compare_with_both_cast_to_object(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) """); @@ -2858,7 +2858,7 @@ public override Task Where_projection(bool async) AssertSql( """ -SELECT c["CompanyName"] +SELECT VALUE c["CompanyName"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = "London")) """); @@ -2904,7 +2904,7 @@ public override Task Generic_Ilist_contains_translates_to_server(bool async) """ @__cities_0='["Seattle"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ARRAY_CONTAINS(@__cities_0, c["City"])) """); @@ -2918,7 +2918,7 @@ public override Task Multiple_OrElse_on_same_column_converted_to_in_with_overlap AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((((c["CustomerID"] = "ALFKI") OR (c["CustomerID"] = "ANATR")) OR (c["CustomerID"] = "ANTON")) OR (c["CustomerID"] = "ANATR"))) """); @@ -2932,7 +2932,7 @@ public override Task Multiple_OrElse_on_same_column_with_null_constant_compariso AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((((c["Region"] = "WA") OR (c["Region"] = "OR")) OR (c["Region"] = null)) OR (c["Region"] = "BC"))) """); @@ -2946,7 +2946,7 @@ public override Task Constant_array_Contains_OrElse_comparison_with_constant_get AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] IN ("ALFKI", "ANATR") OR (c["CustomerID"] = "ANTON"))) """); @@ -2960,7 +2960,7 @@ public override Task Constant_array_Contains_OrElse_comparison_with_constant_get AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["CustomerID"] = "ANTON") OR c["CustomerID"] IN ("ALFKI", "ANATR")) OR (c["CustomerID"] = "ALFKI"))) """); @@ -2974,7 +2974,7 @@ public override Task Constant_array_Contains_OrElse_another_Contains_gets_combin AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] IN ("ALFKI", "ANATR") OR c["CustomerID"] IN ("ALFKI", "ANTON"))) """); @@ -2988,7 +2988,7 @@ public override Task Constant_array_Contains_AndAlso_another_Contains_gets_combi AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] NOT IN ("ALFKI", "ANATR") AND c["CustomerID"] NOT IN ("ALFKI", "ANTON"))) """); @@ -3006,7 +3006,7 @@ public override Task Multiple_AndAlso_on_same_column_converted_to_in_using_param @__prm2_1='ANATR' @__prm3_2='ANTON' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["CustomerID"] != @__prm1_0) AND (c["CustomerID"] != @__prm2_1)) AND (c["CustomerID"] != @__prm3_2))) """); @@ -3023,7 +3023,7 @@ public override Task Array_of_parameters_Contains_OrElse_comparison_with_constan @__prm1_0='ALFKI' @__prm2_1='ANATR' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] IN (@__prm1_0, @__prm2_1) OR (c["CustomerID"] = "ANTON"))) """); @@ -3039,7 +3039,7 @@ public override Task Multiple_OrElse_on_same_column_with_null_parameter_comparis """ @__prm_0=null -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((((c["Region"] = "WA") OR (c["Region"] = "OR")) OR (c["Region"] = @__prm_0)) OR (c["Region"] = "BC"))) """); @@ -3055,7 +3055,7 @@ public override Task Parameter_array_Contains_OrElse_comparison_with_constant(bo """ @__array_0='["ALFKI","ANATR"]' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (ARRAY_CONTAINS(@__array_0, c["CustomerID"]) OR (c["CustomerID"] = "ANTON"))) """); @@ -3073,7 +3073,7 @@ public override Task Parameter_array_Contains_OrElse_comparison_with_parameter_w @__array_1='["ALFKI","ANATR"]' @__prm2_2='ALFKI' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (((c["CustomerID"] = @__prm1_0) OR ARRAY_CONTAINS(@__array_1, c["CustomerID"])) OR (c["CustomerID"] = @__prm2_2))) """); @@ -3087,7 +3087,7 @@ public override Task Two_sets_of_comparison_combine_correctly(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] IN ("ALFKI", "ANATR") AND ((c["CustomerID"] = "ANATR") OR (c["CustomerID"] = "ANTON")))) """); @@ -3101,7 +3101,7 @@ public override Task Two_sets_of_comparison_combine_correctly2(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((((c["Region"] != "WA") AND (c["Region"] != "OR")) AND (c["Region"] != null)) OR ((c["Region"] != "WA") AND (c["Region"] != null)))) """); @@ -3115,7 +3115,7 @@ public override Task Filter_with_property_compared_to_null_wrapped_in_explicit_c AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["Region"] = null)) """); @@ -3163,7 +3163,7 @@ public override Task Where_primitive_tracked(bool async) """ @__p_0='9' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["EmployeeID"] = 5)) OFFSET 0 LIMIT @__p_0 @@ -3180,7 +3180,7 @@ public override Task Where_primitive_tracked2(bool async) """ @__p_0='9' -SELECT c AS e +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Employee") AND (c["EmployeeID"] = 5)) OFFSET 0 LIMIT @__p_0 @@ -3197,7 +3197,7 @@ public override Task Where_poco_closure(bool async) """ @__entity_equality_customer_0_CustomerID='ALFKI' -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = @__entity_equality_customer_0_CustomerID)) """, @@ -3205,7 +3205,7 @@ FROM root c """ @__entity_equality_customer_0_CustomerID='ANATR' -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = @__entity_equality_customer_0_CustomerID)) """); @@ -3221,7 +3221,7 @@ public override Task Where_concat_string_string_comparison(bool async) """ @__i_0='A' -SELECT c["CustomerID"] +SELECT VALUE c["CustomerID"] FROM root c WHERE ((c["Discriminator"] = "Customer") AND ((@__i_0 || c["CustomerID"]) = "AALFKI")) """); @@ -3253,7 +3253,7 @@ public override Task EF_Constant_does_not_parameterized_as_part_of_bigger_subtre AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = ("ALF" || "KI"))) """); @@ -3294,7 +3294,7 @@ public override Task EF_Parameter_does_not_parameterized_as_part_of_bigger_subtr """ @__id_0='ALF' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["CustomerID"] = (@__id_0 || "KI"))) """); @@ -3315,7 +3315,7 @@ public override Task Implicit_cast_in_predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "1337")) """, @@ -3323,7 +3323,7 @@ FROM root c """ @__prm_Value_0='1337' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = @__prm_Value_0)) """, @@ -3331,7 +3331,7 @@ FROM root c """ @__ToString_0='1337' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = @__ToString_0)) """, @@ -3339,13 +3339,13 @@ FROM root c """ @__p_0='1337' -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = @__p_0)) """, // """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["CustomerID"] = "1337")) """); @@ -3361,25 +3361,25 @@ public override Task Interface_casting_though_generic_method(bool async) """ @__id_0='10252' -SELECT c["OrderID"] AS Id +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = @__id_0)) """, // """ -SELECT c["OrderID"] AS Id +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10252)) """, // """ -SELECT c["OrderID"] AS Id +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10252)) """, // """ -SELECT c["OrderID"] AS Id +SELECT VALUE c["OrderID"] FROM root c WHERE ((c["Discriminator"] = "Order") AND (c["OrderID"] = 10252)) """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs index 0f9bd9e7ca3..73ad5f5e24d 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/OwnedQueryCosmosTest.cs @@ -46,7 +46,7 @@ public override Task Navigation_rewrite_on_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY_LENGTH(c["Orders"]) > 0)) ORDER BY c["Id"] @@ -65,10 +65,10 @@ public override async Task Navigation_rewrite_on_owned_collection_with_compositi AssertSql( """ -SELECT (ARRAY( +SELECT VALUE (ARRAY( SELECT VALUE (o["Id"] != 42) FROM o IN c["Orders"] - ORDER BY o["Id"])[0] ?? false) AS c + ORDER BY o["Id"])[0] ?? false) FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["Id"] @@ -97,7 +97,7 @@ public override Task Navigation_rewrite_on_owned_reference_projecting_entity(boo AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["PersonAddress"]["Country"]["Name"] = "USA")) """); @@ -111,7 +111,7 @@ public override Task Navigation_rewrite_on_owned_reference_projecting_scalar(boo AssertSql( """ -SELECT c["PersonAddress"]["Country"]["Name"] +SELECT VALUE c["PersonAddress"]["Country"]["Name"] FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["PersonAddress"]["Country"]["Name"] = "USA")) """); @@ -125,7 +125,7 @@ public override Task Query_for_base_type_loads_all_owned_navs(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") """); @@ -139,7 +139,7 @@ public override Task Query_for_branch_type_loads_all_owned_navs(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("Branch", "LeafA") """); @@ -153,7 +153,7 @@ public override Task Query_for_branch_type_loads_all_owned_navs_tracking(bool as AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("Branch", "LeafA") """); @@ -167,7 +167,7 @@ public override Task Query_for_leaf_type_loads_all_owned_navs(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "LeafA") """); @@ -301,7 +301,7 @@ public override Task SelectMany_on_owned_collection(bool async) AssertSql( """ -SELECT o AS o0 +SELECT VALUE o FROM root c JOIN o IN c["Orders"] WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") @@ -366,7 +366,7 @@ public override Task Query_with_OfType_eagerly_loads_correct_owned_navigations(b AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["Discriminator"] = "LeafA")) """); @@ -385,7 +385,7 @@ public override Task Project_owned_reference_navigation_which_owns_additional(bo // TODO: The following should project out c["PersonAddress"], not c: #34067 AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["Id"] @@ -410,7 +410,7 @@ public override Task No_ignored_include_warning_when_implicit_load(bool async) AssertSql( """ -SELECT COUNT(1) AS c +SELECT VALUE COUNT(1) FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") """); @@ -448,10 +448,9 @@ await AssertQuery( assertOrder: true, elementAsserter: (e, a) => AssertCollection(e, a)); - // TODO: The following should project out a["Details"], not a: #34067 AssertSql( """ -SELECT o["Details"] +SELECT VALUE o["Details"] FROM root c JOIN o IN c["Orders"] WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY_LENGTH(o["Details"]) = 1)) @@ -478,7 +477,7 @@ await AssertQuery( AssertSql( """ -SELECT o AS o0 +SELECT VALUE o FROM root c JOIN o IN c["Orders"] WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY_LENGTH(o["Details"]) = 1)) @@ -505,7 +504,7 @@ await AssertQuery( AssertSql( """ -SELECT o AS o0 +SELECT VALUE o FROM root c JOIN o IN c["Orders"] WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY_LENGTH(o["Details"]) = 1)) @@ -532,7 +531,7 @@ await AssertQuery( AssertSql( """ -SELECT o["Details"] +SELECT VALUE o["Details"] FROM root c JOIN o IN c["Orders"] WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY_LENGTH(o["Details"]) = 1)) @@ -559,7 +558,7 @@ await AssertQuery( AssertSql( """ -SELECT o AS o0 +SELECT VALUE o FROM root c JOIN o IN c["Orders"] WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY_LENGTH(o["Details"]) = 1)) @@ -579,7 +578,7 @@ public override Task Can_query_on_indexer_properties(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["Name"] = "Mona Cy")) """); @@ -593,7 +592,7 @@ public override Task Can_query_on_owned_indexer_properties(bool async) AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["PersonAddress"]["ZipCode"] = 38654)) """); @@ -607,7 +606,7 @@ public override Task Can_query_on_indexer_property_when_property_name_from_closu AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["Name"] = "Mona Cy")) """); @@ -621,7 +620,7 @@ public override Task Can_project_indexer_properties(bool async) AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") """); @@ -635,7 +634,7 @@ public override Task Can_project_owned_indexer_properties(bool async) AssertSql( """ -SELECT c["PersonAddress"]["AddressLine"] +SELECT VALUE c["PersonAddress"]["AddressLine"] FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") """); @@ -649,7 +648,7 @@ public override Task Can_project_indexer_properties_converted(bool async) AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") """); @@ -668,7 +667,7 @@ public override async Task Can_OrderBy_indexer_properties(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["Name"], c["Id"] @@ -689,7 +688,7 @@ public override async Task Can_OrderBy_indexer_properties_converted(bool async) AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["Name"], c["Id"] @@ -710,7 +709,7 @@ public override async Task Can_OrderBy_owned_indexer_properties(bool async) AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["PersonAddress"]["ZipCode"], c["Id"] @@ -731,7 +730,7 @@ public override async Task Can_OrderBy_owned_indexer_properties_converted(bool a AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["PersonAddress"]["ZipCode"], c["Id"] @@ -767,7 +766,7 @@ public override Task Projecting_indexer_property_ignores_include(bool async) AssertSql( """ -SELECT c["PersonAddress"]["ZipCode"] AS Nation +SELECT VALUE c["PersonAddress"]["ZipCode"] FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") """); @@ -781,7 +780,7 @@ public override Task Projecting_indexer_property_ignores_include_converted(bool AssertSql( """ -SELECT c["PersonAddress"]["ZipCode"] AS Nation +SELECT VALUE c["PersonAddress"]["ZipCode"] FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") """); @@ -800,7 +799,7 @@ public override Task Can_query_indexer_property_on_owned_collection(bool async) AssertSql( """ -SELECT c["Name"] +SELECT VALUE c["Name"] FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (( SELECT VALUE COUNT(1) @@ -844,7 +843,7 @@ public override async Task Ordering_by_identifying_projection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["PersonAddress"]["PlaceType"], c["Id"] @@ -860,7 +859,7 @@ public override Task Query_on_collection_entry_works_for_owned_collection(bool a AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["Id"] = 1)) OFFSET 0 LIMIT 2 @@ -869,7 +868,7 @@ OFFSET 0 LIMIT 2 """ @__p_0='1' -SELECT o AS o0 +SELECT VALUE o FROM root c JOIN o IN c["Orders"] WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (o["ClientId"] = @__p_0)) @@ -917,7 +916,7 @@ public override Task Filter_on_indexer_using_closure(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["PersonAddress"]["ZipCode"] = 38654)) """); @@ -931,7 +930,7 @@ public override Task Filter_on_indexer_using_function_argument(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["PersonAddress"]["ZipCode"] = 38654)) """); @@ -949,7 +948,7 @@ public override Task Can_project_owned_indexer_properties_converted(bool async) AssertSql( """ -SELECT c["PersonAddress"]["AddressLine"] +SELECT VALUE c["PersonAddress"]["AddressLine"] FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") """); @@ -963,7 +962,7 @@ public override Task Can_query_owner_with_different_owned_types_having_same_prop AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("HeliumBalloon", "HydrogenBalloon") """); @@ -980,7 +979,7 @@ public override Task Client_method_skip_take_loads_owned_navigations_variation_2 @__p_0='1' @__p_1='2' -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["Id"] @@ -999,7 +998,7 @@ public override Task Client_method_skip_take_loads_owned_navigations(bool async) @__p_0='1' @__p_1='2' -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["Id"] @@ -1015,11 +1014,14 @@ public override async Task Non_nullable_property_through_optional_navigation(boo await CosmosTestHelpers.Instance.NoSyncTest( async, async a => { - await base.Non_nullable_property_through_optional_navigation(a); + await Assert.ThrowsAsync( + () => AssertQuery( + async, + ss => ss.Set().Select(e => new { e.Throned.Value }))); AssertSql( """ -SELECT c["Throned"]["Value"] +SELECT VALUE c["Throned"]["Value"] FROM root c WHERE (c["Discriminator"] = "Barton") """); @@ -1035,7 +1037,7 @@ public override Task Owned_entity_without_owner_does_not_throw_for_identity_reso AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") """); @@ -1049,7 +1051,7 @@ public override Task Simple_query_entity_with_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Star") """); @@ -1063,7 +1065,7 @@ public override Task Throw_for_owned_entities_without_owner_in_tracking_query(bo AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") """); @@ -1077,7 +1079,7 @@ public override Task Unmapped_property_projection_loads_owned_navigations(bool a AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["Id"] = 1)) """); @@ -1093,7 +1095,7 @@ public override Task Client_method_take_loads_owned_navigations(bool async) """ @__p_0='2' -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["Id"] @@ -1113,7 +1115,7 @@ public override Task Client_method_take_loads_owned_navigations_variation_2(bool """ @__p_0='2' -SELECT c +SELECT VALUE c FROM root c WHERE c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") ORDER BY c["Id"] @@ -1131,7 +1133,7 @@ public override Task Count_over_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY_LENGTH(c["Orders"]) = 2)) """); @@ -1147,7 +1149,7 @@ public override Task Any_without_predicate_over_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY_LENGTH(c["Orders"]) > 0)) """); @@ -1163,7 +1165,7 @@ public override Task Any_with_predicate_over_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND EXISTS ( SELECT 1 @@ -1182,7 +1184,7 @@ public override Task Contains_over_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND EXISTS ( SELECT 1 @@ -1201,7 +1203,7 @@ public override Task ElementAt_over_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (c["Orders"][1]["Id"] = -11)) """); @@ -1217,7 +1219,7 @@ public override Task ElementAtOrDefault_over_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND ((c["Orders"][10] ?? null)["Id"] = -11)) """); @@ -1236,7 +1238,7 @@ public override async Task OrderBy_ElementAt_over_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY( SELECT VALUE o["Id"] @@ -1256,7 +1258,7 @@ public override Task Skip_Take_over_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY_LENGTH(ARRAY_SLICE(c["Orders"], 1, 1)) = 1)) """); @@ -1272,7 +1274,7 @@ public override Task FirstOrDefault_over_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (DateTimePart("yyyy", (ARRAY( SELECT VALUE o["OrderDate"] @@ -1305,7 +1307,7 @@ public override Task Union_over_owned_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("OwnedPerson", "Branch", "LeafB", "LeafA") AND (ARRAY_LENGTH(SetUnion(ARRAY( SELECT VALUE o diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs index eb9bfb4ca36..c3275e807a9 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/PrimitiveCollectionsQueryCosmosTest.cs @@ -27,7 +27,7 @@ public override Task Inline_collection_of_ints_Contains(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Int"] IN (10, 999) """); @@ -41,7 +41,7 @@ public override Task Inline_collection_of_nullable_ints_Contains(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["NullableInt"] IN (10, 999) """); @@ -55,7 +55,7 @@ public override Task Inline_collection_of_nullable_ints_Contains_null(bool async AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["NullableInt"] IN (null, 999) """); @@ -69,7 +69,7 @@ public override Task Inline_collection_Count_with_zero_values(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -86,7 +86,7 @@ public override Task Inline_collection_Count_with_one_value(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -103,7 +103,7 @@ public override Task Inline_collection_Count_with_two_values(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -120,7 +120,7 @@ public override Task Inline_collection_Count_with_three_values(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -137,7 +137,7 @@ public override Task Inline_collection_Contains_with_zero_values(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE false """); @@ -160,7 +160,7 @@ public override Task Inline_collection_Contains_with_two_values(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Id"] IN (2, 999) """); @@ -174,7 +174,7 @@ public override Task Inline_collection_Contains_with_three_values(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Id"] IN (2, 999, 1000) """); @@ -188,7 +188,7 @@ public override Task Inline_collection_Contains_with_EF_Constant(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Id"] IN (2, 999, 1000) """); @@ -205,7 +205,7 @@ public override Task Inline_collection_Contains_with_all_parameters(bool async) @__i_0='2' @__j_1='999' -SELECT c +SELECT VALUE c FROM root c WHERE c["Id"] IN (@__i_0, @__j_1) """); @@ -221,7 +221,7 @@ public override Task Inline_collection_Contains_with_constant_and_parameter(bool """ @__j_0='999' -SELECT c +SELECT VALUE c FROM root c WHERE c["Id"] IN (2, @__j_0) """); @@ -237,7 +237,7 @@ public override Task Inline_collection_Contains_with_mixed_value_types(bool asyn """ @__i_0='11' -SELECT c +SELECT VALUE c FROM root c WHERE c["Int"] IN (999, @__i_0, c["Id"], (c["Id"] + c["Int"])) """); @@ -253,7 +253,7 @@ public override Task Inline_collection_List_Contains_with_mixed_value_types(bool """ @__i_0='11' -SELECT c +SELECT VALUE c FROM root c WHERE c["Int"] IN (999, @__i_0, c["Id"], (c["Id"] + c["Int"])) """); @@ -267,7 +267,7 @@ public override Task Inline_collection_Contains_as_Any_with_predicate(bool async AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Id"] IN (2, 999) """); @@ -281,7 +281,7 @@ public override Task Inline_collection_negated_Contains_as_All(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE c["Id"] NOT IN (2, 999) """); @@ -295,7 +295,7 @@ public override Task Inline_collection_Min_with_two_values(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE MIN(a) @@ -311,7 +311,7 @@ public override Task Inline_collection_List_Min_with_two_values(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE MIN(a) @@ -327,7 +327,7 @@ public override Task Inline_collection_Max_with_two_values(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE MAX(a) @@ -343,7 +343,7 @@ public override Task Inline_collection_List_Max_with_two_values(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE MAX(a) @@ -361,7 +361,7 @@ public override Task Inline_collection_Min_with_three_values(bool async) """ @__i_0='25' -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE MIN(a) @@ -379,7 +379,7 @@ public override Task Inline_collection_List_Min_with_three_values(bool async) """ @__i_0='25' -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE MIN(a) @@ -397,7 +397,7 @@ public override Task Inline_collection_Max_with_three_values(bool async) """ @__i_0='35' -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE MAX(a) @@ -415,7 +415,7 @@ public override Task Inline_collection_List_Max_with_three_values(bool async) """ @__i_0='35' -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE MAX(a) @@ -433,7 +433,7 @@ public override Task Parameter_collection_Count(bool async) """ @__ids_0='[2,999]' -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -452,7 +452,7 @@ public override Task Parameter_collection_of_ints_Contains_int(bool async) """ @__ints_0='[10,999]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__ints_0, c["Int"]) """, @@ -460,7 +460,7 @@ WHERE ARRAY_CONTAINS(@__ints_0, c["Int"]) """ @__ints_0='[10,999]' -SELECT c +SELECT VALUE c FROM root c WHERE NOT(ARRAY_CONTAINS(@__ints_0, c["Int"])) """); @@ -476,7 +476,7 @@ public override Task Parameter_collection_HashSet_of_ints_Contains_int(bool asyn """ @__ints_0='[10,999]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__ints_0, c["Int"]) """, @@ -484,7 +484,7 @@ WHERE ARRAY_CONTAINS(@__ints_0, c["Int"]) """ @__ints_0='[10,999]' -SELECT c +SELECT VALUE c FROM root c WHERE NOT(ARRAY_CONTAINS(@__ints_0, c["Int"])) """); @@ -500,7 +500,7 @@ public override Task Parameter_collection_of_ints_Contains_nullable_int(bool asy """ @__ints_0='[10,999]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__ints_0, c["NullableInt"]) """, @@ -508,7 +508,7 @@ WHERE ARRAY_CONTAINS(@__ints_0, c["NullableInt"]) """ @__ints_0='[10,999]' -SELECT c +SELECT VALUE c FROM root c WHERE NOT(ARRAY_CONTAINS(@__ints_0, c["NullableInt"])) """); @@ -524,7 +524,7 @@ public override Task Parameter_collection_of_nullable_ints_Contains_int(bool asy """ @__nullableInts_0='[10,999]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__nullableInts_0, c["Int"]) """, @@ -532,7 +532,7 @@ WHERE ARRAY_CONTAINS(@__nullableInts_0, c["Int"]) """ @__nullableInts_0='[10,999]' -SELECT c +SELECT VALUE c FROM root c WHERE NOT(ARRAY_CONTAINS(@__nullableInts_0, c["Int"])) """); @@ -548,7 +548,7 @@ public override Task Parameter_collection_of_nullable_ints_Contains_nullable_int """ @__nullableInts_0='[null,999]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__nullableInts_0, c["NullableInt"]) """, @@ -556,7 +556,7 @@ WHERE ARRAY_CONTAINS(@__nullableInts_0, c["NullableInt"]) """ @__nullableInts_0='[null,999]' -SELECT c +SELECT VALUE c FROM root c WHERE NOT(ARRAY_CONTAINS(@__nullableInts_0, c["NullableInt"])) """); @@ -572,7 +572,7 @@ public override Task Parameter_collection_of_strings_Contains_string(bool async) """ @__strings_0='["10","999"]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__strings_0, c["String"]) """, @@ -580,7 +580,7 @@ WHERE ARRAY_CONTAINS(@__strings_0, c["String"]) """ @__strings_0='["10","999"]' -SELECT c +SELECT VALUE c FROM root c WHERE NOT(ARRAY_CONTAINS(@__strings_0, c["String"])) """); @@ -596,7 +596,7 @@ public override Task Parameter_collection_of_strings_Contains_nullable_string(bo """ @__strings_0='["10","999"]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__strings_0, c["NullableString"]) """, @@ -604,7 +604,7 @@ WHERE ARRAY_CONTAINS(@__strings_0, c["NullableString"]) """ @__strings_0='["10","999"]' -SELECT c +SELECT VALUE c FROM root c WHERE NOT(ARRAY_CONTAINS(@__strings_0, c["NullableString"])) """); @@ -620,7 +620,7 @@ public override Task Parameter_collection_of_nullable_strings_Contains_string(bo """ @__strings_0='["10",null]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__strings_0, c["String"]) """, @@ -628,7 +628,7 @@ WHERE ARRAY_CONTAINS(@__strings_0, c["String"]) """ @__strings_0='["10",null]' -SELECT c +SELECT VALUE c FROM root c WHERE NOT(ARRAY_CONTAINS(@__strings_0, c["String"])) """); @@ -644,7 +644,7 @@ public override Task Parameter_collection_of_nullable_strings_Contains_nullable_ """ @__strings_0='["999",null]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__strings_0, c["NullableString"]) """, @@ -652,7 +652,7 @@ WHERE ARRAY_CONTAINS(@__strings_0, c["NullableString"]) """ @__strings_0='["999",null]' -SELECT c +SELECT VALUE c FROM root c WHERE NOT(ARRAY_CONTAINS(@__strings_0, c["NullableString"])) """); @@ -668,7 +668,7 @@ public override Task Parameter_collection_of_DateTimes_Contains(bool async) """ @__dateTimes_0='["2020-01-10T12:30:00Z","9999-01-01T00:00:00Z"]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__dateTimes_0, c["DateTime"]) """); @@ -684,7 +684,7 @@ public override Task Parameter_collection_of_bools_Contains(bool async) """ @__bools_0='[true]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__bools_0, c["Bool"]) """); @@ -700,7 +700,7 @@ public override Task Parameter_collection_of_enums_Contains(bool async) """ @__enums_0='[0,3]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__enums_0, c["Enum"]) """); @@ -716,7 +716,7 @@ public override Task Parameter_collection_null_Contains(bool async) """ @__ints_0=null -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__ints_0, c["Int"]) """); @@ -730,7 +730,7 @@ public override Task Column_collection_of_ints_Contains(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(c["Ints"], 10) """); @@ -744,7 +744,7 @@ public override Task Column_collection_of_nullable_ints_Contains(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(c["NullableInts"], 10) """); @@ -758,7 +758,7 @@ public override Task Column_collection_of_nullable_ints_Contains_null(bool async AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(c["NullableInts"], null) """); @@ -772,7 +772,7 @@ public override Task Column_collection_of_strings_contains_null(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(c["Strings"], null) """); @@ -786,7 +786,7 @@ public override Task Column_collection_of_nullable_strings_contains_null(bool as AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(c["NullableStrings"], null) """); @@ -800,7 +800,7 @@ public override Task Column_collection_of_bools_Contains(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(c["Bools"], true) """); @@ -814,7 +814,7 @@ public override Task Column_collection_Count_method(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(c["Ints"]) = 2) """); @@ -828,7 +828,7 @@ public override Task Column_collection_Length(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(c["Ints"]) = 2) """); @@ -842,7 +842,7 @@ public override Task Column_collection_Count_with_predicate(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -859,7 +859,7 @@ public override Task Column_collection_Where_Count(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (( SELECT VALUE COUNT(1) @@ -876,7 +876,7 @@ public override Task Column_collection_index_int(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Ints"][1] = 10) """); @@ -890,7 +890,7 @@ public override Task Column_collection_index_string(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Strings"][1] = "10") """); @@ -904,7 +904,7 @@ public override Task Column_collection_index_datetime(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["DateTimes"][1] = "2020-01-10T12:30:00Z") """); @@ -918,7 +918,7 @@ public override Task Column_collection_index_beyond_end(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Ints"][999] = 10) """); @@ -933,7 +933,7 @@ public override async Task Nullable_reference_column_collection_index_equals_nul AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["NullableStrings"][2] = c["NullableString"]) """); @@ -948,7 +948,7 @@ public override Task Non_nullable_reference_column_collection_index_equals_nulla AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((ARRAY_LENGTH(c["Strings"]) > 0) AND (c["Strings"][1] = c["NullableString"])) """); @@ -966,7 +966,7 @@ public override async Task Inline_collection_index_Column(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ([1, 2, 3][c["Int"]] = 1) """); @@ -985,7 +985,7 @@ public override async Task Inline_collection_value_index_Column(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ([1, c["Int"], 3][c["Int"]] = 1) """); @@ -1004,7 +1004,7 @@ public override async Task Inline_collection_List_value_index_Column(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ([1, c["Int"], 3][c["Int"]] = 1) """); @@ -1025,7 +1025,7 @@ public override async Task Parameter_collection_index_Column_equal_Column(bool a """ @__ints_0='[0,2,3]' -SELECT c +SELECT VALUE c FROM root c WHERE (@__ints_0[c["Int"]] = c["Int"]) """); @@ -1046,7 +1046,7 @@ public override async Task Parameter_collection_index_Column_equal_constant(bool """ @__ints_0='[1,2,3]' -SELECT c +SELECT VALUE c FROM root c WHERE (@__ints_0[c["Int"]] = 1) """); @@ -1061,7 +1061,7 @@ public override Task Column_collection_ElementAt(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Ints"][1] = 10) """); @@ -1075,7 +1075,7 @@ public override Task Column_collection_First(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Ints"][0] = 1) """); @@ -1089,7 +1089,7 @@ public override Task Column_collection_FirstOrDefault(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Ints"][0] ?? 0) = 1) """); @@ -1103,7 +1103,7 @@ public override Task Column_collection_Single(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Ints"][0] = 1) """); @@ -1117,7 +1117,7 @@ public override Task Column_collection_SingleOrDefault(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Ints"][0] ?? 0) = 1) """); @@ -1131,7 +1131,7 @@ public override Task Column_collection_Skip(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(ARRAY_SLICE(c["Ints"], 1)) = 2) """); @@ -1145,7 +1145,7 @@ public override Task Column_collection_Take(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(ARRAY_SLICE(c["Ints"], 0, 2), 11) """); @@ -1159,7 +1159,7 @@ public override Task Column_collection_Skip_Take(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(ARRAY_SLICE(c["Ints"], 1, 2), 11) """); @@ -1173,7 +1173,7 @@ public override Task Column_collection_Where_Skip(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(ARRAY_SLICE(ARRAY( SELECT VALUE i @@ -1190,7 +1190,7 @@ public override Task Column_collection_Where_Take(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(ARRAY_SLICE(ARRAY( SELECT VALUE i @@ -1207,7 +1207,7 @@ public override Task Column_collection_Where_Skip_Take(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(ARRAY_SLICE(ARRAY( SELECT VALUE i @@ -1224,7 +1224,7 @@ public override Task Column_collection_Contains_over_subquery(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE EXISTS ( SELECT 1 @@ -1245,7 +1245,7 @@ public override async Task Column_collection_OrderByDescending_ElementAt(bool as AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY( SELECT VALUE i @@ -1263,7 +1263,7 @@ public override Task Column_collection_Where_ElementAt(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY( SELECT VALUE i @@ -1280,7 +1280,7 @@ public override Task Column_collection_Any(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(c["Ints"]) > 0) """); @@ -1302,7 +1302,7 @@ public override Task Column_collection_SelectMany(bool async) AssertSql( """ -SELECT i AS i0 +SELECT VALUE i FROM root c JOIN i IN c["Ints"] """); @@ -1316,7 +1316,7 @@ public override Task Column_collection_SelectMany_with_filter(bool async) AssertSql( """ -SELECT j +SELECT VALUE j FROM root c JOIN ( SELECT VALUE i @@ -1346,7 +1346,7 @@ public override Task Column_collection_projection_from_top_level(bool async) AssertSql( """ -SELECT c["Ints"] +SELECT VALUE c["Ints"] FROM root c ORDER BY c["Id"] """); @@ -1378,7 +1378,7 @@ public override Task Parameter_collection_Concat_column_collection(bool async) """ @__ints_0='[11,111]' -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(ARRAY_CONCAT(@__ints_0, c["Ints"])) = 2) """); @@ -1394,7 +1394,7 @@ public override Task Column_collection_Union_parameter_collection(bool async) """ @__ints_0='[11,111]' -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(SetUnion(c["Ints"], @__ints_0)) = 2) """); @@ -1408,7 +1408,7 @@ public override Task Column_collection_Intersect_inline_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(SetIntersect(c["Ints"], [11, 111])) = 2) """); @@ -1431,7 +1431,7 @@ public override Task Column_collection_Where_Union(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(SetUnion(ARRAY( SELECT VALUE i @@ -1450,7 +1450,7 @@ public override Task Column_collection_equality_parameter_collection(bool async) """ @__ints_0='[1,10]' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Ints"] = @__ints_0) """); @@ -1466,7 +1466,7 @@ public override Task Column_collection_Concat_parameter_collection_equality_inli """ @__ints_0='[1,10]' -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_CONCAT(c["Ints"], @__ints_0) = [1,11,111,1,10]) """); @@ -1480,7 +1480,7 @@ public override Task Column_collection_equality_inline_collection(bool async) AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Ints"] = [1,10]) """); @@ -1497,7 +1497,7 @@ public override Task Column_collection_equality_inline_collection_with_parameter @__i_0='1' @__j_1='10' -SELECT c +SELECT VALUE c FROM root c WHERE (c["Ints"] = [@__i_0, @__j_1]) """); @@ -1511,7 +1511,7 @@ public override Task Column_collection_Where_equality_inline_collection(bool asy AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY( SELECT VALUE i @@ -1542,7 +1542,7 @@ public override Task Parameter_collection_in_subquery_Union_column_collection(bo """ @__Skip_0='[111]' -SELECT c +SELECT VALUE c FROM root c WHERE (ARRAY_LENGTH(SetUnion(@__Skip_0, c["Ints"])) = 3) """); @@ -1609,7 +1609,7 @@ public override Task Project_collection_of_ints_simple(bool async) AssertSql( """ -SELECT c["Ints"] +SELECT VALUE c["Ints"] FROM root c ORDER BY c["Id"] """); @@ -1627,10 +1627,10 @@ public override async Task Project_collection_of_ints_ordered(bool async) AssertSql( """ -SELECT ARRAY( +SELECT VALUE ARRAY( SELECT VALUE i FROM i IN c["Ints"] - ORDER BY i DESC) AS c + ORDER BY i DESC) FROM root c ORDER BY c["Id"] """); @@ -1645,10 +1645,10 @@ public override Task Project_collection_of_datetimes_filtered(bool async) AssertSql( """ -SELECT ARRAY( +SELECT VALUE ARRAY( SELECT VALUE d FROM d IN c["DateTimes"] - WHERE (DateTimePart("dd", d) != 1)) AS c + WHERE (DateTimePart("dd", d) != 1)) FROM root c ORDER BY c["Id"] """); @@ -1698,9 +1698,9 @@ public override Task Project_collection_of_ints_with_distinct(bool async) AssertSql( """ -SELECT ARRAY( +SELECT VALUE ARRAY( SELECT DISTINCT VALUE i - FROM i IN c["Ints"]) AS c + FROM i IN c["Ints"]) FROM root c ORDER BY c["Id"] """); @@ -1726,12 +1726,11 @@ public override Task Project_collection_of_ints_with_ToList_and_FirstOrDefault(b { await base.Project_collection_of_ints_with_ToList_and_FirstOrDefault(a); - // TODO: Improve SQL, #34081 AssertSql( """ -SELECT ARRAY( +SELECT VALUE ARRAY( SELECT VALUE i - FROM i IN c["Ints"]) AS c + FROM i IN c["Ints"]) FROM root c ORDER BY c["Id"] OFFSET 0 LIMIT 1 @@ -1771,7 +1770,6 @@ public override async Task Project_multiple_collections(bool async) Assert.Equal(HttpStatusCode.BadRequest, exception.StatusCode); - // TODO: Improve SQL, #34081 AssertSql( """ SELECT VALUE @@ -1827,7 +1825,7 @@ public override Task Project_inline_collection(bool async) // The following should be SELECT VALUE [c["String"], "foo"], #33779 AssertSql( """ -SELECT [c["String"], "foo"] AS c +SELECT VALUE [c["String"], "foo"] FROM root c """); }); @@ -1863,7 +1861,7 @@ public override Task Nested_contains_with_Lists_and_no_inferred_type_mapping(boo @__strings_1='["one","two","three"]' @__ints_0='[1,2,3]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__strings_1, (ARRAY_CONTAINS(@__ints_0, c["Int"]) ? "one" : "two")) """); @@ -1880,7 +1878,7 @@ public override Task Nested_contains_with_arrays_and_no_inferred_type_mapping(bo @__strings_1='["one","two","three"]' @__ints_0='[1,2,3]' -SELECT c +SELECT VALUE c FROM root c WHERE ARRAY_CONTAINS(@__strings_1, (ARRAY_CONTAINS(@__ints_0, c["Int"]) ? "one" : "two")) """); @@ -1901,7 +1899,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE IS_DEFINED(c["Ints"][2]) """); @@ -1920,7 +1918,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Ints"][2] ?? 999) = 999) """); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTestBase.cs b/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTestBase.cs index f7b0aba7adb..2c84d5fae0c 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTestBase.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/QueryLoggingCosmosTestBase.cs @@ -45,7 +45,7 @@ public virtual async Task Queryable_simple() CosmosResources.LogExecutingSqlQuery(new TestLogger()).GenerateMessage( "NorthwindContext", "None", "", Environment.NewLine, """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """), @@ -57,7 +57,7 @@ FROM root c CosmosResources.LogExecutingSqlQuery(new TestLogger()).GenerateMessage( "NorthwindContext", "?", "", Environment.NewLine, """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] = "Customer") """), @@ -91,7 +91,7 @@ public virtual async Task Queryable_with_parameter_outputs_parameter_value_loggi CosmosResources.LogExecutingSqlQuery(new TestLogger()).GenerateMessage( "NorthwindContext", "None", "@__city_0='Redmond'", Environment.NewLine, """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_0)) """), @@ -103,7 +103,7 @@ FROM root c CosmosResources.LogExecutingSqlQuery(new TestLogger()).GenerateMessage( "NorthwindContext", "?", "@__city_0=?", Environment.NewLine, """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Discriminator"] = "Customer") AND (c["City"] = @__city_0)) """), diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryTest.cs index 6ddb72653f8..ff923b54676 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/ReadItemPartitionKeyQueryTest.cs @@ -24,7 +24,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c """); } @@ -38,7 +38,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c """); } @@ -53,7 +53,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["PartitionKey1"] = "PK1") AND (c["PartitionKey2"] = 1)) """); @@ -69,7 +69,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE CONTAINS(c["Payload"], "3") """); @@ -88,7 +88,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c """); } @@ -103,7 +103,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c """); } @@ -132,7 +132,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["PartitionKey"] = "PK2") """); @@ -149,7 +149,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["PartitionKey"] = "PK1") """); @@ -247,7 +247,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE ((c["Id"] = 1) AND (c["Id"] = 2)) """); @@ -272,7 +272,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Id"] = 1) """); @@ -328,7 +328,7 @@ await AssertQuery( AssertSql( """ -SELECT c +SELECT VALUE c FROM root c WHERE (c["Discriminator"] IN ("SharedContainerEntity2", "SharedContainerEntity2Child") AND (c["Id"] = 4)) """);