Skip to content

Commit ec76ec9

Browse files
committed
fix: bugs when filtering by device identifier and org
1 parent b071a1b commit ec76ec9

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/repositories/planter.repository.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ export class PlanterRepository extends UtilsRepositoryMixin<
5050
if (deviceIdentifier === null) {
5151
return `LEFT JOIN planter_registrations
5252
ON planter.id=planter_registrations.planter_id
53-
WHERE (planter_registrations.device_identifier ISNULL)
54-
GROUP BY planter.id`;
53+
WHERE (planter_registrations.device_identifier ISNULL)`;
5554
}
5655
return `JOIN planter_registrations
5756
ON planter.id=planter_registrations.planter_id
58-
WHERE (planter_registrations.device_identifier='${deviceIdentifier}')
59-
GROUP BY planter.id`;
57+
WHERE (planter_registrations.device_identifier='${deviceIdentifier}')`;
6058
}
6159

6260
// default .find() wasn't applying the org filters
@@ -72,10 +70,9 @@ export class PlanterRepository extends UtilsRepositoryMixin<
7270

7371
try {
7472
if (this.dataSource.connector) {
75-
const columnNames = this.dataSource.connector.buildColumnNames(
76-
'Planter',
77-
filter,
78-
);
73+
const columnNames = this.dataSource.connector
74+
.buildColumnNames('Planter', filter)
75+
.replace('"id"', 'planter.id as "id"');
7976

8077
let selectStmt;
8178
if (deviceIdentifier) {

0 commit comments

Comments
 (0)