diff --git a/src/mixins/utils.repository-mixin.ts b/src/mixins/utils.repository-mixin.ts index 9bc70155..839788a8 100644 --- a/src/mixins/utils.repository-mixin.ts +++ b/src/mixins/utils.repository-mixin.ts @@ -80,7 +80,7 @@ export function UtilsRepositoryMixin< const planterIds = await this.getNonOrganizationPlanterIds(); // if planter repository request if (model === 'planter') { - return { id: { inq: planterIds } }; + return { planterId: { inq: planterIds } }; } else { // if trees or other repository request return { @@ -102,7 +102,7 @@ export function UtilsRepositoryMixin< return { or: [ { organizationId: { inq: entityIds } }, - { id: { inq: planterIds } }, + { planterId: { inq: planterIds } }, ], }; } else { 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) {