From 299f9087c816ad73e785f0fc3b2482433bdd0e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ida=20=C5=A0tambuk?= Date: Mon, 11 Nov 2024 12:00:52 +0100 Subject: [PATCH] Bugfix: Account for template variables that resolve to a number, prepare 2.9.10 (#323) --- CHANGELOG.md | 11 +++++++++++ cspell.config.json | 3 ++- package.json | 2 +- src/DataSource.test.ts | 6 +++--- src/DataSource.ts | 14 +++++--------- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34c44941..24992854 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ All notable changes to this project will be documented in this file. +## 2.9.10 + +- Bugfix: Account for template variable being a number +- Chore: update dependabot config (#317) +- Dependency updates: + - Upgrade grafana-plugin-sdk-go (deps): Bump github.com/grafana/grafana-plugin-sdk-go from 0.251.0 to 0.258.0 in [#314](https://github.com/grafana/timestream-datasource/pull/314),[#315](https://github.com/grafana/timestream-datasource/pull/315), [#319](https://github.com/grafana/timestream-datasource/pull/319) + - Updates github.com/aws/aws-sdk-go from 1.51.31 to 1.55.5 in [#319](https://github.com/grafana/timestream-datasource/pull/319) + - Updates github.com/grafana/grafana-aws-sdk from 0.31.2 to 0.31.3 in [#319](https://github.com/grafana/timestream-datasource/pull/319) + - Updates actions/checkout from 2 to 4 in [#318](https://github.com/grafana/timestream-datasource/pull/318) + - Updates tibdex/github-app-token from 1.8.0 to 2.1.0 in [#318](https://github.com/grafana/timestream-datasource/pull/318) + ## 2.9.9 - Fix "Wait for All Queries" toggle in [#313](https://github.com/grafana/timestream-datasource/pull/313) diff --git a/cspell.config.json b/cspell.config.json index defb852f..ecd029d2 100644 --- a/cspell.config.json +++ b/cspell.config.json @@ -95,6 +95,7 @@ "otelhttptrace", "otelgrpc", "sqlutil", - "errorsource" + "errorsource", + "tibdex" ] } diff --git a/package.json b/package.json index 1cb09aad..1f720c24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grafana-timestream-datasource", - "version": "2.9.9", + "version": "2.9.10", "description": "Load data timestream in grafana", "scripts": { "build": "webpack -c ./.config/webpack/webpack.config.ts --env production", diff --git a/src/DataSource.test.ts b/src/DataSource.test.ts index 44a57407..ecfd9759 100644 --- a/src/DataSource.test.ts +++ b/src/DataSource.test.ts @@ -46,7 +46,7 @@ describe('DataSource', () => { expect(res.rawQuery).toEqual(`select * from foo where var in ('foo','bar')`); }); - it('should replace __interval interpolated variables with their original string', () => { + it('should return number variables', () => { mockDatasource.applyTemplateVariables( { ...mockQuery, rawQuery: 'select $__interval_ms, $__interval' }, { @@ -55,8 +55,8 @@ describe('DataSource', () => { } ); // check rawQuery.replace is called with correct interval value - expect(replaceMock.mock.calls[3][1].__interval).toEqual({ value: '$__interval' }); - expect(replaceMock.mock.calls[3][1].__interval_ms).toEqual({ value: '$__interval_ms' }); + expect(replaceMock.mock.calls[3][1].__interval).toEqual({ value: 50000 }); + expect(replaceMock.mock.calls[3][1].__interval_ms).toEqual({ value: 5000000 }); }); }); }); diff --git a/src/DataSource.ts b/src/DataSource.ts index a82383cd..6c8796c7 100644 --- a/src/DataSource.ts +++ b/src/DataSource.ts @@ -55,11 +55,15 @@ export class DataSource extends DataSourceWithBackend { + private interpolateVariable = (value: string | string[] | number) => { if (typeof value === 'string') { return value; } + if (typeof value === 'number') { + return value; + } + const quotedValues = value.map((v) => { return this.quoteLiteral(v); }); @@ -76,14 +80,6 @@ export class DataSource extends DataSourceWithBackend