Skip to content

Commit 138d9e5

Browse files
committed
Added Variable Substitution in Variable Query
1 parent e200b50 commit 138d9e5

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)