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

Function getVariableAndValueFromExpr

backend/store/filter.go:9–36  ·  view source on GitHub ↗
(expr celast.Expr)

Source from the content-addressed store, hash-verified

7)
8
9func getVariableAndValueFromExpr(expr celast.Expr) (string, any) {
10 var variable string
11 var value any
12 for _, arg := range expr.AsCall().Args() {
13 switch arg.Kind() {
14 case celast.IdentKind:
15 variable = arg.AsIdent()
16 case celast.SelectKind:
17 // Handle member selection like "labels.environment"
18 sel := arg.AsSelect()
19 if sel.Operand().Kind() == celast.IdentKind {
20 variable = fmt.Sprintf("%s.%s", sel.Operand().AsIdent(), sel.FieldName())
21 }
22 case celast.LiteralKind:
23 value = arg.AsLiteral().Value()
24 case celast.ListKind:
25 list := []any{}
26 for _, e := range arg.AsList().Elements() {
27 if e.Kind() == celast.LiteralKind {
28 list = append(list, e.AsLiteral().Value())
29 }
30 }
31 value = list
32 default:
33 }
34 }
35 return variable, value
36}

Callers 11

GetListDatabaseFilterFunction · 0.70
GetListSheetFilterFunction · 0.70
GetListProjectFilterFunction · 0.70
GetListRolloutFilterFunction · 0.70
GetListGroupFilterFunction · 0.70
GetSearchAuditLogsFilterFunction · 0.70
GetListPlanFilterFunction · 0.70
GetListAccessGrantFilterFunction · 0.70
GetListInstanceFilterFunction · 0.70
GetAccountListFilterFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected