Skip to content

Commit

Permalink
fix: handle invalid initial value in variable formatter (#36)
Browse files Browse the repository at this point in the history
There seems to be an issue present in older versions of Grafana, where a
wrong initial value is sent. This handles that edge case.

https://github.com/parseablehq/parseable-datasource/assets/49564025/8ef3dd77-88ba-48ef-be37-f0210db64016
  • Loading branch information
stanvanrooy authored Oct 24, 2023
1 parent c815e81 commit 58ad7c6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
}

private formatter(value: string | string[], options: any): string {
if (options.multi) {
if (options.multi && Array.isArray(value)) {
return (value as string[]).map(v => `'${v}'`).join(',');
} else if (options.multi) {
return `'${value}'`;
}
return value as string;
}
Expand Down

0 comments on commit 58ad7c6

Please sign in to comment.