fix(db-postgres): sort by localized fields (#8839)
### What? Fixes https://github.com/payloadcms/payload/issues/5152 issue related to sorting by a localized field with SQLite / Postgres database adapters. ### Why? It was an incorrect behaviour. ### How? Modifies the `getTableColumnFromPath` file to have correct join conditions. Previously if you had this structure in the _locales table _locale title parent en A 1 es B 1 we sorted by everything that's here, but we need to sort only by the passed locale. Additionally fixes a typescript error in `dev.ts` that I added here https://github.com/payloadcms/payload/pull/8834 Also, removes the condition with `joins.length` in `countDistinct`. It was there as for this issue https://github.com/payloadcms/payload/issues/4889 because sorting by a localized property caused duplication. This can simnifically improve performance for `.find` with nested querying/sorting on large data sets, because `count(*)` is faster than `count(DISTINCT id)`
This commit is contained in:
@@ -53,6 +53,7 @@ if (args.o) {
|
||||
|
||||
const port = process.env.PORT ? Number(process.env.PORT) : 3000
|
||||
|
||||
// @ts-expect-error the same as in test/helpers/initPayloadE2E.ts
|
||||
const app = nextImport({
|
||||
dev: true,
|
||||
hostname: 'localhost',
|
||||
|
||||
Reference in New Issue
Block a user