Skip to content

Commit ead15db

Browse files
author
Stefan Zwanenburg
committed
variable formatting: don't fail when query isn't available
Fixes #149
1 parent 84e132e commit ead15db

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/datasource/base.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,14 @@ function formatQuery(value: string | string[], variable: any): string {
368368
if (value.length === 0) {
369369
return '__empty__';
370370
}
371-
const fieldName = JSON.parse(variable.query).field;
371+
let fieldName;
372+
if (variable.query) {
373+
try {
374+
fieldName = JSON.parse(variable.query).field;
375+
} catch (error) {
376+
console.warn('Could not parse variable.query', variable.query);
377+
}
378+
}
372379
const quotedValues = value.map((val) => '"' + luceneEscape(val) + '"');
373380
// Quickwit query language does not support fieldName:(value1 OR value2 OR....)
374381
// like lucene does.

0 commit comments

Comments
 (0)