mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
InfluxDB: Fix interpolation for floating point number values (#86396)
return number as it is
This commit is contained in:
parent
f3fd2de9dd
commit
635d85db7a
@ -508,6 +508,22 @@ describe('InfluxDataSource Frontend Mode', () => {
|
||||
const expectation = `(\\/special\\/path|\\/some\\/other\\/path)`;
|
||||
expect(result).toBe(expectation);
|
||||
});
|
||||
|
||||
it('should return floating point number as it is', () => {
|
||||
const variableMock = queryBuilder()
|
||||
.withId('tempVar')
|
||||
.withName('tempVar')
|
||||
.withMulti(false)
|
||||
.withOptions({
|
||||
text: `1.0`,
|
||||
value: `1.0`,
|
||||
})
|
||||
.build();
|
||||
const value = `1.0`;
|
||||
const result = ds.interpolateQueryExpr(value, variableMock, `select value / $tempVar from /^measurement$/`);
|
||||
const expectation = `1.0`;
|
||||
expect(result).toBe(expectation);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -315,6 +315,13 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
|
||||
return value;
|
||||
}
|
||||
|
||||
if (typeof value === 'string') {
|
||||
// Check the value is a number. If not run to escape special characters
|
||||
if (!isNaN(parseFloat(value))) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
// If template variable is a multi-value variable
|
||||
// we always want to deal with special chars.
|
||||
if (variable.multi) {
|
||||
|
Loading…
Reference in New Issue
Block a user