feat: support memo filter for mysql and postgres

This commit is contained in:
johnnyjoy
2025-02-03 17:14:53 +08:00
parent 0f8b7b7fe6
commit e0e735d14d
12 changed files with 670 additions and 87 deletions

View File

@@ -30,26 +30,3 @@ func Parse(filter string, opts ...cel.EnvOption) (expr *exprv1.ParsedExpr, err e
}
return cel.AstToParsedExpr(ast)
}
// GetConstValue returns the constant value of the expression.
func GetConstValue(expr *exprv1.Expr) (any, error) {
v, ok := expr.ExprKind.(*exprv1.Expr_ConstExpr)
if !ok {
return nil, errors.New("invalid constant expression")
}
switch v.ConstExpr.ConstantKind.(type) {
case *exprv1.Constant_StringValue:
return v.ConstExpr.GetStringValue(), nil
case *exprv1.Constant_Int64Value:
return v.ConstExpr.GetInt64Value(), nil
case *exprv1.Constant_Uint64Value:
return v.ConstExpr.GetUint64Value(), nil
case *exprv1.Constant_DoubleValue:
return v.ConstExpr.GetDoubleValue(), nil
case *exprv1.Constant_BoolValue:
return v.ConstExpr.GetBoolValue(), nil
default:
return nil, errors.New("unexpected constant type")
}
}