OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

This topic contains 5 replies, has 2 voices, and was last updated by  Denis 6 years, 10 months ago.

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

  • Creator
    Topic
  • #34382

    Denis
    Participant

    Please help me.
    Can I use the RANK() or DENSE_RANK() functions in source of datagrid config?
    When I try I have an error
    An exception has been thrown during the rendering of a template ([Syntax Error] line 0, col 144: Error: Expected known function, got “DENSE_RANK”)

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #34383

    Mike Kudelya
    Participant

    Hi

    If you are using mysql, as far i know it doesn’t support these functions, but i found many articles where described how to emulate this functions.

    #34384

    Denis
    Participant

    Thanks Mike
    Sorry I did not clarify my question (
    I use Postgres
    and I want to have Rank in datagrid
    for example like this

    query:
    select:
    – product.brand
    – product.name
    – (SUM(product.totalcost)) as totalcost
    – (DENSE_RANK() OVER (ORDER BY SUM(product.totalcost) DESC)) as rank
    from:
    – { table: Extend\Entity\product, alias: product }

    It works for Postgres bat does not work for datagrid.

    #34385

    Mike Kudelya
    Participant

    Hi

    The doctrine by default doesn’t know about this function, but you can define it in your bundle via Resources/config/oro/app.yml (OroCRM 2.* version)

    1. Example of simple function, without DQL definition (function with only one ArithmeticPrimary argument):

    – src/Custom/Bundle/OroBundle/Resources/config/oro/app.yml

    – SQL definition: src/Oro/ORM/Query/AST/Platform/Functions/Mysql/Test.php

    2. Example of complex function, with DQL definition:

    – src/Custom/Bundle/OroBundle/Resources/config/oro/app.yml

    – DQL definition: src/Oro/ORM/Query/AST/Functions/DateTime/ConvertTz.php:

    SQL definition: src/Oro/ORM/Query/AST/Platform/Functions/Mysql/ConvertTz.php:

    I think you should use second variant, also please read the documentation about adding new functions.

    #34386

    Mike Kudelya
    Participant

    There you can find all functions that were created by our team: vendor/oro/doctrine-extensions/src/Oro/ORM/Query/AST

    #34387

    Denis
    Participant

    Thanks Mike

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

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

Back to top