MCPcopy Create free account
hub / github.com/dolthub/doltgresql / preprocessForContains

Method preprocessForContains

postgres/parser/json/contains.go:118–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116func (j jsonString) preprocessForContains() (containsable, error) { return containsableScalar{j}, nil }
117
118func (j jsonArray) preprocessForContains() (containsable, error) {
119 result := containsableArray{}
120 for _, e := range j {
121 switch e.Type() {
122 case ArrayJSONType:
123 preprocessed, err := e.preprocessForContains()
124 if err != nil {
125 return nil, err
126 }
127 result.arrays = append(result.arrays, preprocessed)
128 case ObjectJSONType:
129 preprocessed, err := e.preprocessForContains()
130 if err != nil {
131 return nil, err
132 }
133 result.objects = append(result.objects, preprocessed)
134 default:
135 preprocessed, err := e.preprocessForContains()
136 if err != nil {
137 return nil, err
138 }
139 result.scalars = append(result.scalars, preprocessed.(containsableScalar))
140 }
141 }
142
143 var err error
144 sort.Slice(result.scalars, func(i, j int) bool {
145 if err != nil {
146 return false
147 }
148 var c int
149 c, err = result.scalars[i].JSON.Compare(result.scalars[j].JSON)
150 return c == -1
151 })
152
153 if err != nil {
154 return nil, err
155 }
156
157 return result, nil
158}
159
160func (j jsonObject) preprocessForContains() (containsable, error) {
161 preprocessed := make(containsableObject, len(j))

Callers

nothing calls this directly

Calls 3

TypeMethod · 0.65
preprocessForContainsMethod · 0.65
CompareMethod · 0.65

Tested by

no test coverage detected