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

Method Compare

pkg/util/json/json.go:407–425  ·  view source on GitHub ↗
(other JSON)

Source from the content-addressed store, hash-verified

405}
406
407func (j jsonString) Compare(other JSON) (int, error) {
408 cmp := cmpJSONTypes(j.Type(), other.Type())
409 if cmp != 0 {
410 return cmp, nil
411 }
412 // TODO(justin): we should optimize this, we don't have to decode the whole thing.
413 var err error
414 if other, err = decodeIfNeeded(other); err != nil {
415 return 0, err
416 }
417 o := other.(jsonString)
418 if o > j {
419 return -1, nil
420 }
421 if o < j {
422 return 1, nil
423 }
424 return 0, nil
425}
426
427func (j jsonArray) Compare(other JSON) (int, error) {
428 cmp := cmpJSONTypes(j.Type(), other.Type())

Callers 1

slowContainsMethod · 0.95

Calls 4

TypeMethod · 0.95
cmpJSONTypesFunction · 0.85
decodeIfNeededFunction · 0.85
TypeMethod · 0.65

Tested by

no test coverage detected