mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 04:59:15 -06:00
suggest operators depending on datatype
This commit is contained in:
parent
28f97a2450
commit
8e4db8cc3a
@ -1,6 +1,23 @@
|
||||
export class PostgresMetaQuery {
|
||||
constructor(private target, private queryModel) {}
|
||||
|
||||
getOperators(datatype: string) {
|
||||
switch (datatype) {
|
||||
case 'float4':
|
||||
case 'float8': {
|
||||
return ['=', '!=', '<', '<=', '>', '>='];
|
||||
}
|
||||
case 'text':
|
||||
case 'varchar':
|
||||
case 'char': {
|
||||
return ['=', '!=', '<', '<=', '>', '>=', 'IN', 'NOT IN', 'LIKE', 'NOT LIKE', '~', '~*', '!~', '!~*'];
|
||||
}
|
||||
default: {
|
||||
return ['=', '!=', '<', '<=', '>', '>=', 'IN', 'NOT IN'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// quote identifier as literal to use in metadata queries
|
||||
quoteIdentAsLiteral(value) {
|
||||
return this.queryModel.quoteLiteral(this.queryModel.unquoteIdentifier(value));
|
||||
|
@ -493,7 +493,7 @@ export class PostgresQueryCtrl extends QueryCtrl {
|
||||
.catch(this.handleQueryError.bind(this));
|
||||
}
|
||||
case 'op':
|
||||
return this.$q.when(this.uiSegmentSrv.newOperators(['=', '!=', '<', '<=', '>', '>=', 'IN', 'NOT IN']));
|
||||
return this.$q.when(this.uiSegmentSrv.newOperators(this.metaBuilder.getOperators(part.datatype)));
|
||||
default:
|
||||
return this.$q.when([]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user