influxdb: influxql: make measurement-autocomplete case insensitive (#34563)

pull/34297/head^2
Gábor Farkas 4 years ago committed by GitHub
parent 8d05df83ed
commit e21b90681f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      public/app/plugins/datasource/influxdb/query_builder.ts
  2. 6
      public/app/plugins/datasource/influxdb/specs/query_builder.test.ts

@ -44,7 +44,8 @@ export class InfluxQueryBuilder {
} else if (type === 'MEASUREMENTS') {
query = 'SHOW MEASUREMENTS';
if (withMeasurementFilter) {
query += ' WITH MEASUREMENT =~ /' + kbn.regexEscape(withMeasurementFilter) + '/';
// we do a case-insensitive regex-based lookup
query += ' WITH MEASUREMENT =~ /(?i)' + kbn.regexEscape(withMeasurementFilter) + '/';
}
} else if (type === 'FIELDS') {
measurement = this.target.measurement;

@ -56,13 +56,13 @@ describe('InfluxQueryBuilder', () => {
it('should have WITH MEASUREMENT in measurement query for non-empty query with no tags', () => {
const builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
const query = builder.buildExploreQuery('MEASUREMENTS', undefined, 'something');
expect(query).toBe('SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ LIMIT 100');
expect(query).toBe('SHOW MEASUREMENTS WITH MEASUREMENT =~ /(?i)something/ LIMIT 100');
});
it('should escape the regex value in measurement query', () => {
const builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
const query = builder.buildExploreQuery('MEASUREMENTS', undefined, 'abc/edf/');
expect(query).toBe('SHOW MEASUREMENTS WITH MEASUREMENT =~ /abc\\/edf\\// LIMIT 100');
expect(query).toBe('SHOW MEASUREMENTS WITH MEASUREMENT =~ /(?i)abc\\/edf\\// LIMIT 100');
});
it('should have WITH MEASUREMENT WHERE in measurement query for non-empty query with tags', () => {
@ -71,7 +71,7 @@ describe('InfluxQueryBuilder', () => {
tags: [{ key: 'app', value: 'email' }],
});
const query = builder.buildExploreQuery('MEASUREMENTS', undefined, 'something');
expect(query).toBe('SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ WHERE "app" = \'email\' LIMIT 100');
expect(query).toBe('SHOW MEASUREMENTS WITH MEASUREMENT =~ /(?i)something/ WHERE "app" = \'email\' LIMIT 100');
});
it('should have where condition in measurement query for query with tags', () => {

Loading…
Cancel
Save