Don't do value suggestions for numeric and timestamp

This commit is contained in:
Sven Klemm 2018-08-16 11:47:45 +02:00
parent 735c4abe6c
commit 8ced29a0e7
2 changed files with 21 additions and 5 deletions

View File

@ -143,7 +143,6 @@ WHERE
) s ) s
WHERE EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = s.schema) WHERE EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = s.schema)
) )
LIMIT 1
`; `;
query += ' AND table_name = ' + this.quoteIdentAsLiteral(this.target.table); query += ' AND table_name = ' + this.quoteIdentAsLiteral(this.target.table);
query += ' AND column_name = ' + this.quoteIdentAsLiteral(column); query += ' AND column_name = ' + this.quoteIdentAsLiteral(column);

View File

@ -474,10 +474,22 @@ export class PostgresQueryCtrl extends QueryCtrl {
.then(this.transformToSegments({})) .then(this.transformToSegments({}))
.catch(this.handleQueryError.bind(this)); .catch(this.handleQueryError.bind(this));
case 'right': case 'right':
return this.datasource if (['int4', 'int8', 'float4', 'float8', 'timestamp', 'timestamptz'].indexOf(part.datatype) > -1) {
.metricFindQuery(this.metaBuilder.buildValueQuery(part.params[0])) // don't do value lookups for numerical fields
.then(this.transformToSegments({ addTemplateVars: true, templateQuoter: this.queryModel.quoteLiteral })) return this.$q.when([]);
.catch(this.handleQueryError.bind(this)); } else {
return this.datasource
.metricFindQuery(this.metaBuilder.buildValueQuery(part.params[0]))
.then(
this.transformToSegments({
addTemplateVars: true,
templateQuoter: (v: string) => {
return this.queryModel.quoteLiteral(v);
},
})
)
.catch(this.handleQueryError.bind(this));
}
case 'op': case 'op':
return this.$q.when(this.uiSegmentSrv.newOperators(['=', '!=', '<', '<=', '>', '>=', 'IN', 'NOT IN'])); return this.$q.when(this.uiSegmentSrv.newOperators(['=', '!=', '<', '<=', '>', '>=', 'IN', 'NOT IN']));
default: default:
@ -485,6 +497,11 @@ export class PostgresQueryCtrl extends QueryCtrl {
} }
} }
case 'part-param-changed': { case 'part-param-changed': {
this.datasource.metricFindQuery(this.metaBuilder.buildDatatypeQuery(part.params[0])).then((d: any) => {
if (d.length === 1) {
part.datatype = d[0].text;
}
});
this.panelCtrl.refresh(); this.panelCtrl.refresh();
break; break;
} }