MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / ResolveProjection

Function ResolveProjection

cmd/cql-proxy/resolver/resolver.go:64–90  ·  view source on GitHub ↗

ResolveProjection resolves projection object and returns project sql statement and dependent fields.

(p map[string]interface{}, availFields FieldMap)

Source from the content-addressed store, hash-verified

62
63// ResolveProjection resolves projection object and returns project sql statement and dependent fields.
64func ResolveProjection(p map[string]interface{}, availFields FieldMap) (fm FieldMap, statement string, err error) {
65 fm = FieldMap{}
66 var subStatements []string
67
68 for k, v := range p {
69 if !availFields[k] {
70 err = errors.Errorf("unknown field: %s", k)
71 return
72 }
73
74 if asBool(v) {
75 fm[k] = true
76 subStatements = append(subStatements, fmt.Sprintf(`"%s"`, k))
77 }
78 }
79
80 if len(subStatements) == 0 {
81 for k := range availFields {
82 fm[k] = true
83 subStatements = append(subStatements, fmt.Sprintf(`"%s"`, k))
84 }
85 }
86
87 statement = strings.Join(subStatements, ",")
88
89 return
90}
91
92func logicRelation(childQueries []map[string]interface{}, availFields FieldMap, op string) (
93 fields FieldMap, statement string, args []interface{}, err error) {

Callers 1

FindFunction · 0.85

Calls 2

asBoolFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected