diff --git a/README.md b/README.md index 1798cf6..509574f 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,6 @@ const paginateConfig: PaginateConfig { /** * Required: false * Type: 'first' | 'last' - * Default: 'first' * Description: (ONLY WORKS WITH POSTGRES) Define whether to put null values * at the beginning or end of the result set. */ diff --git a/src/paginate.spec.ts b/src/paginate.spec.ts index 3cb919c..804954a 100644 --- a/src/paginate.spec.ts +++ b/src/paginate.spec.ts @@ -425,23 +425,6 @@ describe('paginate', () => { expect(result.data).toStrictEqual(expectedResult) }) - it('should put null values first when nullSort is not specified', async () => { - const config: PaginateConfig = { - sortableColumns: ['age', 'createdAt'], - defaultSortBy: [['age', 'ASC']], - } - const query: PaginateQuery = { - path: '', - } - - const result = await paginate(query, catRepo, config) - - const expectedCats = cats.slice() - - expect(result.meta.sortBy).toStrictEqual([['age', 'ASC']]) - expect(result.data).toStrictEqual(expectedCats.reverse()) - }) - it('should sort result by multiple columns', async () => { const config: PaginateConfig = { sortableColumns: ['name', 'color'], diff --git a/src/paginate.ts b/src/paginate.ts index fa162b0..c55563e 100644 --- a/src/paginate.ts +++ b/src/paginate.ts @@ -100,8 +100,6 @@ export async function paginate( const queryBuilder = repo instanceof Repository ? repo.createQueryBuilder('__root') : repo - const isPostgres = ['postgres', 'cockroachdb'].includes(queryBuilder.connection.options.type) - if (repo instanceof Repository && !config.relations && config.loadEagerRelations === true) { if (!config.relations) { FindOptionsUtils.joinEagerRelations(queryBuilder, queryBuilder.alias, repo.metadata) @@ -143,7 +141,7 @@ export async function paginate( } } - let nullSort: 'NULLS LAST' | 'NULLS FIRST' | undefined = isPostgres ? 'NULLS FIRST' : undefined + let nullSort: 'NULLS LAST' | 'NULLS FIRST' | undefined = undefined if (config.nullSort) { nullSort = config.nullSort === 'last' ? 'NULLS LAST' : 'NULLS FIRST' } @@ -238,7 +236,7 @@ export async function paginate( parameters: [alias, `:${property.column}`], } - if (isPostgres) { + if (['postgres', 'cockroachdb'].includes(queryBuilder.connection.options.type)) { condition.parameters[0] = `CAST(${condition.parameters[0]} AS text)` }