Repository navigation
fix(reads): read dotted names as nested paths in orderBy, lookup and indexes - #91
Merged
Merged
Conversation
…onour declared dotted names first
Upd4ting
force-pushed
the
fix/dotted-paths
branch
from
November 13, 2026 08:56
b9e49bb to
dd3417e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
orderBy("title.fr"),lookup(other, localKey, "title.fr")and an index{ fields: ["title.fr"] }read a top-level key literally namedtitle.frinstead of thefrmember oftitle. Localized and_internalsorts and lookups therefore answered wrong on postgres: every row tied in a sort, and a lookup found nothing. The mysql benchmark (AntelopeJS/mysqlbench/RESULTS.md) marks these postgres rows ✗. ANT-2089.Summary
A dotted name now reads a nested path, with the rule AntelopeJS/mysql uses. A field declared under the exact name wins. Otherwise the name is a path below its first segment, which may be a declared JSON field (
title.fr) or an undeclared key (_internal.data.title.fr).NamedField(source, name)inrow-source.tsis the one reading.IndexColumns(orderBy,getAll,between,group) and the other key oflookupread through it.NamedFieldover the table's own columns. The index expression is therefore the expression the read compiles to, and the planner uses it.name.frovername: "string") reads throughto_jsonb, which is not IMMUTABLE, and always reads NULL. Registration refuses it with a clear message, as mysql does.datemember below a declared field reads through atimestamptzcast, which is not IMMUTABLE. Its index keys on the stored JSON member, with a JSON null read as absent. It builds and enforcesunique, and serves no read._id, undeclared keys, GIN,crossInstancetwins) are byte-identical tomain, so no deployed index rebuilds except those over dotted names.docs/storage.mddocuments the rule;docs/errors.mdlists the new refusal and the reworded reserved-column message.@antelopejs/interface-databaserises to>=0.3.3 <0.4.0, the release of feat(staged-query): read dotted index fields, orderBy names and lookup keys as nested paths interface-database#87 that carries the shareddotted_pathsconformance suite.flowchart LR N["name: 'title.fr'"] --> D{"declared under<br/>the exact name?"} D -- yes --> C["that column"] D -- no --> P["source.field('title')<br/>then member 'fr'"] C --> R["read: orderBy / getAll / between /<br/>group / lookup other key"] P --> R C --> I["index key DDL"] P --> I I --> X{"IMMUTABLE?"} X -- "path below a scalar" --> F["refused at registration"] X -- "date member" --> J["key on stored JSON member"] X -- yes --> S["same expression as the read:<br/>index serves it"]Related issue
ANT-2089. The shared contract and conformance suite come from ANT-2090 (AntelopeJS/interface-database#87).
Verification
src/test/nested-paths.test.ts, run withpnpm exec ajs module test . -f dist/test/nested-paths.test.js.Before (
origin/mainsource, same test file):After:
The two tests that pass on
mainguard regressions of the fix rather than the original bug. The plan test fails when the reads move to the nested path and the DDL does not: the index then no longer matches the read. The null test fails when the date key drops itsNULLIF: two rows without a date then conflict underunique. Both were checked by patching the builtdist.Shared conformance suite
dotted_pathsfrom@antelopejs/interface-database0.3.3 (-f node_modules/@antelopejs/interface-database/dist/tests/dotted_paths.test.js):origin/main1 passing, 6 failing; this branch 7 passing, 0 failing.src/test/unit/ddl.spec.tsadds the refusal of a path below a scalar or a date member, and a declared dotted field (_id.x) keying on its own column.pnpm run checks:Checks: 11 passed, 0 failed.Upgrade notes for the release
uniqueone fails to rebuild if the nested values hold duplicates; the previous index keeps serving and the failure is logged.orderBy,getAll,between,groupand alookupother key no longer read a top-level key literally nameda.bfrom_extra; they read thebmember ofa.name.frovername: "string") is now refused at registration. Its index never served a read.Checklist