Skip to content

sortBy a VirtualColumn broken in pgsql #997

@Helveg

Description

@Helveg

Due to an upstream issue in TypeORM sorting by home.countCat is broken in pgSQL:

for SELECT DISTINCT, ORDER BY expressions must appear in select list
QueryFailedError: for SELECT DISTINCT, ORDER BY expressions must appear in select list
    at PostgresQueryRunner.query (C:\Users\pwd06\git\nestjs-paginate\src\driver\postgres\PostgresQueryRunner.ts:299:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at SelectQueryBuilder.loadRawResults (C:\Users\pwd06\git\nestjs-paginate\src\query-builder\SelectQueryBuilder.ts:3800:25)
    at SelectQueryBuilder.getRawMany (C:\Users\pwd06\git\nestjs-paginate\src\query-builder\SelectQueryBuilder.ts:1626:29)
    at SelectQueryBuilder.executeEntitiesAndRawResults (C:\Users\pwd06\git\nestjs-paginate\src\query-builder\SelectQueryBuilder.ts:3467:34)
    at SelectQueryBuilder.getManyAndCount (C:\Users\pwd06\git\nestjs-paginate\src\query-builder\SelectQueryBuilder.ts:1873:36)
    at paginate (C:\Users\pwd06\git\nestjs-paginate\src\paginate.ts:393:32)
    at Object.<anonymous> (C:\Users\pwd06\git\nestjs-paginate\src\paginate.spec.ts:668:24)

Since the last commit in TypeORM is 7 months ago, it has 2k open issues, and 150 open PRs, I think it's fair to say that it is unmaintained.

I have my own fork of typeorm, where I have fixes related to virtual columns, including for this issue. We can switch back to the original TypeORM repository if their maintenance ever picks up again.

Since TypeORM is a peerDependency of ours, I'm not sure how we best explain/nudge to our users that they should install the fork @helveg/typeorm, instead of typeorm itself. Probably best to just leave a note in our README, and to leave a note on fixed upstream issues here that we're closing them because they're fixed in my fork

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions