From ec76ec9a0cdcb5290a2ec720c892404d6511cf63 Mon Sep 17 00:00:00 2001 From: Gwynn DP Date: Sun, 7 Nov 2021 11:14:44 -0800 Subject: [PATCH] fix: bugs when filtering by device identifier and org --- src/repositories/planter.repository.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/repositories/planter.repository.ts b/src/repositories/planter.repository.ts index fb97cc5d..e9332f43 100644 --- a/src/repositories/planter.repository.ts +++ b/src/repositories/planter.repository.ts @@ -50,13 +50,11 @@ export class PlanterRepository extends UtilsRepositoryMixin< if (deviceIdentifier === null) { return `LEFT JOIN planter_registrations ON planter.id=planter_registrations.planter_id - WHERE (planter_registrations.device_identifier ISNULL) - GROUP BY planter.id`; + WHERE (planter_registrations.device_identifier ISNULL)`; } return `JOIN planter_registrations ON planter.id=planter_registrations.planter_id - WHERE (planter_registrations.device_identifier='${deviceIdentifier}') - GROUP BY planter.id`; + WHERE (planter_registrations.device_identifier='${deviceIdentifier}')`; } // default .find() wasn't applying the org filters @@ -72,10 +70,9 @@ export class PlanterRepository extends UtilsRepositoryMixin< try { if (this.dataSource.connector) { - const columnNames = this.dataSource.connector.buildColumnNames( - 'Planter', - filter, - ); + const columnNames = this.dataSource.connector + .buildColumnNames('Planter', filter) + .replace('"id"', 'planter.id as "id"'); let selectStmt; if (deviceIdentifier) {