feat: add sqlcommenter-query-insights plugin#28830
Conversation
WalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client as PrismaClient
participant Plugin as SqlCommenterPlugin
participant Param as Parameterizer
participant Shape as Shaper
participant Format as Formatter
participant DB as Database
Client->>Plugin: onQuery(context)
Plugin->>Param: parameterizeQuery(context.query)
Param-->>Plugin: parameterizedQuery
Plugin->>Shape: shapeQuery(parameterizedQuery)
Shape-->>Plugin: shapedQuery
Plugin->>Format: formatQueryInsight({type, model, action, query: shapedQuery})
Format-->>Plugin: commentString
Plugin->>Client: attachComment(commentString)
Client->>DB: execute SQL (with comment)
DB-->>Client: result
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (8)📓 Common learnings📚 Learning: 2025-12-04T16:27:28.693ZApplied to files:
📚 Learning: 2025-12-03T09:46:36.091ZApplied to files:
📚 Learning: 2025-12-04T17:22:16.406ZApplied to files:
📚 Learning: 2025-12-03T09:46:36.091ZApplied to files:
📚 Learning: 2025-12-03T09:46:36.091ZApplied to files:
📚 Learning: 2025-12-03T09:46:36.091ZApplied to files:
📚 Learning: 2025-12-03T09:46:36.091ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1000)
🔇 Additional comments (1)
Comment |
size-limit report 📦
|
a5755d5 to
cc627c7
Compare
4ae0e2c to
619d096
Compare
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts
Outdated
Show resolved
Hide resolved
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts
Outdated
Show resolved
Hide resolved
packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts
Show resolved
Hide resolved
619d096 to
2979d79
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (4)
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts (1)
117-151: E2E flow is solid; consider removing reliance on fixedcapturedQueriesindicesThe end‑to‑end wiring (adapter, logging, parsing comments, and verifying payloads and redaction) looks good, and the
notContainslogic is now clean.What’s still brittle is the dependence on hard‑coded indices (e.g.
verifyQuery(6, ...),verifyQuery(8, ...)with comments about extra queries). Any change in the engine’s query plan or batching could shuffle or insert queries and make these assertions fail spuriously.A more resilient pattern would be to resolve indices by inspecting
prismaQueryrather than position, for example:function findNextQueryIndex( start: number, predicate: (parsed: { prefix: string; payload?: unknown }) => boolean, ): number { for (let i = start; i < capturedQueries.length; i++) { const prismaQuery = extractPrismaQuery(capturedQueries[i]) if (!prismaQuery) continue const parsed = parsePrismaQuery(prismaQuery) if (predicate(parsed)) return i } throw new Error('Expected query not found') } // Usage sketch: let idx = 0 idx = findNextQueryIndex(idx, (p) => p.prefix === 'User.findMany') verifyQuery(idx, 'findMany', { ... }) idx = findNextQueryIndex(idx + 1, (p) => p.prefix === 'User.createOne') verifyQuery(idx, 'create with data', { ... })Then the later checks (pagination, include, complex where, select) can similarly use predicates on prefix and/or payload shape rather than fixed numeric positions.
This isn’t blocking but will make the e2e suite more robust to internal plan changes.
Also applies to: 155-263
packages/sqlcommenter-query-insights/src/shape/shape.ts (1)
100-109: Clarify theshaped || truefallback semantics.When
shapeSelectionObjectreturnsnull(no fields selected beyond markers), line 108 falls back totrue, effectively including the relation. If a relation can legitimately have only markers like{ $scalars: false, $composites: true }with no concrete fields, the behavior should be documented.Consider adding a comment explaining why
trueis the safe default when no fields are selected, or evaluate whether such relations should be dropped instead.packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
34-70: Clarify that STRUCTURE_KEYS define boundaries, not exemptions.The comment states these keys "should NOT be parameterized," but in practice, these keys mark structural boundaries while their values are still recursively parameterized. For example,
where: { name: 'Alice' }would have'Alice'parameterized despite'where'being a structure key.Consider updating the comment to clarify: "Keys that define query structure and mark structural boundaries. Their values are still recursively parameterized to extract user data."
264-285: Dead code:isDataContextis never set totrue.The data context logic at line 265 checks
key === 'data' || parentContext.isDataContext, but whenkey === 'data', line 267 immediately catches it (since'data'is inSTRUCTURE_KEYSat line 59) and returnsisDataContext: false. For children of thedatakey,parentContext.isDataContextremainsfalse, so line 265 never triggers.This makes the entire
isDataContextmechanism effectively unused, adding cognitive load without functional impact. The default parameterization at line 204 already handles primitives safely.Consider either:
- Removing
isDataContextfrom theParameterizationContexttype and all related branches, or- Removing
'data'fromSTRUCTURE_KEYSand adding tests to validate "everything under data is user data except relation ops."Also applies to: 131-144, 153-205
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (5)
packages/client/tests/e2e/sqlcommenter-query-insights/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlpackages/client/tests/e2e/sqlcommenter-query-tags/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlpackages/client/tests/e2e/sqlcommenter-trace-context/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlpackages/client/tests/e2e/sqlcommenter/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (38)
.github/workflows/test-template.yml(2 hunks)AGENTS.md(3 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/_steps.cts(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/package.json(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.ts(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prisma(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/readme.md(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.json(1 hunks)packages/sqlcommenter-query-insights/README.md(1 hunks)packages/sqlcommenter-query-insights/docs/embedder-guide.md(1 hunks)packages/sqlcommenter-query-insights/helpers/build.ts(1 hunks)packages/sqlcommenter-query-insights/package.json(1 hunks)packages/sqlcommenter-query-insights/src/format.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/format.ts(1 hunks)packages/sqlcommenter-query-insights/src/index.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/index.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/shape/shape.ts(1 hunks)packages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.ts(1 hunks)packages/sqlcommenter-query-insights/tsconfig.build.json(1 hunks)packages/sqlcommenter-query-insights/tsconfig.json(1 hunks)packages/sqlcommenter/README.md(1 hunks)tsconfig.build.bundle.json(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript for new code in the Prisma monorepo
Files:
packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/parameterize/tests/security.test.tspackages/sqlcommenter-query-insights/src/format.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.tspackages/sqlcommenter-query-insights/src/shape/shape.tspackages/sqlcommenter-query-insights/src/format.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.tspackages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/src/parameterize/parameterize.tspackages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.tspackages/sqlcommenter-query-insights/helpers/build.tspackages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.tspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.tspackages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.test.ts: Place test files alongside source files with.test.tsnaming convention, which are excluded from build output via esbuild config
Inline snapshots should be kept concise unless the exact message matters
Files:
packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/security.test.tspackages/sqlcommenter-query-insights/src/format.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.tspackages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.tspackages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.tspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.tspackages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.ts
tsconfig.build.bundle.json
📄 CodeRabbit inference engine (AGENTS.md)
Update
tsconfig.build.bundle.jsonundercompilerOptions.pathswith resolution paths for new workspace packages to enable go-to-definition in editors
Files:
tsconfig.build.bundle.json
packages/*/helpers/build.ts
📄 CodeRabbit inference engine (AGENTS.md)
packages/*/helpers/build.ts: For new packages, add ahelpers/build.tsfile to configure the build process
UseadapterConfigfromhelpers/compile/configs.tsfor type-only packages to bundle to both CJS and ESM with type declarations
Files:
packages/sqlcommenter-query-insights/helpers/build.ts
AGENTS.md
📄 CodeRabbit inference engine (GEMINI.md)
Document agent capabilities, constraints, and behavior in AGENTS.md
Update
AGENTS.mdwhenever learning something new about the codebase that would be valuable for future tasks
Files:
AGENTS.md
🧠 Learnings (22)
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/migrate/src/__tests__/fixtures/**/*.config.ts : CLI test fixtures should provide `prisma.config.ts` per schema variant (e.g., `invalid-url.config.ts` next to `prisma/invalid-url.prisma`)
Applied to files:
packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/package.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/format.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsontsconfig.build.bundle.jsonpackages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prismapackages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/_steps.ctspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.tspackages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.tsAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/migrate/src/__tests__/**/*.test.ts : Use `ctx.setDatasource()` test helper to override config.datasource for connection-specific test scenarios
Applied to files:
packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts.github/workflows/test-template.ymlpackages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/_steps.ctspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.ts
📚 Learning: 2025-12-04T13:56:31.584Z
Learnt from: aqrln
Repo: prisma/prisma PR: 28830
File: packages/sqlcommenter-query-insights/src/format.ts:22-47
Timestamp: 2025-12-04T13:56:31.584Z
Learning: In packages/sqlcommenter-query-insights/src/format.ts, compacted batches (type === 'batch' in SqlCommenterQueryInfo) always have a modelName defined, so no guard for missing modelName is required in the batch branch of formatQueryInsight().
Applied to files:
packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/format.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/sqlcommenter-query-insights/src/shape/shape.tspackages/sqlcommenter-query-insights/src/format.tspackages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/tsconfig.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/README.mdpackages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.tspackages/sqlcommenter-query-insights/docs/embedder-guide.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Run client e2e suites with `pnpm --filter prisma/client test:e2e --verbose --runInBand` after fresh `pnpm build`
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/package.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/client/tests/e2e/sqlcommenter-query-insights/_steps.ctspackages/sqlcommenter-query-insights/src/index.test.tsAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/{package.json,tsconfig.json,tsconfig.build.json} : For new packages, create `package.json`, `tsconfig.json`, and `tsconfig.build.json` configuration files
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/package.jsonpackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/package.json
📚 Learning: 2025-12-03T10:49:29.006Z
Learnt from: aqrln
Repo: prisma/prisma PR: 28802
File: packages/client/package.json:208-215
Timestamp: 2025-12-03T10:49:29.006Z
Learning: In packages/client/package.json, dependencies like prisma/instrumentation-contract that are bundled during the build process should remain in devDependencies, not moved to runtime dependencies, because the bundler inlines the code into the runtime output.
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/package.jsontsconfig.build.bundle.jsonAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client-generator-{js,ts}/src/**/*.ts : Use `prisma/ts-builders` for generating TypeScript type declarations
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/index.tspackages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsontsconfig.build.bundle.jsonpackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/sqlcommenter-query-insights/src/shape/shape.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prismapackages/sqlcommenter-query-insights/src/parameterize/parameterize.tspackages/sqlcommenter-query-insights/helpers/build.tspackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to **/*.ts : Use TypeScript for new code in the Prisma monorepo
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsontsconfig.build.bundle.jsonpackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/sqlcommenter-query-insights/tsconfig.jsonAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client-generator-js/src/TSClient/PrismaClient.ts : In PrismaClient constructor options, update generated types in `packages/client-generator-js/src/TSClient/PrismaClient.ts` (`buildClientOptions` method)
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/index.tspackages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsontsconfig.build.bundle.jsonpackages/sqlcommenter-query-insights/src/shape/shape.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prismapackages/sqlcommenter-query-insights/src/parameterize/parameterize.tspackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Run client functional tests via `pnpm --filter prisma/client test:functional` with typechecking or `pnpm --filter prisma/client test:functional:code` for code only
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts.github/workflows/test-template.ymlpackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/client/tests/e2e/sqlcommenter-query-insights/_steps.ctspackages/sqlcommenter-query-insights/src/index.test.tsAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client-generator-ts/src/TSClient/file-generators/PrismaNamespaceFile.ts : In PrismaClient constructor options, update generated types in `packages/client-generator-ts/src/TSClient/file-generators/PrismaNamespaceFile.ts` (`buildClientOptions` function)
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/index.tspackages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsontsconfig.build.bundle.jsonpackages/sqlcommenter-query-insights/src/shape/shape.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prismapackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client/src/runtime/utils/validatePrismaClientOptions.ts : In PrismaClient constructor options, add validation to `packages/client/src/runtime/utils/validatePrismaClientOptions.ts` by updating the `knownProperties` array and `validators` object
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/readme.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to **/*.test.ts : Inline snapshots should be kept concise unless the exact message matters
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/format.test.tspackages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/src/index.test.ts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to **/*.test.ts : Place test files alongside source files with `.test.ts` naming convention, which are excluded from build output via esbuild config
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/src/index.test.ts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to tsconfig.build.bundle.json : Update `tsconfig.build.bundle.json` under `compilerOptions.paths` with resolution paths for new workspace packages to enable go-to-definition in editors
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsontsconfig.build.bundle.jsonpackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/sqlcommenter-query-insights/tsconfig.json
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/migrate/src/__tests__/**/*.test.ts : In CLI test fixtures, use `ctx.setConfigFile('<name>')` to override the config used for the next CLI invocation
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/client/tests/e2e/sqlcommenter-query-insights/_steps.ctspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.ts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/*/helpers/build.ts : Use `adapterConfig` from `helpers/compile/configs.ts` for type-only packages to bundle to both CJS and ESM with type declarations
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsontsconfig.build.bundle.jsonpackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/sqlcommenter-query-insights/helpers/build.ts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/*/helpers/build.ts : For new packages, add a `helpers/build.ts` file to configure the build process
Applied to files:
packages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/sqlcommenter-query-insights/helpers/build.ts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client/src/runtime/core/engines/common/Engine.ts : In PrismaClient constructor options, update engine config in `EngineConfig` interface in `packages/client/src/runtime/core/engines/common/Engine.ts`
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/sqlcommenter-query-insights/src/parameterize/parameterize.tsAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Commands and tests should read connection settings from `PrismaConfigInternal.datasource` rather than CLI flags or environment loading
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tsAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client/src/runtime/getPrismaClient.ts : In PrismaClient constructor options, add runtime types to `PrismaClientOptions` in `packages/client/src/runtime/getPrismaClient.ts`
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.ts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to AGENTS.md : Update `AGENTS.md` whenever learning something new about the codebase that would be valuable for future tasks
Applied to files:
AGENTS.md
🧬 Code graph analysis (18)
packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts (2)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
PARAM_PLACEHOLDER(13-13)packages/sqlcommenter-query-insights/src/index.ts (1)
prismaQueryInsights(28-33)
packages/sqlcommenter-query-insights/src/index.ts (1)
packages/sqlcommenter-query-insights/src/format.ts (1)
formatQueryInsight(22-47)
packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
parameterizeQuery(384-394)
packages/sqlcommenter-query-insights/src/format.test.ts (2)
packages/sqlcommenter-query-insights/src/format.ts (2)
toBase64Url(9-11)formatQueryInsight(22-47)packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.ts (1)
packages/sqlcommenter-query-insights/src/shape/shape.ts (1)
shapeQuery(171-194)
packages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.ts (1)
packages/sqlcommenter-query-insights/src/shape/shape.ts (1)
shapeQuery(171-194)
packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
parameterizeQuery(384-394)
packages/sqlcommenter-query-insights/helpers/build.ts (1)
helpers/compile/configs.ts (1)
adapterConfig(37-37)
packages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/index.test.ts (2)
helpers/compile/plugins/fill-plugin/fillers/buffer-small.ts (1)
Buffer(695-702)packages/sqlcommenter-query-insights/src/index.ts (1)
prismaQueryInsights(28-33)
packages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
parameterizeQuery(384-394)
🪛 Gitleaks (8.30.0)
packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts
[high] 286-286: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
[high] 528-528: Found a Stripe Access Token, posing a risk to payment processing services and sensitive financial data.
(stripe-access-token)
🔇 Additional comments (60)
packages/sqlcommenter/README.md (1)
54-59: New query‑insights plugin entry reads clearly and fits the listThe added first‑party plugin bullet is accurate and consistent with the existing entries.
packages/sqlcommenter-query-insights/tsconfig.build.json (1)
1-8: Build tsconfig matches repo conventions for new packagesExtending the shared build config, emitting to
dist, and excludingsrc/**/*.test.tsaligns with the monorepo patterns for library packages.
Based on learnings, this matches the AGENTS.md guidance fortsconfig.build.jsonin new packages.packages/sqlcommenter-query-insights/helpers/build.ts (1)
1-4: Build helper correctly wires shared compile infrastructureUsing
buildwithadapterConfigfrom the shared helpers follows the established pattern for package build scripts and keeps config centralized.
Based on learnings, this matches thepackages/*/helpers/build.tsguidance in AGENTS.md.packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.json (1)
1-9: E2E tsconfig is reasonable for NodeNext test setupExtending the shared base config, using
ESNext/NodeNext, and excluding_steps.ctsis a sensible setup for this e2e package.packages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.ts (1)
1-206: Basic shapeQuery test coverage is thorough and consistent with the shaping contractThese tests exercise the key modes (scalars‑only, scalars+relations, explicit
select, boolean relations, and preservation offalse) and match the expectedselect/includeshaping behavior fromshapeQuery, giving good confidence in the core transformation rules.packages/sqlcommenter-query-insights/README.md (1)
1-120: README clearly explains behavior, security guarantees, and integrationThe usage, sample
prismaQueryoutput, security section (values parameterized, structure only), and composition with other sqlcommenter plugins are all accurate and give integrators enough information to consume the plugin.packages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.ts (1)
1-409: Nested‑relations tests capture the key edge behaviors for shapeQueryThe suite exercises deep and varied nesting (mixed
select/include, simplification rules, multiple siblings) and the expected outputs are consistent with the shaping semantics, which should help prevent regressions in complex relation trees.packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.ts (1)
1-420: Edge‑case suite robustly exercises shapeQuery’s contractThese tests systematically cover corner cases around markers, empty/primitive inputs, complex arguments, and relation simplification rules, and they align with the documented behavior of
shapeQuery, making the shaping logic much safer to evolve.packages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prisma (1)
1-26: LGTM!The Prisma schema is well-structured for E2E testing. The SQLite datasource, custom client output path, and User-Post relation setup are appropriate for testing the sqlcommenter-query-insights plugin functionality.
tsconfig.build.bundle.json (1)
37-37: LGTM!The path alias for the new
@prisma/sqlcommenter-query-insightspackage is correctly added, following the established pattern and alphabetical ordering. This enables proper module resolution and go-to-definition support in editors.Based on coding guidelines, tsconfig.build.bundle.json must be updated with resolution paths for new workspace packages.
packages/sqlcommenter-query-insights/tsconfig.json (1)
1-4: LGTM!This is a standard package-level TypeScript configuration that correctly extends the root tsconfig and includes all package files.
packages/client/tests/e2e/sqlcommenter-query-insights/package.json (1)
1-24: LGTM!This E2E test package manifest follows the standard pattern used across Prisma's E2E test suite. The tarball dependencies, module type, and pnpm configuration are appropriate for isolated end-to-end testing.
packages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.ts (1)
1-7: LGTM!The Prisma configuration correctly defines a SQLite datasource URL that aligns with the schema provider and E2E test requirements.
packages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.ts (1)
1-135: LGTM!This test suite comprehensively validates that
parameterizeQuerycorrectly preserves selection markers ($scalarsand$composites) across various scenarios including nested selections and mixed field types. The test structure is clean and follows best practices..github/workflows/test-template.yml (2)
967-970: LGTM!The test step for
sqlcommenter-query-insightsis correctly added to the "others" job, following the same pattern as other package tests in this section.
1350-1354: LGTM!The test step for
sqlcommenter-query-insightsis correctly added to the "no-docker" job for Windows and macOS testing, with appropriate conditional gating and consistent formatting.packages/client/tests/e2e/sqlcommenter-query-insights/readme.md (1)
1-20: LGTM!The readme clearly documents the E2E test objectives and provides accurate instructions for local testing. The test goals are well-defined and the setup commands are correct.
packages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.ts (3)
1-4: LGTM!Clean imports following the project conventions. The test file is properly structured with Vitest imports and the necessary exports from the parameterize module.
5-201: LGTM!Comprehensive test coverage for
orderByhandling including:
- Simple sort directions (shorthand and full format)
- Nulls handling
- Array-based multi-field ordering
- Nested relation orderBy
- Aggregate ordering (
_count)All structural values (sort directions like
'asc','desc', nulls handling like'first','last') are correctly preserved.
203-414: LGTM!Solid pagination test coverage:
take/skippreservation including edge cases (negative take, zero skip)- Cursor value parameterization (including compound keys)
- Combined pagination scenarios with orderBy and where clauses
- Nested pagination in selections
The behavior correctly preserves structural pagination parameters while parameterizing cursor values.
packages/client/tests/e2e/sqlcommenter-query-insights/_steps.cts (1)
1-20: LGTM!Well-structured E2E test driver following the established pattern in the repository. The three-phase approach (setup → test → finish) with appropriate commands for Prisma client generation and database setup is correct.
packages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.ts (1)
1-105: LGTM!Solid foundational tests for basic value parameterization. The test cases correctly verify:
- Strings, numbers, and booleans are parameterized in filter contexts
nullvalues are preserved (important forIS NULLqueries)undefinedvalues are preserved (important for optional fields)Test naming is clear and follows conventions.
packages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.ts (1)
1-275: LGTM!Excellent test coverage for relation filters including:
some,every,noneoperators with various conditions- Deeply nested relation filters (4+ levels deep)
- Multiple relation filters at the same level
- Combination with field filters and logical operators
The tests correctly verify that structural operators (
some,every,none,AND,OR) are preserved while values are parameterized.packages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.ts (1)
1-161: LGTM!Thorough edge case coverage ensuring the parameterization logic handles:
- Empty objects and arrays gracefully
- Missing or empty
arguments- Top-level primitives, null, undefined, and arrays
- Mixed arrays containing both objects and primitives
- Deeply nested logical operator structures
These defensive tests help ensure robustness against unexpected input shapes.
packages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.ts (1)
1-713: LGTM!Comprehensive test coverage for data context parameterization in mutation operations:
- Basic data operations with null preservation
- All nested relation operations:
create,createMany,connect,connectOrCreate,disconnect,set,update,updateMany,upsert,delete,deleteMany- Array-based operations
- Boolean flags for disconnect/delete
- Deeply nested relation chains
The tests correctly verify that all user-provided values are parameterized while the structural operation keywords are preserved.
packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.ts (3)
1-28: Well-structured test setup with clear documentation.The imports, canary prefix, and helper functions are well-designed. The
containsCanaryfunction correctly uses JSON serialization to detect leakage in nested structures.
390-461: Comprehensive property-based test suite.The leakage tests provide strong guarantees against user data exposure. The manually constructed deeply nested structure (lines 440-448) is a creative approach to stress-test edge cases beyond what the recursive generator would typically produce.
463-569: Structural guarantee tests are thorough.The tests for determinism, idempotence, JSON-serializability, and preservation of structural values (null, take/skip, orderBy directions, selection markers) cover the essential invariants of the parameterization function.
packages/sqlcommenter-query-insights/src/format.test.ts (5)
1-22: Clean test setup with useful helpers.The
fromBase64UrlandparseQueryInsighthelpers encapsulate the decode/parse logic well, making test assertions readable and maintainable.
24-50: Good coverage for base64url encoding.Testing URL-safety (no
+,/,=) is important since these characters could cause issues in SQL comments.
52-157: Thorough tests for single query formatting.The tests correctly verify:
- Raw queries return only the action name
- Shaped queries produce the expected
Model.action:encodedformat- Parameterization replaces values with
PARAM_PLACEHOLDER- Selection shaping produces appropriate
selectvsincludebased on$scalars
183-227: Good coverage for compacted batch queries.The batch tests verify that each query in the array is independently parameterized and shaped, which is essential for correct query insights in batched operations.
229-355: Edge cases are well-covered.Notable tests:
- Empty query/batch handling ensures robustness
- Special characters test (lines 291-309) validates security against injection
- Long queries test (lines 270-289) verifies handling of large payloads
- Nested relations test (lines 311-354) validates complex shaping scenarios
packages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.ts (4)
1-66: Good coverage for equality operators.Tests correctly verify that
equalsandnotoperators (including nestednotwith object) have their values parameterized while preserving the operator structure.
68-215: Comprehensive tests for list and comparison operators.The tests cover:
- Array parameterization for
in/notIn(each element becomes a placeholder)- All comparison operators (
lt,lte,gt,gte)- Combined operators in a single filter object
217-341: String operators and mode preservation are well-tested.The
mode: 'insensitive'preservation test (lines 322-340) is particularly important as it validates that structural enums are not parameterized, maintaining query semantics.
343-568: Array field and JSON operators are thoroughly covered.Good coverage of:
- Array field operators (
has,hasEvery,hasSome,isEmpty)- JSON path queries with both path array and value parameterization
- All JSON string/array operators
packages/sqlcommenter-query-insights/src/index.ts (1)
1-33: Clean plugin implementation with good documentation.The implementation is minimal and focused. The JSDoc provides clear usage examples and output format documentation. The plugin correctly leverages the formatting infrastructure from
./format.packages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.ts (4)
1-69: Good coverage for AND operator.Tests correctly verify:
- Array form
AND: [...]parameterizes each condition- Single object form
AND: {...}parameterizes nested values- Nested AND operators are properly traversed
71-177: OR and NOT operators are well-tested.The tests cover various forms:
- OR with arrays and complex conditions
- NOT with single object, array, and nested conditions
- Proper value parameterization while preserving operator structure
179-259: Excellent coverage for is/isNot operators with null handling.The null preservation tests (lines 180-198, 220-238) are critical—they verify that
nullvalues inis/isNotoperators are preserved since{ is: null }and{ isNot: null }have semantic meaning in Prisma (checking for null relations).
261-373: Combined logical operators are thoroughly tested.The complex nesting test (lines 332-371) validates deeply nested combinations of AND, OR, and NOT operators, ensuring the parameterization correctly traverses all levels while preserving the logical structure.
packages/sqlcommenter-query-insights/package.json (1)
1-42: Package manifest for@prisma/sqlcommenter-query-insightslooks consistentEntry points, exports, scripts, and devDependencies match existing package patterns; nothing stands out as problematic here.
packages/sqlcommenter-query-insights/src/index.test.ts (1)
1-165: Unit coverage forprismaQueryInsightsis thorough and aligned with the contractThe tests exercise single vs compacted queries, raw queries, parameterization (no raw user data), and both shorthand/long
orderByshapes via decoded payloads, which matches the intended behavior of the plugin. No changes needed here.AGENTS.md (1)
7-8: New SQL Commenter and coding‑convention notes are appropriateThe added bullets correctly document the sqlcommenter package family, how
SqlCommenterQueryInfois shaped, and the conventions around file naming and avoiding new barrel files. This will be helpful context for future changes touching these plugins.Also applies to: 51-59, 68-71
packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.ts (1)
1-553: Complex query parameterization tests match the intended semanticsThese cases exercise deeply nested filters, mixed create/update/upsert operations, aggregations, and multi-relation traversals, correctly expecting only user data to be replaced with
PARAM_PLACEHOLDERwhile structural fields (take,orderBy, selection trees) are preserved. This is a solid complement to the simpler parameterization tests.packages/sqlcommenter-query-insights/docs/embedder-guide.md (1)
1-305: Embedder guide is clear and consistent with the plugin behaviorThe guide accurately describes the
prismaQuerytag format, payload structure (including compacted batches), and the{ "$type": "Param" }placeholder semantics, and it now follows markdownlint conventions (language-tagged fences and proper links). This should be sufficient for observability vendors to integrate against.packages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.ts (1)
1-243: Tagged-value parameterization tests align with the placeholder contractThe suite correctly asserts that all tagged user data types are converted to
PARAM_PLACEHOLDERwhile structuralFieldRefobjects are preserved, across where clauses, data contexts, nested operators, and arrays. This matches the documented behavior and strengthens confidence in the parameterizer.packages/sqlcommenter-query-insights/src/format.ts (3)
1-11: LGTM! Clean encoding utility.The imports are well-organized, and
toBase64Urlcorrectly uses Node's built-in URL-safe base64 encoding without padding. This is appropriate for embedding in SQL comments.
22-37: LGTM! Correct handling of single queries.The function correctly distinguishes between raw queries (no model, no payload) and model-based queries (full parameterization, shaping, and encoding pipeline). The logic flow is clear and well-documented.
39-47: LGTM! Batch handling is correct by design.The batch branch correctly processes compacted batches by parameterizing and shaping each query in the array. No
modelNameguard is needed here since compacted batches always have amodelNamedefined by design.Based on learnings, this implementation aligns with the system's invariants.
packages/sqlcommenter-query-insights/src/shape/shape.ts (4)
1-28: LGTM! Clear documentation and type guards.The module documentation effectively explains the transformation strategy, and the type guards are correctly implemented using standard TypeScript patterns.
30-69: LGTM! Correct simplification logic.Both functions correctly identify when selections can be simplified to
true. The logic properly checks for$scalars: truewith only marker keys present, and validates that arguments are empty before simplifying nested queries.
112-160: LGTM! Correct select/include transformation.The function correctly transforms selections based on the presence of
$scalars:
- With
$scalars: true, usesincludefor relations- Without
$scalars, usesselectfor all fieldsThe logic properly skips markers and returns
nullwhen there's nothing meaningful to output.
162-194: LGTM! Clean query transformation logic.The main export correctly orchestrates the transformation:
- Non-object values pass through unchanged
- Arguments are extracted and spread into the result
- Selection is shaped and conditionally merged
The implementation is clean and follows the documented transformation strategy.
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (5)
1-32: LGTM! Clear documentation and type guards.The module documentation effectively explains the parameterization approach, and the placeholder design allows for future extension. The type guards are correctly implemented with proper TypeScript type narrowing.
72-129: LGTM! Well-organized constant definitions.The constant sets are clearly defined and documented, providing comprehensive coverage of Prisma's query operators and structural keys. The separation into different categories (structural values, numeric structure, filter operators, logical operators) makes the code maintainable.
146-205: LGTM! Sound recursive parameterization strategy.The function implements a conservative parameterization approach with proper context-aware handling:
- Tagged values are correctly handled (preserving FieldRef and structural Enums)
- Context checks ensure booleans and structural values are preserved where appropriate
- Default parameterization errs on the side of safety
The logic is well-structured and defensive.
207-234: LGTM! Clean object parameterization.The function correctly processes object entries, preserves selection markers, and delegates context determination to
getContextForKey. The helper functionisStructuralKeyprovides a clear boundary check.
287-394: LGTM! Comprehensive context handling and clean entry point.The remaining context determination logic correctly handles:
- Structural value keys and numeric structure keys
- OrderBy context for preserving sort directions
- Filter and logical operators
- Default context inheritance
The
parameterizeQueryentry point properly initializes the context and delegates to the recursive logic. The implementation is thorough and well-organized.
packages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.ts
Show resolved
Hide resolved
packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.ts
Show resolved
Hide resolved
packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts
Outdated
Show resolved
Hide resolved
2979d79 to
e476775
Compare
There was a problem hiding this comment.
Actionable comments posted: 5
♻️ Duplicate comments (4)
packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.ts (1)
145-152: Consider simplifying the combined arbitrary.The
Object.fromEntries([['field1', ...]])pattern is verbose. A direct object literal would be cleaner.// Combined: simple fields + logical operator { weight: 1, arbitrary: fc.record({ - ...Object.fromEntries([['field1', whereFieldValueArb(idArb)]]), + field1: whereFieldValueArb(idArb), AND: fc.array(recurse, { minLength: 1, maxLength: 2 }), }), },packages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.ts (1)
417-448: Test names contradict the assertions.The test names state "preserves distinct field names" but the assertions show field names being replaced with
PARAM_PLACEHOLDER. Either the test names are misleading or the expected behavior is incorrect. Update the test names to reflect the actual behavior:describe('parameterizeQuery - distinct', () => { - it('preserves distinct field names', () => { + it('parameterizes distinct field names', () => { const query = { arguments: { distinct: ['email'], }, selection: { $scalars: true }, } expect(parameterizeQuery(query)).toEqual({ arguments: { distinct: [PARAM_PLACEHOLDER], }, selection: { $scalars: true }, }) }) - it('preserves distinct with multiple fields', () => { + it('parameterizes distinct with multiple fields', () => {packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts (2)
285-301: Tweak dummy "secret-like" literals to stop Gitleaks false positives.The test correctly verifies that tagged JSON values are parameterized, but the literal
"test-api-key-12345"matches Gitleaks' generic API key pattern and will cause CI noise.it('does not leak tagged Json values', () => { - const jsonValue = '{"secret":"test-api-key-12345"}' + const jsonValue = '{"secret":"DUMMY_KEY_FOR_TESTING"}' const query = { arguments: { where: { metadata: { $type: 'Json', value: jsonValue }, }, }, selection: { $scalars: true }, } const result = parameterizeQuery(query) const resultStr = JSON.stringify(result) expect(resultStr).not.toContain(jsonValue) - expect(resultStr).not.toContain('test-api-key-12345') + expect(resultStr).not.toContain('DUMMY_KEY_FOR_TESTING') })
521-569: Update Stripe-like test literal to avoid secret scanner detection.The
sk_test_abcdefghijklmnopvalue matches Gitleaks' Stripe access token pattern. While this is clearly a test value, it will trigger security scanner alerts in CI.const sensitiveData = { email: 'john.doe@privatecompany.com', password: 'SuperSecret123!', ssn: '123-45-6789', creditCard: '4111-1111-1111-1111', - apiKey: 'sk_test_abcdefghijklmnop', + apiKey: 'DUMMY_STRIPE_KEY_abcdefghijklmnop', internalId: 'usr_2024_confidential', salary: '150000.00', birthDate: '1990-05-15T00:00:00Z', }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (5)
packages/client/tests/e2e/sqlcommenter-query-insights/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlpackages/client/tests/e2e/sqlcommenter-query-tags/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlpackages/client/tests/e2e/sqlcommenter-trace-context/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlpackages/client/tests/e2e/sqlcommenter/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (38)
.github/workflows/test-template.yml(2 hunks)AGENTS.md(3 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/_steps.cts(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/package.json(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.ts(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prisma(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/readme.md(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts(1 hunks)packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.json(1 hunks)packages/sqlcommenter-query-insights/README.md(1 hunks)packages/sqlcommenter-query-insights/docs/embedder-guide.md(1 hunks)packages/sqlcommenter-query-insights/helpers/build.ts(1 hunks)packages/sqlcommenter-query-insights/package.json(1 hunks)packages/sqlcommenter-query-insights/src/format.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/format.ts(1 hunks)packages/sqlcommenter-query-insights/src/index.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/index.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/shape/shape.ts(1 hunks)packages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.ts(1 hunks)packages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.ts(1 hunks)packages/sqlcommenter-query-insights/tsconfig.build.json(1 hunks)packages/sqlcommenter-query-insights/tsconfig.json(1 hunks)packages/sqlcommenter/README.md(1 hunks)tsconfig.build.bundle.json(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript for new code in the Prisma monorepo
Files:
packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/format.tspackages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.tspackages/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/shape/shape.tspackages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.tspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/security.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.tspackages/sqlcommenter-query-insights/src/format.test.tspackages/sqlcommenter-query-insights/src/parameterize/parameterize.tspackages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/helpers/build.ts
**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.test.ts: Place test files alongside source files with.test.tsnaming convention, which are excluded from build output via esbuild config
Inline snapshots should be kept concise unless the exact message matters
Files:
packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.tspackages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.tspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/security.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.tspackages/sqlcommenter-query-insights/src/format.test.tspackages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.ts
tsconfig.build.bundle.json
📄 CodeRabbit inference engine (AGENTS.md)
Update
tsconfig.build.bundle.jsonundercompilerOptions.pathswith resolution paths for new workspace packages to enable go-to-definition in editors
Files:
tsconfig.build.bundle.json
AGENTS.md
📄 CodeRabbit inference engine (GEMINI.md)
Document agent capabilities, constraints, and behavior in AGENTS.md
Update
AGENTS.mdwhenever learning something new about the codebase that would be valuable for future tasks
Files:
AGENTS.md
packages/*/helpers/build.ts
📄 CodeRabbit inference engine (AGENTS.md)
packages/*/helpers/build.ts: For new packages, add ahelpers/build.tsfile to configure the build process
UseadapterConfigfromhelpers/compile/configs.tsfor type-only packages to bundle to both CJS and ESM with type declarations
Files:
packages/sqlcommenter-query-insights/helpers/build.ts
🧠 Learnings (23)
📓 Common learnings
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/migrate/src/__tests__/fixtures/**/*.config.ts : CLI test fixtures should provide `prisma.config.ts` per schema variant (e.g., `invalid-url.config.ts` next to `prisma/invalid-url.prisma`)
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Run client e2e suites with `pnpm --filter prisma/client test:e2e --verbose --runInBand` after fresh `pnpm build`
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/migrate/src/__tests__/fixtures/**/*.config.ts : CLI test fixtures should provide `prisma.config.ts` per schema variant (e.g., `invalid-url.config.ts` next to `prisma/invalid-url.prisma`)
Applied to files:
packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.tspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/security.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.tspackages/sqlcommenter-query-insights/src/format.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prismapackages/client/tests/e2e/sqlcommenter-query-insights/package.jsonpackages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.tstsconfig.build.bundle.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tspackages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.tsAGENTS.mdpackages/client/tests/e2e/sqlcommenter-query-insights/_steps.ctspackages/sqlcommenter-query-insights/tsconfig.json
📚 Learning: 2025-12-04T13:56:31.584Z
Learnt from: aqrln
Repo: prisma/prisma PR: 28830
File: packages/sqlcommenter-query-insights/src/format.ts:22-47
Timestamp: 2025-12-04T13:56:31.584Z
Learning: In packages/sqlcommenter-query-insights/src/format.ts, compacted batches (type === 'batch' in SqlCommenterQueryInfo) always have a modelName defined, so no guard for missing modelName is required in the batch branch of formatQueryInsight().
Applied to files:
packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.tspackages/sqlcommenter-query-insights/docs/embedder-guide.mdpackages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/format.tspackages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.tspackages/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/shape/shape.tspackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.tspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/format.test.tspackages/sqlcommenter-query-insights/README.mdpackages/sqlcommenter-query-insights/tsconfig.json
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to **/*.test.ts : Inline snapshots should be kept concise unless the exact message matters
Applied to files:
packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to **/*.ts : Use TypeScript for new code in the Prisma monorepo
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/tsconfig.build.jsontsconfig.build.bundle.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tsAGENTS.mdpackages/sqlcommenter-query-insights/tsconfig.json
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to **/*.test.ts : Place test files alongside source files with `.test.ts` naming convention, which are excluded from build output via esbuild config
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/tsconfig.json
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client-generator-{js,ts}/src/**/*.ts : Use `prisma/ts-builders` for generating TypeScript type declarations
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/shape/shape.tspackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prismapackages/sqlcommenter-query-insights/src/parameterize/parameterize.tstsconfig.build.bundle.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tsAGENTS.mdpackages/sqlcommenter-query-insights/helpers/build.tspackages/sqlcommenter-query-insights/tsconfig.json
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client-generator-js/src/TSClient/PrismaClient.ts : In PrismaClient constructor options, update generated types in `packages/client-generator-js/src/TSClient/PrismaClient.ts` (`buildClientOptions` method)
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/shape/shape.tspackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prismapackages/sqlcommenter-query-insights/src/parameterize/parameterize.tstsconfig.build.bundle.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tsAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to tsconfig.build.bundle.json : Update `tsconfig.build.bundle.json` under `compilerOptions.paths` with resolution paths for new workspace packages to enable go-to-definition in editors
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/tsconfig.build.jsontsconfig.build.bundle.jsonpackages/sqlcommenter-query-insights/tsconfig.json
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/migrate/src/__tests__/**/*.test.ts : In CLI test fixtures, use `ctx.setConfigFile('<name>')` to override the config used for the next CLI invocation
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/_steps.cts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/migrate/src/__tests__/**/*.test.ts : Use `ctx.setDatasource()` test helper to override config.datasource for connection-specific test scenarios
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.tspackages/sqlcommenter-query-insights/src/index.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.tspackages/sqlcommenter-query-insights/src/format.test.tspackages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.ts.github/workflows/test-template.ymlpackages/client/tests/e2e/sqlcommenter-query-insights/_steps.cts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client-generator-ts/src/TSClient/file-generators/PrismaNamespaceFile.ts : In PrismaClient constructor options, update generated types in `packages/client-generator-ts/src/TSClient/file-generators/PrismaNamespaceFile.ts` (`buildClientOptions` function)
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/src/index.tspackages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prismapackages/sqlcommenter-query-insights/src/parameterize/parameterize.tstsconfig.build.bundle.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tsAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/*/helpers/build.ts : Use `adapterConfig` from `helpers/compile/configs.ts` for type-only packages to bundle to both CJS and ESM with type declarations
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.jsonpackages/sqlcommenter-query-insights/tsconfig.build.jsontsconfig.build.bundle.jsonpackages/sqlcommenter-query-insights/helpers/build.ts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client/src/runtime/utils/validatePrismaClientOptions.ts : In PrismaClient constructor options, add validation to `packages/client/src/runtime/utils/validatePrismaClientOptions.ts` by updating the `knownProperties` array and `validators` object
Applied to files:
packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.ts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Run client e2e suites with `pnpm --filter prisma/client test:e2e --verbose --runInBand` after fresh `pnpm build`
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/sqlcommenter-query-insights/src/index.test.tspackages/client/tests/e2e/sqlcommenter-query-insights/package.jsonAGENTS.mdpackages/client/tests/e2e/sqlcommenter-query-insights/_steps.cts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Run client functional tests via `pnpm --filter prisma/client test:functional` with typechecking or `pnpm --filter prisma/client test:functional:code` for code only
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.tspackages/client/tests/e2e/sqlcommenter-query-insights/readme.mdpackages/sqlcommenter-query-insights/src/index.test.tsAGENTS.md.github/workflows/test-template.ymlpackages/client/tests/e2e/sqlcommenter-query-insights/_steps.cts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/{package.json,tsconfig.json,tsconfig.build.json} : For new packages, create `package.json`, `tsconfig.json`, and `tsconfig.build.json` configuration files
Applied to files:
packages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/client/tests/e2e/sqlcommenter-query-insights/package.jsonpackages/sqlcommenter-query-insights/tsconfig.json
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/*/helpers/build.ts : For new packages, add a `helpers/build.ts` file to configure the build process
Applied to files:
packages/sqlcommenter-query-insights/tsconfig.build.jsonpackages/sqlcommenter-query-insights/helpers/build.ts
📚 Learning: 2025-12-03T10:49:29.006Z
Learnt from: aqrln
Repo: prisma/prisma PR: 28802
File: packages/client/package.json:208-215
Timestamp: 2025-12-03T10:49:29.006Z
Learning: In packages/client/package.json, dependencies like prisma/instrumentation-contract that are bundled during the build process should remain in devDependencies, not moved to runtime dependencies, because the bundler inlines the code into the runtime output.
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/package.jsontsconfig.build.bundle.jsonAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client/src/runtime/core/engines/common/Engine.ts : In PrismaClient constructor options, update engine config in `EngineConfig` interface in `packages/client/src/runtime/core/engines/common/Engine.ts`
Applied to files:
packages/sqlcommenter-query-insights/src/parameterize/parameterize.tspackages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tsAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to packages/client/src/runtime/getPrismaClient.ts : In PrismaClient constructor options, add runtime types to `PrismaClientOptions` in `packages/client/src/runtime/getPrismaClient.ts`
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.ts
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Commands and tests should read connection settings from `PrismaConfigInternal.datasource` rather than CLI flags or environment loading
Applied to files:
packages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.tsAGENTS.md
📚 Learning: 2025-12-03T09:46:36.091Z
Learnt from: CR
Repo: prisma/prisma PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T09:46:36.091Z
Learning: Applies to AGENTS.md : Update `AGENTS.md` whenever learning something new about the codebase that would be valuable for future tasks
Applied to files:
AGENTS.md
🧬 Code graph analysis (21)
packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.ts (1)
packages/sqlcommenter-query-insights/src/shape/shape.ts (1)
shapeQuery(56-81)
packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
parameterizeQuery(384-394)
packages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts (2)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
PARAM_PLACEHOLDER(13-13)packages/sqlcommenter-query-insights/src/index.ts (1)
prismaQueryInsights(28-33)
packages/sqlcommenter-query-insights/src/format.ts (2)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
parameterizeQuery(384-394)packages/sqlcommenter-query-insights/src/shape/shape.ts (1)
shapeQuery(56-81)
packages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.ts (1)
packages/sqlcommenter-query-insights/src/shape/shape.ts (1)
shapeQuery(56-81)
packages/sqlcommenter-query-insights/src/index.ts (1)
packages/sqlcommenter-query-insights/src/format.ts (1)
formatQueryInsight(22-47)
packages/sqlcommenter-query-insights/src/shape/shape.ts (1)
packages/cli/src/platform/_lib/prelude.ts (1)
isObject(12-14)
packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/index.test.ts (1)
packages/sqlcommenter-query-insights/src/index.ts (1)
prismaQueryInsights(28-33)
packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
parameterizeQuery(384-394)
packages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
parameterizeQuery(384-394)
packages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.ts (1)
packages/sqlcommenter-query-insights/src/shape/shape.ts (1)
shapeQuery(56-81)
packages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.ts (1)
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (2)
parameterizeQuery(384-394)PARAM_PLACEHOLDER(13-13)
packages/sqlcommenter-query-insights/helpers/build.ts (1)
helpers/compile/configs.ts (1)
adapterConfig(37-37)
🪛 Gitleaks (8.30.0)
packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts
[high] 286-286: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
[high] 528-528: Found a Stripe Access Token, posing a risk to payment processing services and sensitive financial data.
(stripe-access-token)
🔇 Additional comments (69)
packages/sqlcommenter/README.md (1)
58-58: LGTM!The new plugin entry is properly documented and follows the established format for first-party plugins.
tsconfig.build.bundle.json (1)
37-37: LGTM!The path mapping for the new package follows the established pattern and enables go-to-definition in editors as required.
Based on coding guidelines, this update is necessary for proper IDE support.
packages/sqlcommenter-query-insights/helpers/build.ts (1)
1-4: LGTM!The build configuration follows the established pattern for new packages, using
adapterConfigto bundle to both CJS and ESM with type declarations.Based on coding guidelines, this is the correct approach for new packages.
packages/sqlcommenter-query-insights/tsconfig.json (1)
1-4: LGTM!The TypeScript configuration follows the standard pattern for new packages in the monorepo.
packages/sqlcommenter-query-insights/tsconfig.build.json (1)
1-8: LGTM!The build configuration correctly excludes test files and follows the established pattern for new packages in the monorepo.
AGENTS.md (3)
7-7: LGTM!Appropriately adds the new sqlcommenter packages to the key packages list.
51-59: LGTM!Comprehensive documentation of the SQL Commenter packages, covering core types, usage patterns, test locations, and the distinction between single and compacted query types.
Based on coding guidelines, updating AGENTS.md when learning about new codebase features is the correct approach.
68-71: LGTM!The coding conventions section clearly establishes naming patterns (kebab-case) and import practices (avoiding barrel files) that will help maintain consistency across the codebase.
packages/sqlcommenter-query-insights/package.json (1)
1-42: LGTM!The package manifest is well-structured with proper ESM/CJS dual exports, appropriate devDependencies, and standard build scripts using Vitest for testing.
packages/sqlcommenter-query-insights/src/parameterize/parameterize.ts (1)
1-394: LGTM!The parameterization logic implements a conservative, context-aware approach that safely masks user data while preserving structural query information. The implementation correctly handles:
- Tagged values (FieldRef preserved, Enum conditionally preserved, others parameterized)
- Structural keys and operators
- Selection contexts (booleans indicate field selection)
- OrderBy contexts (sort directions preserved)
- Filter operators (values parameterized)
- Nested relation operations
The strategy of erring on the side of parameterization (false positives acceptable, false negatives avoided) aligns well with the security-first goal of preventing user data leakage into query comments.
packages/client/tests/e2e/sqlcommenter-query-insights/tsconfig.json (1)
1-9: E2E tsconfig matches NodeNext/step-driver conventionsExtending the shared base, excluding
_steps.cts, and usingESNext+NodeNext/nodenextis consistent and should work fine for this E2E package..github/workflows/test-template.yml (1)
967-970: CI wiring forsqlcommenter-query-insightsis consistent with existing sqlcommenter packagesBoth new steps (Linux “others” and no-docker mac/win) mirror the patterns used for
sqlcommenter-query-tagsandsqlcommenter-trace-context(samepnpm run test, naming, and working-directory), so this should integrate cleanly into the existing matrix.Also applies to: 1350-1354
packages/client/tests/e2e/sqlcommenter-query-insights/package.json (1)
1-24: E2E package.json structure and dependencies look correctUsing local
/tmp/*.tgztarballs, keeping the package private, and restrictingonlyBuiltDependenciestobetter-sqlite3match the established E2E test package pattern.packages/client/tests/e2e/sqlcommenter-query-insights/prisma.config.ts (1)
1-7: Prisma config is minimal and appropriate for the SQLite E2E setupUsing
defineConfigwith afile:./dev.dbdatasource keeps the test self-contained and matches the expected config shape.packages/sqlcommenter-query-insights/src/parameterize/tests/selection-markers.test.ts (1)
1-135: Good coverage of selection marker preservation in parameterizationThese tests comprehensively assert that
$scalars/$compositesflags (including false values and nested relation selections) surviveparameterizeQueryunchanged, which guards against regressions in selection-shape handling.packages/client/tests/e2e/sqlcommenter-query-insights/readme.md (1)
1-20: E2E README accurately documents test goals and local run stepsThe description of what’s being verified and the run commands match the implemented flow, making it easy to understand and reproduce the scenario locally.
packages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.ts (1)
1-105: Scalar/nullable parameterization behavior is well specifiedThese tests clearly define the contract that string/number/boolean filter values become
PARAM_PLACEHOLDERwhilenullandundefinedare preserved, which is important both for privacy and semantic correctness in filters.packages/client/tests/e2e/sqlcommenter-query-insights/_steps.cts (1)
1-20: E2E step driver aligns with existing executeSteps-based flowsThe setup/test/finish phases (install, generate,
db push --force-reset, runsrc/index.tsvia tsx, and type-check withtsc --noEmit) match the documented README flow and typical client E2E conventions.packages/sqlcommenter-query-insights/src/parameterize/tests/relation-filters.test.ts (5)
1-4: LGTM!Imports are correct and follow the project conventions. The test file is properly co-located with the source as per coding guidelines.
6-54: LGTM!Good coverage of the
somerelation filter operator, including complex nested conditions with logical operators.
56-106: LGTM!Proper coverage of the
everyrelation filter operator with both single and multiple conditions.
108-156: LGTM!Good coverage of the
nonerelation filter operator, including nested filter operators likeendsWith.
158-274: LGTM!Excellent coverage of nested relation filters including deeply nested structures, multiple relation filters at the same level, combinations with field filters, and usage within logical operators.
packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.ts (4)
1-4: LGTM!Imports are correct. Using fast-check for property-based testing is an excellent choice for validating parameterization safety guarantees.
16-28: LGTM!The canary-based detection approach is elegant and effective for verifying that user data doesn't leak into parameterized output.
390-461: LGTM!Excellent property-based tests for data leakage prevention. The combination of randomly generated query shapes with canary value detection provides strong confidence in parameterization safety.
463-569: LGTM!Good structural guarantee tests covering determinism, idempotence, JSON serializability, and preservation of structural values like
null,take,skip,orderBydirections, and selection markers.packages/sqlcommenter-query-insights/src/parameterize/tests/edge-cases.test.ts (5)
1-4: LGTM!Imports are correct and follow project conventions.
6-60: LGTM!Good coverage of empty structure edge cases, ensuring they're preserved correctly without causing errors.
62-82: LGTM!Correctly tests queries with missing or empty arguments.
84-100: LGTM!Good coverage of top-level primitive inputs. The behavior of preserving
null/undefinedwhile parameterizing other primitives is correct.
102-160: LGTM!Good coverage of mixed arrays and deeply nested structures. These tests validate that the recursive parameterization correctly handles arbitrary nesting depth.
packages/sqlcommenter-query-insights/src/parameterize/tests/tagged-values.test.ts (4)
1-4: LGTM!Imports are correct and follow project conventions.
6-144: LGTM!Comprehensive coverage of all tagged value types (DateTime, Decimal, BigInt, Bytes, Json, Enum, Raw). Each test correctly verifies that tagged user data values are parameterized.
146-165: LGTM!Important test verifying that
FieldReftagged values are preserved as structural values rather than being parameterized. This is correct since field references are part of the query structure, not user data.
167-242: LGTM!Good coverage of tagged values in various contexts: data context, nested filter operators, and arrays. This ensures consistent parameterization behavior regardless of where tagged values appear.
packages/sqlcommenter-query-insights/src/parameterize/tests/data-context.test.ts (8)
1-4: LGTM!Imports are correct and follow project conventions.
6-54: LGTM!Good coverage of basic data operations with proper null preservation. This ensures
nullvalues (which have semantic meaning) are preserved while user data is parameterized.
56-156: LGTM!Comprehensive coverage of nested relation create operations including single objects, arrays, and
createMany. All data values are correctly parameterized.
158-244: LGTM!Good coverage of connect operations including single connect, array connect, and
connectOrCreate. All identifier and data values are correctly parameterized.
246-368: LGTM!Good coverage of disconnect and set operations. The parameterization of boolean
disconnectvalues is consistent with the approach of parameterizing all data values.
370-522: LGTM!Comprehensive coverage of update and upsert operations including nested updates, updates with where clauses,
updateMany, and all upsert variants.
524-624: LGTM!Good coverage of delete operations including single deletes, array deletes, boolean deletes, and
deleteManywith where clauses.
626-712: LGTM!Excellent coverage of complex nested data operations. The deeply nested relation creates test (user → posts → comments → author) validates that parameterization correctly handles arbitrary nesting depth in data contexts.
packages/sqlcommenter-query-insights/README.md (1)
1-120: Excellent documentation structure and content.The README is comprehensive, well-organized, and provides clear examples for users. The security section appropriately emphasizes that user data is never included in comments, and the examples effectively demonstrate the plugin's capabilities.
packages/sqlcommenter-query-insights/src/parameterize/tests/filter-operators.test.ts (1)
1-569: Comprehensive and well-structured test coverage.The test suite thoroughly covers all filter operator categories with clear, descriptive test cases. The tests appropriately validate that sensitive values are parameterized while structural information (like
mode: 'insensitive') is preserved.packages/sqlcommenter-query-insights/src/shape/tests/basic-shaping.test.ts (1)
1-206: Well-organized test suite with clear transformations.The tests effectively validate the core shaping functionality, clearly demonstrating the transformation from internal query format to Prisma-like format. The coverage includes important edge cases like empty arguments and false value preservation.
packages/sqlcommenter-query-insights/src/parameterize/tests/complex-queries.test.ts (1)
1-553: Excellent coverage of complex query scenarios.The test suite comprehensively validates parameterization behavior across deeply nested queries, mutations, and complex relation traversals. The tests appropriately verify that structural values are preserved while sensitive data is parameterized.
packages/sqlcommenter-query-insights/src/shape/tests/nested-relations.test.ts (1)
1-409: Thorough testing of nested relation transformations.The test suite effectively validates complex nested relation scenarios, including proper handling of mixed include/select patterns and simplification logic. The use of ARGS constants improves test readability.
packages/sqlcommenter-query-insights/src/index.ts (1)
1-33: Clean and well-documented plugin implementation.The plugin factory function is concise and well-documented with comprehensive JSDoc. The implementation correctly delegates to
formatQueryInsightand returns the expectedSqlCommenterPlugininterface.packages/sqlcommenter-query-insights/docs/embedder-guide.md (1)
1-305: Comprehensive and practical integration guide.The embedder guide provides excellent technical documentation for third-party integrators. The JavaScript examples are practical, the payload structure is well-documented, and the best practices section appropriately guides defensive parsing for forward compatibility.
packages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.ts (1)
1-373: Thorough coverage of logical operator scenarios.The test suite comprehensively validates logical operator parameterization, including important edge cases like null handling and complex nested combinations. The tests appropriately verify that logical structure is preserved while values are parameterized.
packages/sqlcommenter-query-insights/src/parameterize/tests/order-by-and-pagination.test.ts (2)
1-201: Good test coverage for orderBy scenarios.The tests comprehensively cover simple, shorthand, nested, and aggregate orderBy formats, correctly asserting that sort directions (
asc,desc) and nulls handling (first,last) are preserved as structural values.
203-415: Pagination tests are well-structured.The tests correctly verify that
takeandskipvalues are preserved (including edge cases like negative take and zero skip), whilecursorvalues are properly parameterized withPARAM_PLACEHOLDER. The combined scenarios withwhereclauses demonstrate correct behavior across different query argument types.packages/sqlcommenter-query-insights/src/index.test.ts (3)
6-28: Well-designed test helpers.The helper functions are concise and reusable.
parseQueryInsightcorrectly handles both raw queries (no colon) and encoded payloads. Consider adding a brief JSDoc comment toparseQueryInsightexplaining the expected format (prefix:base64payloador justprefix).
30-116: Comprehensive plugin behavior tests.The test suite covers essential plugin behaviors: tag presence, raw query formatting, model/action prefixes, data parameterization, batch query handling, and instance isolation. The assertions are clear and focused.
118-165: Good coverage for orderBy preservation.Both shorthand (
createdAt: 'desc') and long format ({ sort: 'desc', nulls: 'last' }) are tested to ensure structural values are preserved in the payload. This aligns with the parameterization logic that treats sort directions as structural enums.packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts (2)
1-62: Solid security test foundation.The test suite establishes a clear pattern for verifying that sensitive data doesn't leak through parameterization. The
sensitiveValuesarray provides good coverage of common sensitive data patterns.
103-472: Excellent coverage of filter and operator scenarios.The tests comprehensively cover all filter operators (
in,notIn,contains,startsWith, etc.), array operators (has,hasEvery,hasSome), JSON path queries, and JSON string/array operators. This provides strong confidence in the parameterization security guarantees.packages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts (2)
117-153: Well-structured verification helper.The
verifyQueryfunction provides clear error messages with query descriptions and payload dumps on failure. ThenotContainscheck correctly usesString.includes()without unnecessary escaping.
1-112: Good E2E test structure.The test covers a representative set of Prisma operations and validates that the plugin correctly formats
prismaQuerycomments with parameterized payloads. The query capture mechanism via Prisma's event system is appropriate for E2E validation.packages/sqlcommenter-query-insights/src/shape/tests/edge-cases.test.ts (5)
5-54: Excellent null/undefined and empty object coverage.The tests correctly verify that
shapeQueryhandles edge cases gracefully: primitives pass through unchanged, empty objects return empty results, and$compositesalone doesn't produce output without$scalars.
56-133: Good coverage of selection marker behaviors.The tests clearly demonstrate how
$scalars: truevs$scalars: falseaffect output, and how relations are handled when no explicit$scalarsis present at the top level.
135-255: Comprehensive argument and relation structure tests.The tests verify that complex nested arguments (AND conditions, orderBy arrays, deeply nested data) are preserved, and that relations with various argument/selection combinations are correctly transformed.
296-311: Clear test description for$scalarsoverride behavior.The test name accurately describes that when
$scalars: trueis present, explicit boolean field selections (name: true,email: true) are redundant and the result omits them. This correctly reflects the documented shapeQuery behavior.
360-419: Good edge case coverage for relation simplification.The tests demonstrate when relations can be simplified to
true(only$scalars/$composites) versus when they must be expanded (nested relations or additional fields). This covers important optimization paths in the shapeQuery logic.packages/sqlcommenter-query-insights/src/format.ts (1)
6-11: Base64url helper is straightforward and correctUsing
Buffer.from(data, 'utf-8').toString('base64url')gives URL‑safe, padding‑free output without any manual replacements, which is ideal for compact comment payloads.packages/sqlcommenter-query-insights/src/format.test.ts (1)
7-22: Test helpers nicely mirror the production codec
fromBase64UrlandparseQueryInsightgive a clean, symmetric way to assert on decoded payloads and prefixes, which keeps the tests focused on semantics rather than encoding details.packages/client/tests/e2e/sqlcommenter-query-insights/prisma/schema.prisma (1)
6-8: Ensure matchingprisma.config.tsdefines the datasource URLThis schema relies on the newer Prisma config flow, with a datasource that specifies only the provider. Please double‑check that the corresponding
prisma.config.tsfor this e2e fixture definesdatasource.url(andengine, if required) so that CLI commands and client generation can connect to the SQLite database correctly. (prisma.io)
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts
Outdated
Show resolved
Hide resolved
0449b96 to
ea902f6
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (6)
packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.ts (1)
145-152: Consider simplifying the combined arbitrary.The
Object.fromEntries([['field1', ...]])pattern is verbose; a direct object literal would be cleaner.packages/sqlcommenter-query-insights/src/parameterize/tests/security.test.ts (1)
286-301: Update secret‑like dummy literals to avoid Gitleaks false positives.The tests correctly assert that sensitive‑looking data never appears in the parameterized output, but the specific strings:
"test-api-key-12345"in the tagged Json test, and'sk_test_abcdefghijklmnop'in the combined sensitiveData samplestill match common generic API key / Stripe token patterns, which keeps Gitleaks noisy. This repeats the earlier feedback and appears unresolved in the current snapshot.
You can keep the same security semantics (the strings must not appear) while switching to obviously non-real placeholders:
- it('does not leak tagged Json values', () => { - const jsonValue = '{"secret":"test-api-key-12345"}' + it('does not leak tagged Json values', () => { + const jsonValue = '{"secret":"NOT_A_REAL_API_KEY_12345"}' @@ - const resultStr = JSON.stringify(result) - expect(resultStr).not.toContain(jsonValue) - expect(resultStr).not.toContain('test-api-key-12345') + const resultStr = JSON.stringify(result) + expect(resultStr).not.toContain(jsonValue) + expect(resultStr).not.toContain('NOT_A_REAL_API_KEY_12345') @@ - apiKey: 'sk_test_abcdefghijklmnop', + apiKey: 'NOT_A_REAL_STRIPE_KEY_abcdefghijklmnop',This keeps coverage intact (these values must not appear) while avoiding patterns that look like real secrets to scanners.
Also applies to: 523-568
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts (1)
222-263: Hard-coded query indices remain fragile.This is a duplicate of a past review comment. The tests still rely on fixed indices into
capturedQueries(indices 6, 8, 9) with manual adjustments for operations generating multiple queries. A more resilient approach would locate queries by inspectingprismaQueryprefixes.packages/sqlcommenter-query-insights/src/shape/shape.ts (1)
14-16:isObjectshould exclude arrays for robustness.This was flagged in a past review. The current implementation returns
truefor arrays, which could cause unexpected behavior if arrays appear in selection contexts. The fix frompackages/cli/src/platform/_lib/prelude.tsshows the preferred pattern:function isObject(value: unknown): value is Obj { - return typeof value === 'object' && value !== null + return typeof value === 'object' && value !== null && !Array.isArray(value) }packages/sqlcommenter-query-insights/src/format/format.ts (1)
22-46: Consider exhaustive type handling for future-proofing.The current if/else pattern handles
type === 'single'explicitly but treats any other type as a compacted batch. IfSqlCommenterQueryInfogains additional type variants in the future, they would silently fall through to the batch branch without compile-time detection.Consider using a switch statement with explicit cases and a default branch that throws or calls an
assertNeverhelper to ensure exhaustive handling:export function formatQueryInsight(queryInfo: SqlCommenterQueryInfo): string { - if (queryInfo.type === 'single') { + switch (queryInfo.type) { + case 'single': { - const { modelName, action, query } = queryInfo + const { modelName, action, query } = queryInfo - // Raw queries don't have a model and we skip the query payload - if (!modelName) { - return action - } + // Raw queries don't have a model and we skip the query payload + if (!modelName) { + return action + } - // Parameterize, shape, and encode the query - const parameterizedQuery = parameterizeQuery(query) - const shapedQuery = shapeQuery(parameterizedQuery) - const encoded = toBase64Url(JSON.stringify(shapedQuery)) + // Parameterize, shape, and encode the query + const parameterizedQuery = parameterizeQuery(query) + const shapedQuery = shapeQuery(parameterizedQuery) + const encoded = toBase64Url(JSON.stringify(shapedQuery)) - return `${modelName}.${action}:${encoded}` - } + return `${modelName}.${action}:${encoded}` + } - // Compacted batch - const { modelName, action, queries } = queryInfo + case 'compacted': { + // Compacted batch + const { modelName, action, queries } = queryInfo - // Parameterize and shape each query in the batch - const shapedQueries = queries.map((q) => shapeQuery(parameterizeQuery(q))) - const encoded = toBase64Url(JSON.stringify(shapedQueries)) + // Parameterize and shape each query in the batch + const shapedQueries = queries.map((q) => shapeQuery(parameterizeQuery(q))) + const encoded = toBase64Url(JSON.stringify(shapedQueries)) - return `${modelName}.${action}:${encoded}` + return `${modelName}.${action}:${encoded}` + } + + default: + // Exhaustiveness check - will cause a compile error if a new type is added + const _exhaustive: never = queryInfo + throw new Error(`Unhandled query info type: ${(_exhaustive as any).type}`) + } }packages/sqlcommenter-query-insights/src/format/format.test.ts (1)
291-309: Strengthen the special characters test to verify actual parameterization.The current test only verifies that the base64url-encoded result doesn't contain
specialValue, which would be true even if parameterization failed (since base64 encoding inherently obscures the raw input). To verify that sensitive values are actually parameterized rather than merely hidden by encoding, decode the payload and assert the parameter values are replaced withPARAM_PLACEHOLDER.Apply this diff to strengthen the test:
const result = formatQueryInsight(queryInfo) - // Should not contain the special value + // Should not contain the special value in the encoded string expect(result).not.toContain(specialValue) - // Should still be valid - expect(() => parseQueryInsight(result)).not.toThrow() + + // Verify the decoded payload has parameterized the sensitive value + const parsed = parseQueryInsight(result) + expect(parsed.payload).toEqual({ + where: { name: PARAM_PLACEHOLDER }, + })
94d4cf8 to
8da276b
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (2)
packages/sqlcommenter-query-insights/src/parameterize/tests/basic-values.test.ts (1)
1-105: Basic value behavior is well covered; same note about placeholder coupling as aboveThe tests correctly lock in the expected behavior for scalars vs null/undefined in filter context.
As in the logical-operators tests, if you want to avoid tests depending on the exact structure of the internal placeholder, you could define a local
PARAM_PLACEHOLDERconstant here instead of importing it from../parameterize, and assert against that.packages/sqlcommenter-query-insights/src/format/format.test.ts (1)
291-309: Strengthen the “special characters” test to assert parameterization, not just encodingRight now this test only checks that the formatted string doesn’t contain
specialValue, which would be true even if the raw value were still present in the JSON payload (base64url already hides it). To ensure we actually parameterize the value, also assert on the decoded payload:const result = formatQueryInsight(queryInfo) - // Should not contain the special value - expect(result).not.toContain(specialValue) - // Should still be valid - expect(() => parseQueryInsight(result)).not.toThrow() + // Should not contain the special value in the encoded comment + expect(result).not.toContain(specialValue) + + const parsed = parseQueryInsight(result) + // After shaping + parameterization, the raw value should be replaced + expect(parsed.prefix).toBe('User.findFirst') + expect(parsed.payload).toEqual({ + where: { name: PARAM_PLACEHOLDER }, + })This keeps the existing safety check while directly validating that the special-character value is replaced by the placeholder in the decoded payload.
packages/sqlcommenter-query-insights/src/parameterize/tests/logical-operators.test.ts
Show resolved
Hide resolved
8da276b to
dc8f41a
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (2)
packages/sqlcommenter-query-insights/src/format/format.test.ts (1)
291-309: Consider asserting the decoded payload for the special‑characters test.Right now this test only checks that the encoded string doesn’t contain
specialValueand that parsing doesn’t throw, which base64url already guarantees even without parameterization. To better guard against regressions, you could also assert on the decoded payload, for example:const result = formatQueryInsight(queryInfo) // Should not contain the special value expect(result).not.toContain(specialValue) - // Should still be valid - expect(() => parseQueryInsight(result)).not.toThrow() + const parsed = parseQueryInsight(result) + // After shaping + parameterization, the raw value should be replaced + expect(parsed.payload).toEqual({ + where: { name: PARAM_PLACEHOLDER }, + })This keeps the current safety check while also verifying that parameterization actually strips the raw value from the structured payload.
packages/client/tests/e2e/sqlcommenter-query-insights/src/index.ts (1)
1-313: E2E harness for prismaQuery insights is solid and focusedThe end-to-end test wiring (BetterSQLite adapter, query event capture,
extractPrismaQuery/parsePrismaQuery,flushQueries, andverifyQueries) is clean and robust. Each logical operation is isolated viaflushQueries, and the assertions on prefixes, payload structure, and absence of secrets inprismaQueryprovide good coverage of the plugin’s behavior. DuplicatingPARAM_PLACEHOLDERlocally here (instead of importing from the package) is appropriate since it’s an internal implementation detail.
packages/sqlcommenter-query-insights/src/parameterize/tests/properties.test.ts
Show resolved
Hide resolved
FGoessler
left a comment
There was a problem hiding this comment.
Crazy level of testing ! I like 🫶
Implement
@prisma/sqlcommenter-query-insightsplugin. The documentation is currently very generic and doesn't talk about Prisma Postgres because the corresponding functionality isn't yet available in Console. Once it is, the README will be rewritten to be Prisma Postgres centric (although third-party observability providers like Datadog, Sentry etc can also make use of this to provide new cool features for Prisma users).In the future parameterization will happen in core using the query schema aka DMMF, which is also necessary for query plan caching. For now the plugin temporarily implements its own best-effort parameterization logic, which preserves the hardcoded list of values which are explicitly allowed in certain contexts, and errs on the side of parameterizing everything else.
Closes: https://linear.app/prisma-company/issue/TML-1645/build-ppg-query-insights-plugin
Summary by CodeRabbit
New Features
Documentation
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.