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

Method RemoveString

postgres/parser/json/json.go:1394–1417  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

1392}
1393
1394func (j jsonArray) RemoveString(s string) (JSON, bool, error) {
1395 b := NewArrayBuilder(j.Len())
1396 removed := false
1397 for _, el := range j {
1398 // We want to remove only elements of string type.
1399 if el.Type() == StringJSONType {
1400 t, err := el.AsText()
1401 if err != nil {
1402 return nil, false, err
1403 }
1404 if *t != s {
1405 b.Add(el)
1406 } else {
1407 removed = true
1408 }
1409 } else {
1410 b.Add(el)
1411 }
1412 }
1413 if removed {
1414 return b.Build(), removed, nil
1415 }
1416 return j, false, nil
1417}
1418
1419func (j jsonObject) RemoveString(s string) (JSON, bool, error) {
1420 idx, ok := findPairIndexByKey(j, s)

Callers

nothing calls this directly

Calls 6

LenMethod · 0.95
AddMethod · 0.95
BuildMethod · 0.95
NewArrayBuilderFunction · 0.85
TypeMethod · 0.65
AsTextMethod · 0.65

Tested by

no test coverage detected