{"record":{"id":"e0824c34f907f077","repo":"dgraph-io/dgraph","slug":"equal-not-supported-for-type-v","errorCode":null,"errorMessage":"Equal not supported for type: %v","messagePattern":"Equal not supported for type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"types/sort.go","lineNumber":244,"sourceCode":"\t// point at which consecutive floats are more than 1 apart).\n\tif a.Tid == FloatID {\n\t\treturn a.Value.(float64) < float64(b.Value.(int64))\n\t}\n\tx.AssertTrue(b.Tid == FloatID)\n\treturn float64(a.Value.(int64)) < b.Value.(float64)\n}\n\n// Equal returns true if a is equal to b.\nfunc Equal(a, b Val) (bool, error) {\n\tif a.Tid != b.Tid {\n\t\treturn false, errors.Errorf(\"Arguments of different type can not be compared.\")\n\t}\n\ttyp := a.Tid\n\tswitch typ {\n\tcase DateTimeID, IntID, FloatID, StringID, DefaultID, BoolID, BigFloatID:\n\t\t// Don't do anything, we can sort values of this type.\n\tdefault:\n\t\treturn false, errors.Errorf(\"Equal not supported for type: %v\", a.Tid)\n\t}\n\treturn equal(a, b), nil\n}\n\nfunc equal(a, b Val) bool {\n\tif a.Tid != b.Tid {\n\t\treturn false\n\t}\n\tswitch a.Tid {\n\tcase DateTimeID:\n\t\taVal, aOk := a.Value.(time.Time)\n\t\tbVal, bOk := b.Value.(time.Time)\n\t\treturn aOk && bOk && aVal.Equal(bVal)\n\tcase IntID:\n\t\taVal, aOk := a.Value.(int64)\n\t\tbVal, bOk := b.Value.(int64)\n\t\treturn aOk && bOk && aVal == bVal\n\tcase FloatID:","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/types/sort.go#L226-L262","documentation":"Once types.Equal establishes that both values share a Tid, it only supports equality testing for DateTime, Int, Float, String, Default, Bool and BigFloat. Equality on other types (Uid, binary, etc.) is not defined here and triggers this error.","triggerScenarios":"Calling types.Equal on same-typed Vals whose Tid is outside the supported set — notably UidID or BinaryID values, e.g. checking equality of two uid Vals through CompareVals or during pagination.","commonSituations":"Filtering on uid equality through the generic value-comparison path; comparing binary/encrypted values; generic filter code that routes all predicate types through Equal without special-casing uids.","solutions":["Compare uids directly as uint64 values instead of via types.Equal","Restrict the generic Equal path to supported scalar types and special-case others in your code","Convert binary values to a supported type (e.g. string/Default) before comparing","Check the predicate's schema type and use the appropriate comparison helper"],"exampleFix":"// before\nok, err := types.Equal(a, b) // a.Tid == types.UidID -> error\n// after\nvar ok bool\nif a.Tid == types.UidID {\n    ok = a.Value.(uint64) == b.Value.(uint64)\n} else {\n    ok, err = types.Equal(a, b)\n}","handlingStrategy":"type-guard","validationCode":"switch a.Tid {\ncase types.UidID, types.BinaryID:\n    return fmt.Errorf(\"equality for %s handled separately\", a.Tid)\n}\nok, err := types.Equal(a, b)","typeGuard":"func equalitySupported(v types.Val) bool {\n    switch v.Tid {\n    case types.DateTimeID, types.IntID, types.FloatID, types.StringID, types.DefaultID, types.BoolID, types.BigFloatID:\n        return true\n    }\n    return false\n}","tryCatchPattern":"ok, err := types.Equal(a, b)\nif err != nil {\n    if strings.Contains(err.Error(), \"Equal not supported\") {\n        // special-case: compare uids as uint64 or bytes.Equal for binary\n    }\n    return err\n}","preventionTips":["Compare uids directly via uint64, not through types.Equal","Route binary values through bytes.Equal instead of the generic path","Filter unsupported types out of generic filter/compare pipelines"],"tags":["equality","types","unsupported-type","dgraph"],"backgroundTag":"unsupported-operation-for-type","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}