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

Function logicRelation

cmd/cql-proxy/resolver/resolver.go:92–129  ·  view source on GitHub ↗
(childQueries []map[string]interface{}, availFields FieldMap, op string)

Source from the content-addressed store, hash-verified

90}
91
92func logicRelation(childQueries []map[string]interface{}, availFields FieldMap, op string) (
93 fields FieldMap, statement string, args []interface{}, err error) {
94 fields = FieldMap{}
95
96 if len(childQueries) == 0 {
97 err = errors.New("$and/$or operator needs non-empty array")
98 return
99 }
100
101 var subStatements []string
102
103 for _, cq := range childQueries {
104 var (
105 childField FieldMap
106 childStatement string
107 childArgs []interface{}
108 )
109 childField, childStatement, childArgs, err = ResolveFilter(cq, availFields)
110 if err != nil {
111 return
112 }
113
114 if childStatement == "" {
115 continue
116 }
117
118 fields.Merge(childField)
119 subStatements = append(subStatements, childStatement)
120 args = append(args, childArgs...)
121 }
122
123 if len(subStatements) == 0 {
124 return
125 }
126
127 statement = "(" + strings.Join(subStatements, ") "+op+" (") + ")"
128 return
129}
130
131// ResolveFieldCondition resolves field condition object and returns as where condition statement.
132func ResolveFieldCondition(field string, v interface{}) (statement string, args []interface{}, err error) {

Callers 1

ResolveFilterFunction · 0.85

Calls 3

ResolveFilterFunction · 0.85
MergeMethod · 0.80
NewMethod · 0.65

Tested by

no test coverage detected