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

Function getJSONPath

pkg/sql/sem/tree/eval.go:366–384  ·  view source on GitHub ↗

getJSONPath is used for the #> and #>> operators.

(j DJSON, ary DArray)

Source from the content-addressed store, hash-verified

364
365// getJSONPath is used for the #> and #>> operators.
366func getJSONPath(j DJSON, ary DArray) (Datum, error) {
367 // TODO(justin): this is slightly annoying because we have to allocate
368 // a new array since the JSON package isn't aware of DArray.
369 path := make([]string, len(ary.Array))
370 for i, v := range ary.Array {
371 if v == DNull {
372 return DNull, nil
373 }
374 path[i] = string(MustBeDString(v))
375 }
376 result, err := json.FetchPath(j.JSON, path)
377 if err != nil {
378 return nil, err
379 }
380 if result == nil {
381 return DNull, nil
382 }
383 return &DJSON{result}, nil
384}
385
386func newCannotMixBitArraySizesError(op string) error {
387 return pgerror.Newf(pgcode.StringDataLengthMismatch,

Callers 1

eval.goFile · 0.85

Calls 2

FetchPathFunction · 0.92
MustBeDStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…