MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / preprocessForContains

Method preprocessForContains

pkg/util/json/contains.go:104–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102func (j jsonString) preprocessForContains() (containsable, error) { return containsableScalar{j}, nil }
103
104func (j jsonArray) preprocessForContains() (containsable, error) {
105 result := containsableArray{}
106 for _, e := range j {
107 switch e.Type() {
108 case ArrayJSONType:
109 preprocessed, err := e.preprocessForContains()
110 if err != nil {
111 return nil, err
112 }
113 result.arrays = append(result.arrays, preprocessed)
114 case ObjectJSONType:
115 preprocessed, err := e.preprocessForContains()
116 if err != nil {
117 return nil, err
118 }
119 result.objects = append(result.objects, preprocessed)
120 default:
121 preprocessed, err := e.preprocessForContains()
122 if err != nil {
123 return nil, err
124 }
125 result.scalars = append(result.scalars, preprocessed.(containsableScalar))
126 }
127 }
128
129 var err error
130 sort.Slice(result.scalars, func(i, j int) bool {
131 if err != nil {
132 return false
133 }
134 var c int
135 c, err = result.scalars[i].JSON.Compare(result.scalars[j].JSON)
136 return c == -1
137 })
138
139 if err != nil {
140 return nil, err
141 }
142
143 return result, nil
144}
145
146func (j jsonObject) preprocessForContains() (containsable, error) {
147 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