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

Function parseExpression

backend/api/v1/common.go:122–140  ·  view source on GitHub ↗
(expr string)

Source from the content-addressed store, hash-verified

120}
121
122func parseExpression(expr string) (Expression, error) {
123 // Split the expression by " " to get the key, comparator and val.
124 re := regexp.MustCompile(`\s+`)
125 words := re.Split(strings.TrimSpace(expr), -1)
126 if len(words) != 3 {
127 return Expression{}, errors.Errorf("invalid expression %q", expr)
128 }
129
130 comparator, err := getComparatorType(words[1])
131 if err != nil {
132 return Expression{}, err
133 }
134
135 return Expression{
136 Key: words[0],
137 Operator: comparator,
138 Value: words[2],
139 }, nil
140}
141
142func getComparatorType(op string) (OperatorType, error) {
143 switch op {

Callers 1

ParseFilterFunction · 0.85

Calls 2

getComparatorTypeFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected