Skip to content

fix(cli): handle model name collisions during scaffolding - #1052

Merged
cpojer merged 4 commits into
voidzero-dev:mainfrom
niteshseram:fix/model-gen-name-collisions
Dec 6, 2026
Merged

cpojer merged 4 commits into
voidzero-dev:mainfrom
niteshseram:fix/model-gen-name-collisions

Conversation

@niteshseram

Copy link
Copy Markdown
Contributor

Summary

void gen model accepts names that can produce invalid TypeScript or routes that Void skips. For example, class produces an invalid declaration, _posts produces routes that are ignored, and a model named text or db can collide with an import in the generated files. A model named body can also be shadowed by the POST handler’s request body.

  • Reject names that are invalid TypeScript bindings or would produce skipped routes before writing any files.
  • Keep valid names such as text, db, and body. Use a local alias in the schema when a helper import has the same name, and import the table as modelTable in generated routes. The SQL table name, schema export, and API path still use the requested model name.
  • Document the model naming rules in the CLI reference.

Tests

  • gen-args.test.ts covers reserved TypeScript names and a leading underscore
  • gen.test.ts covers schema and route naming collisions across D1, PostgreSQL, and MySQL

niteshseram and others added 3 commits December 5, 2026 22:00

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@cpojer
cpojer enabled auto-merge (squash) December 6, 2026 00:19
@cpojer
cpojer merged commit cb95845 into voidzero-dev:main Dec 6, 2026
19 checks passed
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.

2 participants