'How can I order by a JSON field using TypeOrm while having a JOIN?

I'm trying to order the results by a JSON column while doing a JOIN but for some reason it is not working, here is the query:

const tasks = await connection
    .getRepository(Task)
    .createQueryBuilder("tasks")
    .innerJoin("tasks.owners", "owners")
    .where("owners.id = :ownerId", { ownerId })
    .orderBy(`tasks.payload->"$.similarPropUrl"`, 'ASC');

And here is the error I'm getting:

There was an error Cannot read properties of undefined (reading 'databaseName')

Weird enough, if I remove the JOIN the query works.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source