Skip to content

Commit 3d158e4

Browse files
committed
Fix macro bindings
1 parent 89488c2 commit 3d158e4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/datasource.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,14 @@ export class JsonDataSource extends DataSourceApi<JsonApiQuery, JsonApiDataSourc
145145
.forEach((v) => {
146146
bindings[v.name] = v.value;
147147
});
148-
149-
bindings["__unixEpochFrom"] = range.from.unix().toString()
150-
bindings["__unixEpochTo"] = range.to.unix().toString()
151-
bindings["__isoFrom"] = range.from.unix().toISOString()
152-
bindings["__isoTo"] = range.to.unix().toISOString()
153-
148+
149+
if (range) {
150+
bindings['__unixEpochFrom'] = range.from.valueOf();
151+
bindings['__unixEpochTo'] = range.to.valueOf();
152+
bindings['__isoFrom'] = range.from.toISOString();
153+
bindings['__isoTo'] = range.to.toISOString();
154+
}
155+
154156
const result = expression.evaluate(json, bindings);
155157

156158
// Ensure that we always return an array.

0 commit comments

Comments
 (0)