{"record":{"id":"a979414e702b8c90","repo":"cayleygraph/cayley","slug":"cannot-find-quad-v-in-query-output-columns-v","errorCode":null,"errorMessage":"cannot find quad %v in query output (columns: %v)","messagePattern":"cannot find quad (.+?) in query output \\(columns: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/sql/iterator.go","lineNumber":198,"sourceCode":"\tfor i := range pointers {\n\t\tpointers[i] = &nodes[i]\n\t}\n\tif err := r.Scan(pointers...); err != nil {\n\t\tit.err = err\n\t\treturn false\n\t}\n\tit.tags = make(map[string]graph.Ref)\n\tfor i, name := range it.cols {\n\t\tif !strings.Contains(name, tagPref) {\n\t\t\tit.tags[name] = nodes[i].ValueHash\n\t\t}\n\t}\n\tif len(it.cind) > 1 {\n\t\tvar q QuadHashes\n\t\tfor _, d := range quad.Directions {\n\t\t\ti, ok := it.cind[d]\n\t\t\tif !ok {\n\t\t\t\tit.err = fmt.Errorf(\"cannot find quad %v in query output (columns: %v)\", d, it.cols)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tq.Set(d, nodes[i].ValueHash)\n\t\t}\n\t\tit.res = q\n\t\treturn true\n\t}\n\ti, ok := it.cind[quad.Any]\n\tif !ok {\n\t\tit.err = fmt.Errorf(\"cannot find node hash in query output (columns: %v, cind: %v)\", it.cols, it.cind)\n\t\treturn false\n\t}\n\tit.res = nodes[i]\n\treturn true\n}\n\nfunc (it *iteratorBase) Err() error {\n\treturn it.err","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/sql/iterator.go#L180-L216","documentation":"In scanValue, when the iterator expects a full quad (multiple column indexes in it.cind), each quad direction (subject/predicate/object/label) must map to a query output column. This error means a required direction column is missing from the SELECT result, so the quad cannot be reconstructed. It is stored in it.err and aborts the scan.","triggerScenarios":"Running a Next/NextPath/Contains on a SQL iterator built with a Select that requests quad directions, where the query result columns (it.cols) lack a column for one of the directions.","commonSituations":"Custom or hand-built Select statements whose column set doesn't match the directions the iterator expects; schema/column aliasing changes after an upgrade; queries optimized away a direction.","solutions":["Inspect the printed columns list and ensure your Select requests a column for every quad direction used.","Build Selects via the library's helper methods rather than hand-crafting column lists.","Check for version mismatches between the store schema and the library expecting per-direction columns."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"for it.Next(ctx) { }\nif it.Err() != nil {\n    if strings.Contains(it.Err().Error(), \"cannot find quad\") {\n        // rebuild the Select with all quad direction columns\n    }\n}","preventionTips":["Build Selects with the library's query-building helpers, never hand-crafted column lists.","Ensure every quad direction used by the iterator has a corresponding output column.","Keep the DB schema in sync with the library version."],"tags":["sql","iterator","column-mapping"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}