Skip to content

feat: add Prisma 7 SQLCommenter demo app#14

Open
ChrisHarris2012 wants to merge 3 commits into
feat/sqlcommenter-prismafrom
feat/prisma-demo
Open

feat: add Prisma 7 SQLCommenter demo app#14
ChrisHarris2012 wants to merge 3 commits into
feat/sqlcommenter-prismafrom
feat/prisma-demo

Conversation

@ChrisHarris2012

Copy link
Copy Markdown

Summary

  • Full-stack Express + React demo app showing Prisma 7's native SQLCommenter support
  • Uses PrismaClient comments API with @prisma/sqlcommenter-query-tags for request-scoped tags
  • Proxy-based call-site capture for the file tag (path:line:column format) with WSL path support
  • withQueryTags / withMergedQueryTags middleware for route and method injection
  • Project/issue tracker app generating varied OLTP queries (CRUD, aggregations, filtering, pagination, batch ops)

Tags produced

Every query gets a SQL comment like:

/*action='findMany',db_driver='prisma',file='//wsl.localhost/Ubuntu/.../server/routes/issues.ts:36:18',method='GET',model='Issue',route='/api/issues'*/

Test plan

  • cp .env.example .env and configure DATABASE_URL
  • npm install && npx prisma migrate dev && npm run db:seed
  • npm run dev — verify frontend loads at localhost:5173
  • Check query log panel shows SQL comments with all tags including file

🤖 Generated with Claude Code

ChrisHarris2012 and others added 3 commits March 6, 2026 07:36
SQLCommenter integration for Prisma ORM via driver adapter wrapping.
Automatically appends query metadata (db_driver, route, method, file)
as SQL comments to all Prisma queries.

Key design decisions:
- wrapAdapter patches the adapter in-place (not Object.create) to
  preserve Prisma's error registry object identity
- wrapAdapterFactory supports Prisma 6+ SqlDriverAdapterFactory
  pattern where PrismaPg.connect() returns the SqlDriverAdapter
- Bridges ALS context across Prisma's WASM engine boundary via
  module-level variables, since AsyncLocalStorage is lost when
  the Rust engine calls back into JS

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prisma's PrismaPromise defers execution via .then(), so by the time
$allOperations fires, the user code is no longer on the call stack.
The first non-filtered frame was node:internal/process/task_queues,
producing a misleading file tag. Filter node:internal and
node:async_hooks frames so the file tag is omitted rather than wrong.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Full-stack Express + React demo showing Prisma 7's native `comments`
API with `@prisma/sqlcommenter-query-tags`. Includes proxy-based
call-site capture for the `file` tag (path:line:column) and
`withQueryTags` middleware for route/method injection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@veksen veksen force-pushed the feat/sqlcommenter-prisma branch from d603f01 to 84d2ad5 Compare June 16, 2026 22:10
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.

1 participant