Compare canonical paths by token spelling

This commit is contained in:
2026-10-09 03:23:08 +00:00
parent edc6660654
commit 9ac65ccc08
5 changed files with 151 additions and 16 deletions

View File

@@ -41,7 +41,7 @@ func (m Metadata) effectiveField(path Path) (FieldInfo, bool) {
}
pointer := path.String()
candidate, ok := m.effectivePaths[pointer]
if !ok || !matchesPathShapeWithPointer(path, candidate, pointer) {
if !ok || !matchesPathShape(path, candidate) {
return FieldInfo{}, false
}
info, ok := m.fields[pointer]
@@ -89,18 +89,14 @@ func (m Metadata) HistoricalPaths() []Path {
// Textual pointers are lookup keys, but explicit key/index kinds remain part of
// the query. Candidate paths are constructed from actual document containers.
func matchesPathShape(query, candidate Path) bool {
if !query.valid() {
return false
}
return matchesPathShapeWithPointer(query, candidate, query.String())
}
func matchesPathShapeWithPointer(query, candidate Path, pointer string) bool {
if pointer != candidate.String() || len(query.segments) != len(candidate.segments) {
if !query.valid() || len(query.segments) != len(candidate.segments) {
return false
}
for i, segment := range query.segments {
actual := candidate.segments[i]
if !pathTokenSpellingEqual(segment, actual) {
return false
}
if actual.kind == pathSegmentIndex {
index, ok := schemaIndex(segment)
if !ok || index != actual.index {