getJSONPath is used for the #> and #>> operators.
(j DJSON, ary DArray)
| 364 | |
| 365 | // getJSONPath is used for the #> and #>> operators. |
| 366 | func 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 | |
| 386 | func newCannotMixBitArraySizesError(op string) error { |
| 387 | return pgerror.Newf(pgcode.StringDataLengthMismatch, |
no test coverage detected
searching dependent graphs…