fix: brand PrimaryKeyBuilder to close empty structural type hole - #6189
fix: brand PrimaryKeyBuilder to close empty structural type hole#6189webdevsamran wants to merge 1 commit into
Conversation
In the published declarations, PrimaryKeyBuilder had its instance properties stripped by @internal markers, causing it to be structurally empty ({}). As a result, arbitrary plain objects or wrapped index objects (e.g. { myIndex: uniqueIndex(...) }) satisfied PgTableExtraConfigValue without compiler error, leading to silently dropped indexes. Fix: add nominal declare _: { brand: '<Dialect>PrimaryKeyBuilder' }`nbranding to PrimaryKeyBuilder across pg, mysql, singlestore, cockroach, and mssql dialects (matching sqlite). Fixes drizzle-team#6140
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c394ab52e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| declare _: { | ||
| brand: 'MySqlPrimaryKeyBuilder'; | ||
| }; |
There was a problem hiding this comment.
Brand the remaining empty MySQL union member
For consumers of the published MySQL declarations, this brand still does not reject legacy object-wrapped indexes: MySqlTableExtraConfigValue also includes UniqueConstraintBuilder, whose columns, name, and build members are all stripped as @internal, leaving only a constructor, which does not participate in structural instance compatibility. Consequently that union still accepts arbitrary objects such as { myIndex: uniqueIndex(...) }, so MySQL users continue to receive no diagnostic and the index remains silently ignored; UniqueConstraintBuilder must also retain a structural discriminator.
Useful? React with 👍 / 👎.
Fixes #6140
Summary
In published type definitions, PrimaryKeyBuilder had its instance properties stripped due to /** @internal */ comments, leaving it structurally empty ({}).
Consequently, arbitrary plain objects or object-wrapped builders (such as [{ myIndex: uniqueIndex(...) }] when migrating from legacy object syntax) satisfied TableExtraConfigValue without TypeScript reporting any diagnostic, which caused indexes to be silently ignored at runtime.
Changes