Skip to content

Add API to opt out of case conversion#4364

Closed
clockwork-labs-bot wants to merge 1 commit intomasterfrom
bot/case-conversion-opt-out
Closed

Add API to opt out of case conversion#4364
clockwork-labs-bot wants to merge 1 commit intomasterfrom
bot/case-conversion-opt-out

Conversation

@clockwork-labs-bot
Copy link
Collaborator

Companion to the case conversion PR (#4263).

Adds an API for existing modules to disable automatic case conversion, preventing migration errors from renamed fields or enum variants when deploying the case conversion feature against modules with existing data.

Changes:

  • RawModuleDefV10Builder::set_case_conversion_policy(policy) — sets the module-level case conversion policy
  • spacetimedb::rt::register_no_case_conversion() — convenience function for modules to disable case conversion

Usage in a module:

// In the module's lib.rs, add a preinit function:
#[ctor::ctor]
fn disable_case_conversion() {
    spacetimedb::rt::register_no_case_conversion();
}

This is needed for the controldb module which has existing data with PascalCase enum variants (Owner, Admin, etc.) that would be renamed to camelCase (owner, admin, etc.) by the default SnakeCase policy.

@cloutiertyler
Copy link
Contributor

We have tested this in staging

Add RawModuleDefV10Builder::set_case_conversion_policy() and an internal
register_case_conversion_policy() function in rt.rs. This allows modules
like controldb to disable case conversion via a __preinit__ hook, avoiding
migration errors when existing data uses a different naming convention.

Re-exports CaseConversionPolicy from the bindings crate for convenience.
@clockwork-labs-bot clockwork-labs-bot changed the base branch from shub/case-conversion to master February 20, 2026 12:57
@clockwork-labs-bot clockwork-labs-bot force-pushed the bot/case-conversion-opt-out branch from 0f6bcc3 to 03a297e Compare February 20, 2026 12:57
@Shubham8287 Shubham8287 added this pull request to the merge queue Feb 20, 2026
@Shubham8287 Shubham8287 removed this pull request from the merge queue due to a manual request Feb 20, 2026
@clockwork-labs-bot clockwork-labs-bot added this pull request to the merge queue Feb 20, 2026
@Shubham8287 Shubham8287 removed this pull request from the merge queue due to a manual request Feb 20, 2026
@Shubham8287
Copy link
Contributor

Changes in this PR will get merged through - https://github.com/clockworklabs/SpacetimeDB/pull/4366/changes.

@Shubham8287
Copy link
Contributor

Changes in this PR will get merged through - https://github.com/clockworklabs/SpacetimeDB/pull/4366/changes.

@Shubham8287 Shubham8287 reopened this Feb 20, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 20, 2026
## Summary

Adds a cross-language `#[spacetimedb::settings]` mechanism for declaring
module-level settings. The first supported setting is
`CASE_CONVERSION_POLICY`, which controls how identifiers are
case-converted.

### Rust

```rust
use spacetimedb::CaseConversionPolicy;

#[spacetimedb::settings]
const CASE_CONVERSION_POLICY: CaseConversionPolicy = CaseConversionPolicy::None;
```

- Proc macro validates const name against `KNOWN_SETTINGS`
- Generates `__preinit__` export for registration
- Duplicate settings produce a linker error (duplicate symbol)

### TypeScript

```ts
export const moduleSettings: ModuleSettings = {
  caseConversionPolicy: CaseConversionPolicy.None,
};
```

- `ModuleSettings` interface with typed fields
- `caseConversionPolicy` section pushed in `rawModuleDefV10()`


## Stacked on

- `shub/case-conversion` (base)
- PR #4364 (internal opt-out API)

This PR adds the proper user-facing API on top of the internal mechanism
in #4364.

Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments