suggest operators depending on datatype

This commit is contained in:
Sven Klemm 2018-08-17 10:38:23 +02:00
parent 28f97a2450
commit 8e4db8cc3a
2 changed files with 18 additions and 1 deletions

View File

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

View File

@ -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([]);
}