fix: scaffolder total query

fixes scaffolder list error with postgres: error: select count("tasks"."id")
as "count" from "tasks" order by "created_at" desc - column
"tasks.created_at" must appear in the GROUP BY clause or be used
in an aggregate function

Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
Heikki Hellgren
2024-10-16 07:38:22 +03:00
parent d066d53c58
commit 6aa5b986b5
2 changed files with 8 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend': patch
---
Fix tasks listing with postgres
@@ -213,6 +213,9 @@ export class DatabaseTaskStore implements TaskStore {
queryBuilder.whereIn('status', [...new Set(arr)]);
}
const countQuery = queryBuilder.clone();
countQuery.count('tasks.id', { as: 'count' });
if (order) {
order.forEach(f => {
queryBuilder.orderBy(f.field, f.order);
@@ -221,9 +224,6 @@ export class DatabaseTaskStore implements TaskStore {
queryBuilder.orderBy('created_at', 'desc');
}
const countQuery = queryBuilder.clone();
countQuery.count('tasks.id', { as: 'count' });
if (pagination?.limit !== undefined) {
queryBuilder.limit(pagination.limit);
}