Skip to content

Custom sort and filter field with no alias #720

@danielkv

Description

@danielkv

Is your feature request related to a problem? Please describe.
I'm trying to sort and filter by a field that's generated in selection, it's not on DB. But the system tries to put an alias which is not the case.

Describe the solution you'd like
It may be a good solution to define allowed sorting fields and filters and how those would work individually

Additional context
This is a custom selection I need to make

query.addSelect([
    "COMPANY_IS_OPEN(`meta`.`value`) as isOpen",
    "COMPANY_NEXT_OPEN_DATE(`meta`.`value`, NOW()) as nextOpen",
    "COMPANY_NEXT_CLOSE_DATE(`meta`.`value`) as nextClose",
   "COMPANY_ALLOW_BUY_CLOSED_BY_ID(`Company`.`id`) as allowBuyClosed",
]);

// order by (open | allowBuyClosed)
query.addOrderBy('isOpen OR (allowBuyClosed IS NOT NULL AND allowBuyClosed <> "false")', 'DESC');

I can't filter or sort by field isOpen or nextOpen

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions