OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions [Bug] Datarid Filters, filter_by_having Not Working

This topic contains 4 replies, has 2 voices, and was last updated by  archy_bold 8 years ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34126

    archy_bold
    Participant

    Hi there. I’ve come across a weird scenario where one of my datagrid filters doesn’t work and it seems to be because filter_by_having isn’t working correctly, at least in my case. Here’s the important parts from my datagrid.yml file:

    So, as you can see, I’m trying to get all the order references for each customer into a column and then using that to filter on.

    All seems to work well until I try to filter and I get the following error:

    An exception occurred while executing 'SELECT count(t0_.id) AS sclr_0 FROM trueconn_customer t0_ LEFT JOIN trueconn_order t1_ ON t0_.id = t1_.customer_id AND (t1_.organization_id = 1) WHERE GROUP_CONCAT(t1_.order_reference SEPARATOR ' ') LIKE ? AND t0_.organization_id = 1' with params ["%uns%"]:

    SQLSTATE[HY000]: General error: 1111 Invalid use of group function (500 Internal Server Error)

    This query would work if the GROUP_CONCAT part was part of a HAVING statement rather than a WHERE, which I would think filter_by_having would do.

    Is it a bug or is there more I’m missing?

    Thanks,
    Simon

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #34127

    Yevhen Shyshkin
    Participant

    Hello, Simon.

    This is really weird case – I’ve tried to do exactly the same and it works for me:

    Please, make sure that cache is fresh (do app/console cache:clear in the appropriate environment) and try again. If issue still will be there – I’d like to ask for full grid configuration to reproduce this issue locally.

    #34128

    archy_bold
    Participant

    Thanks for the response Yevhen. I managed to solve it, actually. I dug a little deeper and saw it was working for me when using a COUNT. The difference here was that I added a groupBy to the datagrid configuration. So my datagrid looks as follows now:

    I guess you need to group your results in the case of using an aggregate function?

    #34129

    Yevhen Shyshkin
    Participant

    > I guess you need to group your results in the case of using an aggregate function?
    Yes, of course. MySQL maybe is a bit less strict in this case, but PostgreSQL will trigger an exception if you try to use having without grouping.

    #34130

    archy_bold
    Participant

    Ah, my stupidity there! Thanks for looking into it.

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

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top