From ff2564900f86c9e524526322ee17ccf69c2bd47d Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Sat, 18 Aug 2018 12:34:19 +0200 Subject: [PATCH] only allow 1 filter macro in where clause --- public/app/plugins/datasource/postgres/query_ctrl.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/postgres/query_ctrl.ts b/public/app/plugins/datasource/postgres/query_ctrl.ts index b459880366d..8bd61a59493 100644 --- a/public/app/plugins/datasource/postgres/query_ctrl.ts +++ b/public/app/plugins/datasource/postgres/query_ctrl.ts @@ -535,7 +535,13 @@ export class PostgresQueryCtrl extends QueryCtrl { addWhereAction(part, index) { switch (this.whereAdd.type) { case 'macro': { - this.whereParts.push(sqlPart.create({ type: 'macro', name: this.whereAdd.value, params: [] })); + let partModel = sqlPart.create({ type: 'macro', name: this.whereAdd.value, params: [] }); + if (this.whereParts.length >= 1 && this.whereParts[0].def.type === 'macro') { + // replace current macro + this.whereParts[0] = partModel; + } else { + this.whereParts.splice(0, 0, partModel); + } break; } default: {