Skip to content

Commit

Permalink
fix: bugs when filtering by device identifier and org
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynndp committed Nov 8, 2021
1 parent b071a1b commit ec76ec9
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/repositories/planter.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit ec76ec9

Please sign in to comment.