Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

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

  • Creator
    Topic
  • #34291
    Denis
    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
  • #34318
    Mike Kudelya
    Mike Kudelya
    Oro Core

    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.

    #34335
    Denis
    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.

    #34390
    Mike Kudelya
    Mike Kudelya
    Oro Core

    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.

    #34392
    Mike Kudelya
    Mike Kudelya
    Oro Core

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

    #34480
    Denis
    Denis
    Participant

    Thanks Mike

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

You must be logged in to reply to this topic.

ssossossosso