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

fix write document metadata properties for apply ComputeTransformatio… #1142

Merged
merged 4 commits into from Apr 5, 2018

Conversation

Projects
None yet
2 participants
@voronov-maxim
Contributor

voronov-maxim commented Apr 2, 2018

Description

When write response for query "OrderItems?$apply=compute(Count mul Price as Total,Id add OrderId as SumId)" compute properties not append metadata "@odata.context": "http://dummy/$metadata#OrderItems".

Response must be:
"@odata.context": "http://dummy/$metadata#OrderItems(Total,SumId)"

{
string computeProperties = string.Join(",", computeExpressions.Select(e => e.Alias));
if (!string.IsNullOrEmpty(computeProperties))
result = string.IsNullOrEmpty(result)

This comment has been minimized.

@AlanWong-MS

AlanWong-MS Apr 3, 2018

Contributor

Even though this is a single line within the if-statement, we prefer to still have the { } based on our style guide.

@@ -102,6 +104,15 @@ internal List<string> GetLastAggregatedPropertyNames()
: CreateAggregatePropertiesUriSegment(aggregateExpressions);
}
if (computeExpressions != null)
{
string computeProperties = string.Join(",", computeExpressions.Select(e => e.Alias));

This comment has been minimized.

@AlanWong-MS

AlanWong-MS Apr 3, 2018

Contributor

There's a build failure at this line:
src\Microsoft.OData.Core\UriParser\Aggregation\ApplyClause.cs(109,61): error CS1503: Argument 2: cannot convert from 'System.Collections.Generic.IEnumerable<string>' to 'string[]' [src\Microsoft.OData.Core\Build.Net35\Microsoft.OData.Core.NetFX35.csproj]

You may want to apply a .ToArray() at the end of the LINQ expression, similar to lines 93-94.

@AlanWong-MS

Thanks for the PR! Please review a couple of my comments. There's at least one build failure that we'll need to fix before we can merge.

mvoronov added some commits Apr 4, 2018

@AlanWong-MS

This comment has been minimized.

Contributor

AlanWong-MS commented Apr 4, 2018

Thanks for addressing my comments. It would be great if you're able to add a test case to cover your change; I don't think there were any existing tests. I think you may be able to add it to test\FunctionalTests\Microsoft.OData.Core.Tests\ScenarioTests\Writer\JsonLight\FullPayloadValidateTests.cs and use the existing ones as an example.

mvoronov

@AlanWong-MS AlanWong-MS merged commit 8a639ce into OData:master Apr 5, 2018

2 checks passed

continuous-integration/vsts The build trigger has fired.
Details
license/cla All CLA requirements met.
Details
@AlanWong-MS

This comment has been minimized.

Contributor

AlanWong-MS commented Apr 5, 2018

Thanks!

biaol-odata added a commit to biaol-odata/odata.net that referenced this pull request Jun 26, 2018

Fix metadata properties for apply ComputeTransformationNode (OData#1142)
- Fix write document metadata properties for apply ComputeTransformationNode
- Add corresponding test case

biaol-odata added a commit that referenced this pull request Jun 26, 2018

Fix metadata properties for apply ComputeTransformationNode (#1142)
- Fix write document metadata properties for apply ComputeTransformationNode
- Add corresponding test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment