Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: support not contains operator in cel expression (#17780)
ecmadao3f1831e5029b
diff --git a/frontend/src/components/ExprEditor/components/OperatorSelect.vue b/frontend/src/components/ExprEditor/components/OperatorSelect.vueindex 3f4d7dcfef..5791402bce 100644--- a/frontend/src/components/ExprEditor/components/OperatorSelect.vue+++ b/frontend/src/components/ExprEditor/components/OperatorSelect.vue@@ -50,6 +50,7 @@ const OPERATOR_DICT = new Map([["_>=_", "≥"],["_>_", ">"],["@not_in", "not in"],+ ["@not_contains", "not contains"],]);const options = computed(() => {diff --git a/frontend/src/plugins/cel/logic/build.ts b/frontend/src/plugins/cel/logic/build.tsindex ab85d453a6..4716992882 100644--- a/frontend/src/plugins/cel/logic/build.ts+++ b/frontend/src/plugins/cel/logic/build.ts@@ -72,6 +72,15 @@ export const buildCELExpr = async (if (isStringExpr(condition)) {const { operator, args } = condition;const [factor, value] = args;+ if (operator === "@not_contains") {+ return wrapCallExpr("!_", [+ wrapCallExpr(+ "contains",+ [wrapConstExpr(value)],+ wrapIdentExpr(factor)+ ),+ ]);+ }return wrapCallExpr(operator,[wrapConstExpr(value)],diff --git a/frontend/src/plugins/cel/logic/resolve.ts b/frontend/src/plugins/cel/logic/resolve.tsindex 0093e38cf2..e62dd89620 100644--- a/frontend/src/plugins/cel/logic/resolve.ts+++ b/frontend/src/plugins/cel/logic/resolve.ts@@ -109,7 +109,7 @@ export const resolveCELExpr = (expr: CELExpr): SimpleExpr => {return resolveCompareExpr(expr);}if (isStringOperator(operator)) {- return resolveStringExpr(expr);+ return resolveStringExpr(expr, negative);}if (isCollectionOperator(operator)) {return resolveCollectionExpr(expr, negative);@@ -179,12 +179,18 @@ const resolveCompareExpr = (expr: CELExpr): CompareExpr => {throw new Error(`cannot resolve expr ${JSON.stringify(expr)}`);};-const resolveStringExpr = (expr: CELExpr): StringExpr => {+const resolveStringExpr = (+ expr: CELExpr,+ negative: boolean = false+): StringExpr => {const callExpr =expr.exprKind?.case === "callExpr" ? expr.exprKind.value : null;if (!callExpr)throw new Error(`Expected callExpr but got ${expr.exprKind?.case}`);- const operator = callExpr.function as StringOperator;+ let operator = callExpr.function as StringOperator;+ if (negative && operator == "contains") {+ operator = "@not_contains";+ }const factor = getFactorName(callExpr.target!);const value = callExpr.args[0];return {@@ -203,7 +209,7 @@ const resolveCollectionExpr = (if (!callExpr)throw new Error(`Expected callExpr but got ${expr.exprKind?.case}`);let operator = callExpr.function as CollectionOperator;- if (negative) {+ if (negative && operator == "@in") {operator = "@not_in";}const [factorExpr, valuesExpr] = callExpr.args;diff --git a/frontend/src/plugins/cel/types/operator.ts b/frontend/src/plugins/cel/types/operator.tsindex 32318291eb..df5f238544 100644--- a/frontend/src/plugins/cel/types/operator.ts+++ b/frontend/src/plugins/cel/types/operator.ts@@ -39,6 +39,8 @@ export type CollectionOperator = (typeof CollectionOperatorList)[number];export const StringOperatorList = ["contains",+ "@not_contains",+ "matches","matches","startsWith","endsWith",