MCPcopy
hub / github.com/kashav/fsql / applyModifiers

Method applyModifiers

query/modifier.go:23–55  ·  view source on GitHub ↗

applyModifiers iterates through each SELECT attribute for this query and applies the associated modifier to the attribute's output value.

(path string, info os.FileInfo)

Source from the content-addressed store, hash-verified

21// applyModifiers iterates through each SELECT attribute for this query
22// and applies the associated modifier to the attribute's output value.
23func (q *Query) applyModifiers(path string, info os.FileInfo) (map[string]interface{}, error) {
24 results := make(map[string]interface{}, len(q.Attributes))
25
26 for _, attribute := range q.Attributes {
27 value, err := transform.DefaultFormatValue(attribute, path, info)
28 if err != nil {
29 return map[string]interface{}{}, err
30 }
31
32 if _, ok := q.Modifiers[attribute]; !ok {
33 results[attribute] = value
34 continue
35 }
36
37 for _, m := range q.Modifiers[attribute] {
38 value, err = transform.Format(&transform.FormatParams{
39 Attribute: attribute,
40 Path: path,
41 Info: info,
42 Value: value,
43 Name: m.Name,
44 Args: m.Arguments,
45 })
46 if err != nil {
47 return map[string]interface{}{}, err
48 }
49 }
50
51 results[attribute] = value
52 }
53
54 return results, nil
55}

Callers 1

walkFuncMethod · 0.95

Calls 2

DefaultFormatValueFunction · 0.92
FormatFunction · 0.92

Tested by

no test coverage detected