diff --git a/src/sql/utils/utils.test.ts b/src/sql/utils/utils.test.ts index a07047e..ad88b3b 100644 --- a/src/sql/utils/utils.test.ts +++ b/src/sql/utils/utils.test.ts @@ -12,6 +12,7 @@ describe('filterQuery', () => { const scopedVars: Record = { $simple: 'foo', + $numeric: 123, $multiple: ['foo', 'bar'], }; // simplified version of getTemplateSrv().replace @@ -35,6 +36,15 @@ describe('applySQLTemplateVariables', () => { expect(res.rawSQL).toEqual('select * from foo'); }); + it('should replace a numeric var', () => { + const res = applySQLTemplateVariables( + { ...mockQuery, rawSQL: 'select * from $numeric' }, + scopedVars, + getTemplateSrv + ); + expect(res.rawSQL).toEqual('select * from 123'); + }); + it('should replace a multiple var', () => { const res = applySQLTemplateVariables( { ...mockQuery, rawSQL: 'select * from foo where var in ($multiple)' }, diff --git a/src/sql/utils/utils.ts b/src/sql/utils/utils.ts index 81b7cba..b08e08f 100644 --- a/src/sql/utils/utils.ts +++ b/src/sql/utils/utils.ts @@ -22,7 +22,7 @@ export function applySQLTemplateVariables( } function interpolateVariable(value: string | string[]) { - if (typeof value === 'string') { + if (typeof value === 'string' || typeof value === 'number') { return value; }