OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums OroCRM OroCRM – Programming Questions Problem With GROUP_CONCAT In Datagrid

This topic contains 8 replies, has 2 voices, and was last updated by  a.azadi 4 months, 2 weeks ago.

  • Creator
    Topic
  • #39151

    a.azadi
    Participant

    Hi everyone. I have a problem since 2 days ago. I have a Datagrid which has a GROUP_CONCAT in select. I have used this function so many time before. But this time I get an error which says can’t group on my field. I checked the DQL and it’s because my GROUP_CONCAT alias is in DQL group by!!!!!
    I know that it should not be there but I don’t why.

    My Datagrid:

    My Exception:

    Thank You,
    Aryana.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #39669
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    This is not a datagrid query itself but an automatically built query that counts records in the datagrid.

    You can define the count query manually by specifying “count_query” attribute in the “source” section of the datagrid configuration.
    As an example, see datagrids.yml in an EmailBundle.

    #39676

    a.azadi
    Participant

    Thank you very much for your help. I added this count_query to my datagrid. Like the example you gave me.

    I did not add the rest of code here because you can see the code in first post.
    But the code is in my datagrid.

    The count_query is not working. It’s not effecting and changing the default count_query. It’s like
    the count_query is not there.

    My ORO version is 1.8. Is this because of the ORO version? Or I have something not right in my code?

    Thanks again for your respond.

    • This reply was modified 4 months, 3 weeks ago by  a.azadi.
    #39708
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    Yes, unfortunately, it is because of the ORO version.

    Count query feature was introduced 3 years ago in “1.10.6-beta.4” version.

    You should consider upgrading.

    #39715

    a.azadi
    Participant

    Is there any other way to bypass this problem? maybe using listener or something else?

    #39746
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    The easiest workaround I can find here is decorating or overriding CountQueryBuilderOptimizer.
    Otherwise, it requires to backport too many classes, as I see.

    #39760

    a.azadi
    Participant

    Thanks for your help. Somehow I managed to edit the Count Query and I guess it is solved now. But now I have problem with the main query.

    The error is for another datagrid but I have same error for this datagrid too.

    #39765
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    Investigated an issue deeper and found that it was fixed in this commit by the selected line
    https://github.com/oroinc/platform/commit/b612efe82b93c6df875b74e2b8f5dc5d1e67c8c1#diff-51af6e720c7389ace895a6d42c0d9db1R71
    Group_by should not be added automatically for fields with GROUP_CONCAT.

    GroupByHelper is a service (oro_query_designer.group_by_helper) so you can extend it to override the protected method hasAggregate.

    #39832

    a.azadi
    Participant

    Thank you so much for your help and support. My problem is solved for now. I changed the code and added group_concat to the list and it works now.

    Like the code in Github

    Problem Solved.

Viewing 8 replies - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

You will be redirected to [title]. Would you like to continue?

Yes No