Feature Description
The Problem
My use case is that I want to get results from Typeorm based on an array of IDs after I've filtered and ordered my items in an Elastic Search query. My main WHERE clause is queryBuilder.andWhere('vendor.id IN (:ids)', { ids }).
I tried ordering by the same array of IDs like so:
queryBuilder.orderBy(`FIELD(\`vendor\`.\`id\`, ${ids.join(',')})`)
...but the query builder insists on putting ASC or DESC at the end of the ORDER BY so the query fails. If I get the raw query with getSql(), remove the ASC at the end, and try to run it manually it works correctly.
The Solution
I guess some kind of mechanism to specify an order other than ASC or DESC or some kind of way to omit this part completely so that we can use custom MySQL functions like ORDER BY FIELD(id, 53, 644, 7491, 666).
Relevant Database Driver(s)
Are you willing to resolve this issue by submitting a Pull Request?
Feature Description
The Problem
My use case is that I want to get results from Typeorm based on an array of IDs after I've filtered and ordered my items in an Elastic Search query. My main WHERE clause is
queryBuilder.andWhere('vendor.id IN (:ids)', { ids }).I tried ordering by the same array of IDs like so:
...but the query builder insists on putting
ASCorDESCat the end of theORDER BYso the query fails. If I get the raw query withgetSql(), remove theASCat the end, and try to run it manually it works correctly.The Solution
I guess some kind of mechanism to specify an order other than
ASCorDESCor some kind of way to omit this part completely so that we can use custom MySQL functions likeORDER BY FIELD(id, 53, 644, 7491, 666).Relevant Database Driver(s)
aurora-data-apiaurora-data-api-pgbetter-sqlite3cockroachdbcordovaexpomongodbmysqlnativescriptoraclepostgresreact-nativesapsqlitesqlite-abstractsqljssqlserverAre you willing to resolve this issue by submitting a Pull Request?