Skip to content

Regenerate case conversion TS bindings#5434

Open
rekhoff wants to merge 14 commits into
masterfrom
rekhoff/update-ts-case-conv-bindings
Open

Regenerate case conversion TS bindings#5434
rekhoff wants to merge 14 commits into
masterfrom
rekhoff/update-ts-case-conv-bindings

Conversation

@rekhoff

@rekhoff rekhoff commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description of Changes

Updates the TypeScript code generator to emit correct .name() values on table fields, and updates the three affected Case Conversion Test snapshots.

Problem: For source identifiers with mixed/PascalCase casing (e.g., Player1Id), the in-process codegen path used by cargo test and check-diff.sh emitted .name() calls using the pre-conversion identifier (name('Player1Id')) instead of the canonical database column name (name('player_1_id')). The CLI spacetime generate path was already correct because its extract-schema round-trip canonicalizes names before codegen. The two paths disagreed, causing check-diff CI failures.

Root cause / Fix: write_object_type_builder_fields in crates/codegen/src/typescript.rs was using the TypespaceForGenerate pre-conversion identifier for .name(). It now accepts an optional &[ColumnDef] and emits column.name for table fields. The camelCase accessor key (e.g., player1Id) is unchanged; only the underlying wire/database column name is corrected to snake_case.

The three snapshot files in crates/bindings-typescript/case-conversion-test-client/src/module_bindings/ are updated to match the corrected output.

API and ABI breaking changes

No API or ABI changes at the Rust crate or C ABI level.
For TypeScript users, this is a bug fix for the in-process generation path; the CLI path was already correct.

Expected complexity level and risk

1 - Trivial

Testing

  • Local testing
    • Verified the in-process cargo test -p spacetimedb-sdk -- case_conversion path on master generated incorrect PascalCase .name() values (name("Player1Id"), missing .name() for currentLevel2/status3Field.
    • Verified the same in-process path on the PR branch generates correct snake_case .name() values (name("player_1_id"), name("current_level_2"), name("status_3_field")), matching the updated snapshots.
    • Verified the CLI spacetime generate --lang typescript path produces identical snake_case output on both master and the PR branch.
    • Created a standalone TypeScript test that confirms the generated bindings produce SQL with canonical snake_case column names ("current_level_2", "player_1_id", "player_ref") via the SDK toSql() function.
  • CI passing

@rekhoff rekhoff marked this pull request as ready for review June 24, 2026 23:29
@bfops bfops changed the base branch from bot/fix-ts-table-handle-casing to master June 26, 2026 15:58
@rekhoff rekhoff requested a review from Shubham8287 June 26, 2026 17:02
@rekhoff rekhoff self-assigned this Jun 26, 2026
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.

3 participants