You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0e0b566
Browse filesBrowse the repository at this point in the historyBrowse files
fix(codegen-ts): honour an index's physical attributes, and gate the comments that delegate to a test by name
Two items, both about a guarantee that was stated but not kept.
INDEX SHAPE. The two index emitters were reconciled on NAME earlier in this stream; they
still disagreed on SHAPE, and the disagreement was invisible because it lived in attributes
codegen never read at all. `@expr`, `@using`, `@orders` and `@where` all reach migrate and
none reached this file:
- an @expr-only index emitted NOTHING, because both loops required a non-empty @fields
while migrate keys an expression index off @expr;
- @where never arrived, so a PARTIAL unique index read as a FULLY unique one — the
generated schema declares a constraint stricter than the database has, and
`drizzle-kit push` proposes replacing the real index with the wrong one;
- @orders was dropped, so a DESC index read as ASC.
The last one had a test pinning it. `index-lookup emits .on(table.customerId,
table.placedAt)` asserted the direction was ABSENT, over a fixture whose own comment says
"non-unique composite on customerId + placedAt DESC" and which sets @orders ["asc","desc"].
The fixture knew the intent and the assertion pinned the defect.
The two loops are now ONE function, because they were near-identical and migrate treats the
two shapes identically apart from uniqueness — a rule written twice is a rule that can be
forgotten twice, which is precisely how these attributes came to be honoured by neither.
Migrate's exact conventions are mirrored, including the two that look like details and are
not: a `btree` @using is omitted (migrate treats it as the default, so emitting it would be
a spurious difference) and an all-ascending @orders serializes as no orders at all (same
reason). sqlite drops @expr rather than emitting it wrong — its `.on()` takes columns, not
SQL, so the only available spelling would index a COLUMN instead of the expression, which is
a worse answer than an absent index. @where works on both dialects.
TEST-FILE REFERENCES. Six comments across two packages delegate a guarantee to
`secondary-index-name-parity.test.ts` by bare filename. Writing that is right — it swaps an
assertion the reader must trust for one they can run — but nothing connected the two, so a
rename would leave all six reading as live guarantees while pointing at nothing. That is
worse than never promising: the comment still tells the next reader the case is covered.
`scripts/check-test-references.sh` resolves every backticked `<name>.test.ts` mention by
BASENAME (so moving a test between directories, which breaks no promise, does not fail it)
and prints every referring site when one goes missing. Proved by renaming the file and
watching it name all six, then restoring. Ten references today, all resolving.
That script's first draft had the same defect as the coverage script fixed earlier in this
stream, from the other direction: a quoted git pathspec matched nothing, `git grep` exits 1
on no matches, and under `set -euo pipefail` the assignment aborted — so it exited 1 having
printed NOTHING. A check that fails silently is no more useful than one that passes wrongly.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSCgs7z19w8aGXGiceCohC
0 commit comments