Commit b44156d
fix(ts-sdk): Add primaryKey() and index() to SumBuilderImpl and SumColumnBuilder (#4389)
## Summary
- Codegen unconditionally emits `.primaryKey()` on all primary key
columns, including enum types
- `SumBuilderImpl` (used for **all** object-form enums via
`__t.enum("Name", { ... })`) only implemented `Defaultable` and
`Nameable` — not `PrimaryKeyable` or `Indexable`
- This causes a runtime `TypeError: SC.primaryKey is not a function`
whenever an enum type is used as a primary key column
## Fix
Add `Indexable` and `PrimaryKeyable` interfaces and their methods to:
- `SumBuilderImpl` (the base class for all enum type builders)
- `SumColumnBuilder` (the column builder returned by `SumBuilderImpl`
methods)
This matches the existing pattern already present in
`SimpleSumBuilderImpl` and `SimpleSumColumnBuilder`.
## Why SumBuilderImpl and not just SimpleSumBuilderImpl?
Codegen always generates object-form enums:
```typescript
export const PlatformModuleType = __t.enum("PlatformModuleType", {
Standard: __t.unit,
Control: __t.unit,
});
```
The runtime dispatch in `type_builders.ts` (line ~3656) routes
object-form enums to `SumBuilder` (backed by `SumBuilderImpl`), never to
`SimpleSumBuilder`. So `SimpleSumBuilderImpl`'s existing
`primaryKey()`/`index()` methods are effectively dead code for codegen
output.
## Test plan
- [x] Verify enum types used as primary keys no longer throw `TypeError:
SC.primaryKey is not a function`
- [ ] Verify existing `SimpleSumBuilderImpl`/`SimpleSumColumnBuilder`
behavior is unchanged (subclass overrides still work)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>1 parent cda345a commit b44156d
1 file changed
Lines changed: 60 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1568 | 1568 | | |
1569 | 1569 | | |
1570 | 1570 | | |
1571 | | - | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
1572 | 1574 | | |
1573 | 1575 | | |
1574 | 1576 | | |
| |||
1673 | 1675 | | |
1674 | 1676 | | |
1675 | 1677 | | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
1676 | 1705 | | |
1677 | 1706 | | |
1678 | 1707 | | |
| |||
3273 | 3302 | | |
3274 | 3303 | | |
3275 | 3304 | | |
3276 | | - | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
3277 | 3308 | | |
3278 | 3309 | | |
3279 | 3310 | | |
| |||
3294 | 3325 | | |
3295 | 3326 | | |
3296 | 3327 | | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
3297 | 3355 | | |
3298 | 3356 | | |
3299 | 3357 | | |
| |||
0 commit comments