Repository navigation
feat: expose each query's source file and name it in its errors - #34
Merged
Merged
Conversation
Every build step writes the .sql file's path into the module, and the query exposes it as .source. Reylo's errors about a parameter's value, a column's value or the row count start with it; the driver's own errors pass through unchanged.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
ℹ️ No critical issues. One minor typing suggestion inline.
Reviewed changes
I reviewed the full diff of this PR: every .sql module now carries its source, Query exposes it, and Reylo's parameter, decode and row-count errors start with it.
sourcealways emitted:sqlModulewrites the root-relative path with/for every statement, not only ones withfresh. Every build step (vite, webpack, jest, the register hooks) goes through it.ParameterError: aTypeErrorsubclass that replaces every parameter-valueTypeErrorinsrc/execute.tsandsrc/rows.ts.named()indefineQueryuses it withDecodeErrorto prefix only Reylo's own errors onrun,runSyncandwith.- Stack patching:
named()rewrites the stack's first line only when the stack was already formatted. I checked on Node 24: V8 picks up the new message ifstackhasn't been read yet and keeps the old one if it has, so both branches are needed. - Tests: the new
execute.test.tscase passes locally. The existing message assertions on loader-built modules (casts,structured,representation) are unanchored regexes, so the new prefix doesn't break them.
claude-opus-5-5 | 𝕏
Contributor
There was a problem hiding this comment.
✅ No new issues found. The prior typing suggestion is addressed.
Reviewed changes
Since the last review, one commit narrows the declared type of a .sql import's source.
source: stringon the mapper's intersection:src/mapper.tsaddsreadonly source: stringbesidesqlandraw, so app code no longer needs a!. I checked that every build path goes throughsqlModule: vite, esbuild, webpack/turbopack, and the register worker used byregisterandjest. So the non-optional type holds at run time.- Not the literal path: keeping
stringrather than the path itself is the right call. The build resolves the root from the.sqlfile's own project, and the mapper resolves it from the tsconfig's, so a literal could name the wrong file in a workspace. - Docs capture and tests follow:
site/scripts/capture-types.tsmirrors the mapper's line,site/lib/sql-modules.jsonis recaptured, andtests/compiled.test.tsaddssourceto thetexts()filter and to the expected declarations for all three dialects.
claude-opus-5-5 | 𝕏
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.

Each
.sqlimport now knows which file it came from, so an app can tag its logs and traces with it, and Reylo's own errors say which query failed..source: every build step writes the file's path, relative to the project's root and written with/, into the module, and the query exposes it (getUser.source === "queries/get_user.sql"). Until now the module carried it only when the statement had catalog facts to check, and only for the stale-database error. A query defined by hand withdefineQueryhas none (undefined).queries/get_user.sql: Expected exactly one row, got 0. The driver's own errors, and Reylo's errors about the client itself, pass through unchanged.TypeErrorsubclass of their own, as decode errors already had, so.run()and.runSync()can tell them from the driver's. Both stayTypeErrors, with the samename..rawin Usage.Test plan
nub run typechecknub run test(163 pass; the 35 skipped need the Postgres and MySQL servers CI starts).source; the row-count, parameter and decode errors named onrunandrunSync, the stack included; a driver error (UNIQUE constraint failed) and a query with no file left as they weresource: "queries/one.sql"site:nub run build