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

This commit is contained in:
Gábor Farkas
2021-05-24 12:24:42 +02:00
committed by GitHub
parent 8d05df83ed
commit e21b90681f
2 changed files with 5 additions and 4 deletions

View File

@@ -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;

View File

@@ -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', () => {