Skip to content

Commit 19274e3

Browse files
authored
Merge pull request #29 from GridProtectionAlliance/FixQueryEditor
Fixed Bug causing WHERE not being applied
2 parents 670a40b + 138d9e5 commit 19274e3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/datasource.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ export class DataSource extends DataSourceApi<OpenHistorianQuery, OpenHistorianD
7171
query.fieldNames = ["*"];
7272
}
7373

74+
const queryCondition = (query.condition?.length ?? 0) === 0 ? "" : ` WHERE ${getTemplateSrv().replace(query.condition, options.scopedVars)}`;
75+
7476
let data = await getBackendSrv().post(this.url + "/Search", {
7577
dataTypeIndex: -1 /* unrestricted search */,
76-
expression: `SELECT DISTINCT ${query.fieldNames} FROM ${query.tableName} ${query.condition?.length ?? 0 === 0 ? "" : ` WHERE ${query.condition}`}`
78+
expression: `SELECT DISTINCT ${query.fieldNames} FROM ${query.tableName} ${queryCondition}`
7779
})
7880
return data.map((s: string) => ({ text: s }));
7981
}

0 commit comments

Comments
 (0)