mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
InfluxQL: Quoting tag values in the query editor (#54187)
* Quote numeric values in query editor
This commit is contained in:
parent
26524e3ff1
commit
6ed0787376
@ -19,8 +19,9 @@ function renderTagCondition(tag: { operator: any; value: string; condition: any;
|
||||
}
|
||||
}
|
||||
|
||||
// quote value unless regex or number, or if empty-string
|
||||
if (value === '' || (operator !== '=~' && operator !== '!~' && isNaN(+value))) {
|
||||
// quote value unless regex or empty-string
|
||||
// Influx versions before 0.13 had inconsistent requirements on if (numeric) tags are quoted or not.
|
||||
if (value === '' || (operator !== '=~' && operator !== '!~')) {
|
||||
value = "'" + value.replace(/\\/g, '\\\\').replace(/\'/g, "\\'") + "'";
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ describe('InfluxQueryBuilder', () => {
|
||||
undefined
|
||||
);
|
||||
const query = builder.buildExploreQuery('MEASUREMENTS');
|
||||
expect(query).toBe(`SHOW MEASUREMENTS WHERE "app" == 42 LIMIT 100`);
|
||||
expect(query).toBe(`SHOW MEASUREMENTS WHERE "app" == '42' LIMIT 100`);
|
||||
});
|
||||
|
||||
it('should handle tag-value=number-ish getting tag-keys', () => {
|
||||
@ -175,7 +175,7 @@ describe('InfluxQueryBuilder', () => {
|
||||
undefined
|
||||
);
|
||||
const query = builder.buildExploreQuery('TAG_KEYS');
|
||||
expect(query).toBe(`SHOW TAG KEYS WHERE "app" == 42`);
|
||||
expect(query).toBe(`SHOW TAG KEYS WHERE "app" == '42'`);
|
||||
});
|
||||
|
||||
it('should handle tag-value-contains-backslash-character getting tag-keys', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user