chore(drizzle): alias _query to query and enforce via lint#3118
Closed
chore(drizzle): alias _query to query and enforce via lint#3118
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Reviewed by gpt-5.5-2026-04-23 · 761,150 tokens |
Prep for drizzle v1, which renames the RQB namespace from `query` to `_query`. Adds a runtime alias so both names work, rewrites every `.query` drizzle receiver to `._query`, and enforces the new name with an oxlint rule plus a type-aware CI check. - New `@kilocode/drizzle-shims` package patches PgDatabase and BaseSQLiteDatabase prototypes with a `_query` getter; transaction subclasses (`tx._query`) are covered automatically. - Side-effect imports added at every `drizzle(...)` construction site (packages/db client plus 12 DO service files). - `oxlint-plugin-drizzle.js` gains `prefer-underscore-query` (autofix, name-gated: db / ctx.db / this.db / tx / trx). - `scripts/drizzle-query-rename.ts` is a ts-morph codemod/verifier that walks every workspace tsconfig plus dev/ and scripts/ orphans and checks the drizzle `query` property by declaration location. Exposed as `pnpm drizzle:query-rename` and `pnpm drizzle:query-check`; the check runs as part of `pnpm validate`. - 372 call sites across 76 files rewritten.
Adds a 'Drizzle _query enforcement' step to the lint job that runs `pnpm drizzle:query-check`. The oxlint rule already blocks the common cases (db / ctx.db / this.db / tx / trx); the ts-morph verifier catches the type-aware long tail so a renamed drizzle db can't sneak past. Both exit non-zero on a fresh `.query` — verified by injecting a canary.
jeanduplessis
approved these changes
May 8, 2026
apps/web tsconfig uses moduleResolution: node, which doesn't honor the shim package's exports map (.ts source files). Without resolution, the _query type augmentation never loads and next build fails type checking. Add a path mapping mirroring the existing @kilocode/db/* pattern.
…gle tick The single macrotask tick was fast enough locally but not on CI's slower Postgres, where the claimPendingReviewRows UPDATE round-trip hadn't returned before the assertion fired.
Contributor
Author
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.
Summary
Prep for drizzle v1, which renames the RQB namespace from
queryto_query. This change adds a runtime alias so both names work today, rewrites every.querydrizzle receiver to._query, and enforces the new name going forward.@kilocode/drizzle-shimspackage patchesPgDatabase.prototypeandBaseSQLiteDatabase.prototypewith a_querygetter that returnsthis.query. Transaction subclasses (PgTransaction,SQLiteTransaction) inherit the alias automatically, sotx._queryworks everywhere too. Includes module augmentations so TypeScript sees_queryon every drizzle db flavour.import '@kilocode/drizzle-shims/query-alias';) at everydrizzle(...)construction site —packages/db/src/client.tsplus 12 DO service files. The new workspace dep was added to each affected service.oxlint-plugin-drizzle.jsgainsprefer-underscore-query(AST-only, autofixable, name-gated on["db", "ctx.db", "this.db", "tx", "trx"]— same posture as the existing two drizzle rules). Enabled as"error"in.oxlintrc.json.scripts/drizzle-query-rename.ts— ts-morph codemod / CI verifier. Because oxlint plugins can't see types, this script is the authoritative check: it walks every workspace tsconfig plusdev/andscripts/orphan files and identifies.queryproperty accesses whosequeryproperty is declared insidedrizzle-orm. Runs aspnpm drizzle:query-rename(--fix) orpnpm drizzle:query-check; the latter is wired intopnpm validate..queryto._query.When drizzle v1 lands, delete
packages/drizzle-shims/, the 13 side-effect imports, the oxlint rule, and the codemod script. The codebase already reads from_query.Verification
Example of a run that finds calls to
.query:Reviewer Notes
packages/drizzle-shims/src/query-alias.tswith clear removal instructions for the drizzle v1 migration.txn/trxrenames, helpers returning a drizzle db, etc.).@kilocode/trpc's.d.tsabout@kilocode/drizzle-shims/query-aliasbeing an external dep. It's benign (the import is type-only from consumers' perspective and resolves via the workspace), but worth flagging.query-alias.ts— only additive, no setter, idempotent, non-enumerable; and (2) the codemod correctness — mitigated by the type-aware check, the full test suite passing, and targeted typechecks. Worth spot-checking a handful of rewrites (e.g.apps/web/src/lib/kilo-pass/usage-triggered-bonus.ts) to confirm semantics are preserved.