Commit 3905bba
Regenerate case conversion TS bindings (#5434)
# 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
- [X] 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.
- [X] CI passing
---------
Signed-off-by: Ryan <r.ekhoff@clockworklabs.io>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>1 parent 77ed3b1 commit 3905bba
4 files changed
Lines changed: 34 additions & 19 deletions
File tree
- crates
- bindings-typescript/case-conversion-test-client/src/module_bindings
- codegen/src
Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
89 | 97 | | |
90 | 98 | | |
91 | 99 | | |
| |||
143 | 151 | | |
144 | 152 | | |
145 | 153 | | |
146 | | - | |
| 154 | + | |
147 | 155 | | |
148 | 156 | | |
149 | 157 | | |
| |||
815 | 823 | | |
816 | 824 | | |
817 | 825 | | |
818 | | - | |
| 826 | + | |
819 | 827 | | |
820 | 828 | | |
821 | 829 | | |
| |||
840 | 848 | | |
841 | 849 | | |
842 | 850 | | |
843 | | - | |
| 851 | + | |
844 | 852 | | |
845 | 853 | | |
846 | 854 | | |
| |||
932 | 940 | | |
933 | 941 | | |
934 | 942 | | |
935 | | - | |
| 943 | + | |
936 | 944 | | |
937 | 945 | | |
938 | 946 | | |
| |||
945 | 953 | | |
946 | 954 | | |
947 | 955 | | |
948 | | - | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
949 | 964 | | |
950 | 965 | | |
951 | 966 | | |
| |||
1083 | 1098 | | |
1084 | 1099 | | |
1085 | 1100 | | |
1086 | | - | |
| 1101 | + | |
1087 | 1102 | | |
1088 | 1103 | | |
1089 | 1104 | | |
| |||
0 commit comments