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

Group-By Attributes not returned in Aggregated Query #48

Open
bwmodular opened this issue Jun 7, 2022 · 6 comments · May be fixed by DynamicsValue/fake-xrm-easy-core#30
Open

Group-By Attributes not returned in Aggregated Query #48

bwmodular opened this issue Jun 7, 2022 · 6 comments · May be fixed by DynamicsValue/fake-xrm-easy-core#30
Labels
bug Something isn't working scope-core

Comments

@bwmodular
Copy link

Here's a fetchXml query. It returns the count of 'work notification jobs', grouped by technician name, number and id.
image

When run against a real (d365 online) instance, the grouped by columns are returned in the query:
image
When run against FakeXrmEasy v1,2 or 3 the AttributeCollection returned by the query only contains the count, but not the group by columns:
image

I'm not sure if this a known issue from v1. I can provide a failing test if required, using OOB entities.

@jordimontana82 jordimontana82 added bug Something isn't working scope-core labels Jun 9, 2022
@bwmodular
Copy link
Author

Here's a unit test for this with OOB attrbutes. It fails because the grouped by column doesn't appear in the resultset.

It's the equivalent of this SQL query:

select count(*), so.name
from salesorderdetail sod
, salesorder so
where sod.salesorderid = so.salesorderid
group by so.name;

The 'name' column does not appear in the results of the query.
Issue48.zip

@BetimBeja
Copy link

@jordimontana82 @bwmodular the following test works:

[Fact]
public void When_An_Aggregated_Query_Contains_Group_By_On_Base_Attributes_These_Should_Be_Returned_In_The_Query_Results()
{
    EntityCollection records = _service.RetrieveMultiple(new FetchExpression(@"<fetch aggregate='true'>
                          <entity name='salesorderdetail'>
                            <attribute name='salesorderdetailid' alias='count' aggregate='count' />                                 
                            <attribute name='lineitemnumber' alias='lineitemnumber' groupby='true' />                                     
                          </entity>
                        </fetch>"));

    Assert.Equal(1, (int)((AliasedValue)records.Entities[0]["lineitemnumber"]).Value);
}

which means the problem is only limited to groupby applied to linked entities

BetimBeja added a commit to BetimBeja/dynamicsvalue-fake-xrm-easy-core that referenced this issue Dec 23, 2022
@filcole
Copy link

filcole commented Dec 24, 2022

Might be the same as jordimontana82/fake-xrm-easy#482 in v1.

@BetimBeja
Copy link

BetimBeja commented Dec 24, 2022

@filcole I think I didn't solve that problem with my PR... if that is the case do you mind issuing a PR against https://github.com/BetimBeja/dynamicsvalue-fake-xrm-easy-core/tree/fix/2x/issue-48 which would add your commits to DynamicsValue/fake-xrm-easy-core#30 ?

I wrote a blog about the process some time ago: https://xrm.al/blog/co-author-github

BetimBeja added a commit to BetimBeja/dynamicsvalue-fake-xrm-easy-core that referenced this issue Dec 25, 2022
BetimBeja added a commit to BetimBeja/dynamicsvalue-fake-xrm-easy-core that referenced this issue Dec 25, 2022
@BetimBeja
Copy link

Confirmed that the bug you raised on v1 is not fixed with DynamicsValue/fake-xrm-easy-core#30
image

@jordimontana82
Copy link
Contributor

Thanks lads @filcole @BetimBeja @bwmodular

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working scope-core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants