Skip to content

Select with function in where condition #802

@twavv

Description

@twavv

Is your feature request related to a problem? Please describe.
I'd like some way to query using a function as part of the where condition. Concretely, I have a unique index on UPPER(payload) for some table where the payload is case-insensitive, and I want to query using WHERE UPPER(payload) = UPPER($1) (obviously, the UPPER($1) can be done in the client side, so that's less of an issue here).

Describe the solution you'd like
Unclear what the API would be.

Describe alternatives you've considered
There is a querybuilder way of doing this, but it's not what I'm looking for here.

test('select with custom expression', async () => {
const qb1 = orm.em.createQueryBuilder(Book2);
qb1.select('*').where({ 'json_contains(`e0`.`meta`, ?)': [{ foo: 'bar' }] });
expect(qb1.getQuery()).toEqual('select `e0`.*, `e0`.price * 1.19 as `price_taxed` from `book2` as `e0` where json_contains(`e0`.`meta`, ?)');
expect(qb1.getParams()).toEqual(['{"foo":"bar"}']);

Additional context
Add any other context about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions