Repository navigation
fix(void): load SQL helpers before the schema in void/db - #526
Merged
Merged
Conversation
A table file that db/schema.ts re-exports from outside db/ (for example
src/resources/projects/projects.schema.ts) imports `sql` from void/db.
When a route loaded void/db first, the cycle
void/db -> db/schema.ts -> projects.schema.ts -> void/db
handed the table file a half-loaded void/db, and `sql` was undefined in
dev ("__vite_ssr_import_0__.sql is not a function").
Vite SSR runs imports in source order, so void/db now re-exports the
drizzle-orm helpers before it imports the schema, for SQLite, PostgreSQL
and MySQL. The helpers are ready whatever path the schema file lives at.
Build output already linked the helpers directly and keeps working.
Fixes #472
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://fix-db-schema-cycle-void-cloud.voidzero-docs.workers.dev (commit b8f3efd)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Fixes #472
Problem
db/schema.tsre-exports a table file from outsidedb/, and that file usessqlfromvoid/dbat the top level:In dev this throws
__vite_ssr_import_0__.sql is not a function. #504 fixed thedb/schema/folder. Files anywhere else still hit the error.Fix
Vite SSR runs imports in the order they are written.
void/dbnow re-exports the drizzle-orm helpers (sql,eq, …) first, before it imports the schema. This applies to all three dialects (SQLite, PostgreSQL, MySQL).resolveId,virtual:void-db-schemaanddb/schema/**are unchanged.sqldirectly. It still works, and it ships the same modules in a different order.dbat the top level of a schema file. It needs a request anyway.Tests
plugin-drizzle.test.ts: helper export comes first (sqlite/postgresql/mysql)plugin-vite-environment.test.ts: real dev server, #472 layout, route importsdbbefore@schemasql is not a functionBoth files pass (103/103). Lint, format and the
voidtypecheck are clean.🤖 Generated with Claude Code