Skip to content

fix(ts-sdk): Add primaryKey() and index() to SumBuilderImpl and SumColumnBuilder#4389

Open
Ludv1gL wants to merge 1 commit intoclockworklabs:masterfrom
Ludv1gL:fix/enum-primarykey-sum-builder
Open

fix(ts-sdk): Add primaryKey() and index() to SumBuilderImpl and SumColumnBuilder#4389
Ludv1gL wants to merge 1 commit intoclockworklabs:masterfrom
Ludv1gL:fix/enum-primarykey-sum-builder

Conversation

@Ludv1gL
Copy link
Contributor

@Ludv1gL Ludv1gL commented Feb 21, 2026

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:

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

  • 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

…lumnBuilder

Codegen unconditionally calls .primaryKey() on all primary key columns,
including enum types. But SumBuilderImpl (used for all object-form enums)
only implemented Defaultable and Nameable — not PrimaryKeyable or
Indexable. This caused a runtime TypeError when any enum type was used
as a primary key column.

Add Indexable and PrimaryKeyable interfaces and their methods to both
SumBuilderImpl and SumColumnBuilder, matching the existing pattern in
SimpleSumBuilderImpl and SimpleSumColumnBuilder.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant