MCPcopy Create free account
hub / github.com/bytebase/bytebase / resolveCompareExpr

Function resolveCompareExpr

frontend/src/plugins/cel/logic/resolve.ts:169–198  ·  view source on GitHub ↗
(expr: CELExpr)

Source from the content-addressed store, hash-verified

167};
168
169const resolveCompareExpr = (expr: CELExpr): CompareExpr => {
170 const callExpr =
171 expr.exprKind?.case === "callExpr" ? expr.exprKind.value : null;
172 if (!callExpr)
173 throw new Error(`Expected callExpr but got ${expr.exprKind?.case}`);
174 const operator = callExpr.function as CompareOperator;
175 const [factorExpr, valueExpr] = callExpr.args;
176 const factor = getFactorName(factorExpr);
177 if (isNumberFactor(factor)) {
178 return {
179 type: ExprType.Condition,
180 operator,
181 args: [factor, getConstantInt64Value(valueExpr)],
182 };
183 }
184 if (isTimestampFactor(factor)) {
185 return {
186 type: ExprType.Condition,
187 operator,
188 args: [
189 factor,
190 valueExpr.exprKind?.case === "callExpr" &&
191 valueExpr.exprKind.value.args[0]?.exprKind?.case === "constExpr"
192 ? new Date(getConstantStringValue(valueExpr.exprKind.value.args[0]))
193 : new Date(),
194 ],
195 };
196 }
197 throw new Error(`cannot resolve expr ${JSON.stringify(expr)}`);
198};
199
200const resolveStringExpr = (
201 expr: CELExpr,

Callers 1

dfsFunction · 0.85

Calls 5

isNumberFactorFunction · 0.90
isTimestampFactorFunction · 0.90
getFactorNameFunction · 0.85
getConstantInt64ValueFunction · 0.85
getConstantStringValueFunction · 0.85

Tested by

no test coverage detected