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

Method Compare

postgres/parser/json/json.go:477–506  ·  view source on GitHub ↗
(other JSON)

Source from the content-addressed store, hash-verified

475}
476
477func (j jsonArray) Compare(other JSON) (int, error) {
478 cmp := cmpJSONTypes(j.Type(), other.Type())
479 if cmp != 0 {
480 return cmp, nil
481 }
482 lenJ := j.Len()
483 lenO := other.Len()
484 if lenJ < lenO {
485 return -1, nil
486 }
487 if lenJ > lenO {
488 return 1, nil
489 }
490 // TODO(justin): we should optimize this, we don't have to decode the whole thing.
491 var err error
492 if other, err = decodeIfNeeded(other); err != nil {
493 return 0, err
494 }
495 o := other.(jsonArray)
496 for i := 0; i < lenJ; i++ {
497 cmp, err := j[i].Compare(o[i])
498 if err != nil {
499 return 0, err
500 }
501 if cmp != 0 {
502 return cmp, nil
503 }
504 }
505 return 0, nil
506}
507
508func (j jsonObject) Compare(other JSON) (int, error) {
509 cmp := cmpJSONTypes(j.Type(), other.Type())

Callers

nothing calls this directly

Calls 7

TypeMethod · 0.95
LenMethod · 0.95
cmpJSONTypesFunction · 0.85
decodeIfNeededFunction · 0.85
TypeMethod · 0.65
LenMethod · 0.65
CompareMethod · 0.65

Tested by

no test coverage detected