fix(ts-sdk): Add primaryKey() and index() to SumBuilderImpl and SumColumnBuilder#4389
Open
Ludv1gL wants to merge 1 commit intoclockworklabs:masterfrom
Open
fix(ts-sdk): Add primaryKey() and index() to SumBuilderImpl and SumColumnBuilder#4389Ludv1gL wants to merge 1 commit intoclockworklabs:masterfrom
Ludv1gL wants to merge 1 commit intoclockworklabs:masterfrom
Conversation
…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>
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.
Summary
.primaryKey()on all primary key columns, including enum typesSumBuilderImpl(used for all object-form enums via__t.enum("Name", { ... })) only implementedDefaultableandNameable— notPrimaryKeyableorIndexableTypeError: SC.primaryKey is not a functionwhenever an enum type is used as a primary key columnFix
Add
IndexableandPrimaryKeyableinterfaces and their methods to:SumBuilderImpl(the base class for all enum type builders)SumColumnBuilder(the column builder returned bySumBuilderImplmethods)This matches the existing pattern already present in
SimpleSumBuilderImplandSimpleSumColumnBuilder.Why SumBuilderImpl and not just SimpleSumBuilderImpl?
Codegen always generates object-form enums:
The runtime dispatch in
type_builders.ts(line ~3656) routes object-form enums toSumBuilder(backed bySumBuilderImpl), never toSimpleSumBuilder. SoSimpleSumBuilderImpl's existingprimaryKey()/index()methods are effectively dead code for codegen output.Test plan
TypeError: SC.primaryKey is not a functionSimpleSumBuilderImpl/SimpleSumColumnBuilderbehavior is unchanged (subclass overrides still work)🤖 Generated with Claude Code