Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos: Apply projection in post processor #23412

Merged
1 commit merged into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public CosmosQueryTranslationPostprocessor(
public override Expression Process(Expression query)
{
query = base.Process(query);

if (query is ShapedQueryExpression shapedQueryExpression
&& shapedQueryExpression.QueryExpression is SelectExpression selectExpression)
{
// Cosmos does not have nested select expression so this should be safe.
selectExpression.ApplyProjection();
}

query = new CosmosValueConverterCompensatingExpressionVisitor(_sqlExpressionFactory).Visit(query);

return query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery
{
case SelectExpression selectExpression:

selectExpression.ApplyProjection();

shaperBody = new CosmosProjectionBindingRemovingExpressionVisitor(
selectExpression, jObjectParameter,
QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.TrackAll)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public virtual void Where_conditional_bool_with_value_conversion_is_used()
Assert.Equal("http://blog.com", result.Url);
}

[ConditionalFact(Skip = "Issue #21142")]
[ConditionalFact]
public virtual void Select_conditional_bool_with_value_conversion_is_used()
{
using var context = CreateContext();
Expand Down
2 changes: 2 additions & 0 deletions test/EFCore.Specification.Tests/LazyLoadProxyTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,8 @@ public virtual void Top_level_projection_track_entities_before_passing_to_client
orderby p.Id
select DtoFactory.CreateDto(p)).FirstOrDefault();

RecordLog();

Assert.NotNull(((dynamic)query).Single);
}

Expand Down
12 changes: 4 additions & 8 deletions test/EFCore.Specification.Tests/OptimisticConcurrencyTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,8 @@ public virtual Task
null);
}

[ConditionalFact(Skip = "Many-to-many relationships are not supported without CLR class for join table.")]
// TODO: See issue#1368
public virtual Task
Attempting_to_delete_same_relationship_twice_for_many_to_many_results_in_independent_association_exception()
[ConditionalFact(Skip = "Issue#23411")]
public virtual Task Attempting_to_delete_same_relationship_twice_for_many_to_many_results_in_independent_association_exception()
{
return ConcurrencyTestAsync(
c =>
Expand All @@ -292,10 +290,8 @@ public virtual Task
null);
}

[ConditionalFact(Skip = "Many-to-many relationships are not supported without CLR class for join table.")]
// TODO: See issue#1368
public virtual Task
Attempting_to_add_same_relationship_twice_for_many_to_many_results_in_independent_association_exception()
[ConditionalFact(Skip = "Issue#23411")]
public virtual Task Attempting_to_add_same_relationship_twice_for_many_to_many_results_in_independent_association_exception()
{
return ConcurrencyTestAsync(
c =>
Expand Down
2 changes: 1 addition & 1 deletion test/EFCore.Specification.Tests/StoreGeneratedTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void ValueGenerationNegative<TKey, TEntity, TConverter>()
Assert.Throws<NotSupportedException>(() => context.Add(new TEntity())).Message);
}

[ConditionalFact(Skip = "Issue#15589")]
[ConditionalFact]
public virtual void Value_generation_works_for_common_GUID_conversions()
{
ValueGenerationPositive<Guid, GuidToString>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,17 +433,21 @@ FROM [Child] AS [c]
}
}

[ConditionalFact(Skip = "Issue#1015")]
[ConditionalFact]
public override void Top_level_projection_track_entities_before_passing_to_client_method()
{
base.Top_level_projection_track_entities_before_passing_to_client_method();

Assert.Equal(
@"@__p_0='707' (Nullable = true)
@"SELECT TOP(1) [p].[Id], [p].[AlternateId], [p].[Discriminator]
FROM [Parent] AS [p]
ORDER BY [p].[Id]

@__p_0='707' (Nullable = true)

SELECT [c].[Id], [c].[ParentId]
FROM [Child] AS [c]
WHERE [c].[ParentId] = @__p_0",
SELECT [s].[Id], [s].[ParentId]
FROM [Single] AS [s]
WHERE [s].[ParentId] = @__p_0",
Sql,
ignoreLineEndingDifferences: true);
}
Expand Down
8 changes: 5 additions & 3 deletions test/EFCore.Tests/ChangeTracking/Internal/QueryFixupTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -888,18 +888,20 @@ public void Query_owned()
});
}

[ConditionalFact(Skip = "Issue #16752")]
[ConditionalFact]
public void Query_subowned()
{
Seed();

using var context = new QueryFixupContext();
var subDependent1 = context.Set<Order>()
.Include(a => a.OrderDetails.BillingAddress.OrderDetails.Order)
.Select(o => o.OrderDetails.BillingAddress)
.Include(a => a.OrderDetails.Order).Single();
.Single();
var subDependent2 = context.Set<Order>()
.Include(a => a.OrderDetails.ShippingAddress.OrderDetails.Order)
.Select(o => o.OrderDetails.ShippingAddress)
.Include(a => a.OrderDetails.Order).Single();
.Single();

AssertFixup(
context,
Expand Down