Skip to content

Commit 4926bf0

Browse files
Merge branch 'prisma:main' into fix/mssql-connection-pool-exhaustion
2 parents a7b352f + 44cac9f commit 4926bf0

61 files changed

Lines changed: 2685 additions & 113 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-template.yml

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -707,39 +707,38 @@ jobs:
707707

708708
#
709709
# INTEGRATION-TESTS
710-
# TODO: re-enable once they're ported to the Query Compiler architecture.
711710
#
712-
# integration-tests:
713-
# name: Integration tests
714-
# timeout-minutes: 20
715-
# runs-on: ubuntu-latest
716-
# if: |
717-
# contains(inputs.jobsToRun, '-all-') ||
718-
# contains(inputs.jobsToRun, '-integration-tests-')
719-
# strategy:
720-
# fail-fast: false
721-
# matrix:
722-
# node: ['20.19.0']
723-
# steps:
724-
# - uses: actions/checkout@v4
725-
726-
# - name: Start Docker Compose Services
727-
# uses: nick-fields/retry@v3
728-
# with:
729-
# timeout_minutes: 10
730-
# max_attempts: 5
731-
# retry_wait_seconds: 120
732-
# command: docker compose -f docker/docker-compose.yml up --wait --detach postgres mysql mariadb mssql
733-
734-
# - name: Install & build
735-
# uses: ./.github/actions/setup
736-
# with:
737-
# node-version: ${{ matrix.node }}
738-
# engine-hash: ${{ inputs.engineHash }}
739-
# skip-tsc: true
740-
741-
# - run: pnpm run test
742-
# working-directory: packages/integration-tests
711+
integration-tests:
712+
name: Integration tests
713+
timeout-minutes: 20
714+
runs-on: ubuntu-latest
715+
if: |
716+
contains(inputs.jobsToRun, '-all-') ||
717+
contains(inputs.jobsToRun, '-integration-tests-')
718+
strategy:
719+
fail-fast: false
720+
matrix:
721+
node: ['20.19.0']
722+
steps:
723+
- uses: actions/checkout@v4
724+
725+
- name: Start Docker Compose Services
726+
uses: nick-fields/retry@v3
727+
with:
728+
timeout_minutes: 10
729+
max_attempts: 5
730+
retry_wait_seconds: 120
731+
command: docker compose -f docker/docker-compose.yml up --wait --detach postgres mysql mariadb mssql
732+
733+
- name: Install & build
734+
uses: ./.github/actions/setup
735+
with:
736+
node-version: ${{ matrix.node }}
737+
engine-hash: ${{ inputs.engineHash }}
738+
skip-tsc: true
739+
740+
- run: pnpm run test
741+
working-directory: packages/integration-tests
743742

744743
#
745744
# `@prisma/internals`

AGENTS.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
## Prisma Repository – Agent Field Notes
22

3+
> **Meta note**: This is the primary agent knowledge base file. `CLAUDE.md` and `GEMINI.md` are symlinks to this file—always edit `AGENTS.md` directly. When learning something new about the codebase that would help with future tasks, update this file immediately.
4+
35
- **Repository scope**: Monorepo for Prisma ORM, CLI, client, tests, etc. Many packages use TypeScript, Rust and WebAssembly (via engines), TSX, and Jest; automation relies on `pnpm`. Expect large fixture directories and generated files.
4-
- **Workspace layout**: Managed via pnpm workspaces and Turborepo (`turbo.json`). Node 20+/22+/24+ and pnpm ≥10.15 are required (see root `package.json`). Top-level scripts (`pnpm build`, `pnpm dev`, `pnpm test`) delegate into `scripts/ci/publish.ts`; package-specific commands run with `pnpm --filter @prisma/<pkg> <script>`.
5-
- **Key packages**: `packages/cli` (Prisma CLI entry point), `packages/migrate` (migrate/db namespace + fixtures), `packages/client` (client runtime), `packages/client-generator-ts` (new `prisma-client` generator), `packages/client-generator-js` (traditional `prisma-client-js` generator), `packages/client-engine-runtime` (the core part of the new Rust binary free client based on Wasm query compiler, used by `ClientEngine` class in `packages/client`), `packages/config` (`PrismaConfigInternal` + loader), `packages/internals` (shared CLI + engine glue), `packages/engines` (Rust binaries download wrapper), `packages/integration-tests` (matrix suites), and numerous driver adapters under `packages/adapter-*`.
6+
- **Workspace layout**: Managed via pnpm workspaces and Turborepo (`turbo.json`). Node 20+/22+/24+ and pnpm ≥10.15 are required (see root `package.json`). Top-level scripts (`pnpm build`, `pnpm dev`, `pnpm test`) delegate into `scripts/ci/publish.ts`; package-specific commands run with `pnpm --filter @prisma/<pkg> <script>`. Turborepo caches builds; run `pnpm build` from root to build all packages in dependency order.
7+
- **Key packages**: `packages/cli` (Prisma CLI entry point), `packages/migrate` (migrate/db namespace + fixtures), `packages/client` (client runtime), `packages/client-generator-ts` (new `prisma-client` generator), `packages/client-generator-js` (traditional `prisma-client-js` generator), `packages/client-engine-runtime` (the core part of the new Rust binary free client based on Wasm query compiler, used by `ClientEngine` class in `packages/client`), `packages/config` (`PrismaConfigInternal` + loader), `packages/internals` (shared CLI + engine glue), `packages/engines` (Rust binaries download wrapper), `packages/integration-tests` (matrix suites), `packages/query-plan-executor` (standalone query plan executor service for Prisma Accelerate), and numerous driver adapters under `packages/adapter-*`.
68
- **Driver adapters & runtimes**: `packages/bundled-js-drivers` plus the `adapter-*` packages ship experimental JS driver adapters (Planetscale, Neon, libsql, D1, etc.) built on helpers in `driver-adapter-utils`; migrate/client fixtures exercise them, so adapter changes typically require fixture/test updates.
7-
- **Build & tooling**: Typescript-first repo with WASM/Rust assets (downloaded by `@prisma/engines`). Multiple `tsconfig.*` drive bundle vs runtime builds. Lint via `pnpm lint`, format via `pnpm format`. Maintenance scripts live in `scripts/` (e.g. `bump-engines.ts`, `bench.ts`, `ci/publish.ts` orchestrates build/test/publish flows).
9+
- **Build & tooling**: Typescript-first repo with WASM/Rust assets (downloaded by `@prisma/engines`). Multiple `tsconfig.*` drive bundle vs runtime builds. Lint via `pnpm lint`, format via `pnpm format`. Maintenance scripts live in `scripts/` (e.g. `bump-engines.ts`, `bench.ts`, `ci/publish.ts` orchestrates build/test/publish flows). Build configuration uses esbuild via `helpers/compile/build.ts` with configs in `helpers/compile/configs.ts`. Most packages use `adapterConfig` which bundles to both CJS and ESM with type declarations.
810
- **Testing & databases**: `TESTING.md` covers Jest/Vitest usage. Most suites run as `pnpm --filter @prisma/<pkg> test <pattern>`. DB-backed tests expect `.db.env` and Docker services from `docker/docker-compose.yml` (`docker compose up -d`). Client functional tests sit in `packages/client/tests/functional`—run them via `pnpm --filter @prisma/client test:functional` (with typechecking) or `pnpm --filter @prisma/client test:functional:code` (code only); `helpers/functional-test/run-tests.ts` documents CLI flags to target providers, drivers, etc. Client e2e suites require a fresh `pnpm build` at repo root, then `pnpm --filter @prisma/client test:e2e --verbose --runInBand`. The legacy `pnpm --filter @prisma/client test` command primarily runs the older Jest unit tests plus `tsd` type checks. Migrate CLI suites live in `packages/migrate/src/__tests__`, the CLI runs both Jest (legacy suites) and Vitest (new subcommand coverage) via `pnpm --filter prisma test`, and end-to-end coverage lives in `packages/integration-tests`.
911
- **Docs & references**: `ARCHITECTURE.md` contains dependency graphs (requires GraphViz to regenerate), `docker/README.md` explains local DB setup, `examples/` provides sample apps, and `sandbox/` hosts debugging helpers like the DMMF explorer.
1012

13+
- **Client architecture (Prisma 7)**:
14+
- `ClientEngine` in `packages/client/src/runtime/core/engines/client/` orchestrates query execution using WASM query compiler.
15+
- Two executor implementations: `LocalExecutor` (driver adapters, direct DB) and `RemoteExecutor` (Accelerate/Data Proxy).
16+
- `QueryInterpreter` in `packages/client-engine-runtime/src/interpreter/` executes query plans against `SqlQueryable` (driver adapter interface).
17+
- Query flow: `PrismaClient``ClientEngine.request()` → query compiler → `executor.execute()``QueryInterpreter.run()` → driver adapter.
18+
- `ExecutePlanParams` interface defines what's passed through the execution chain.
19+
20+
- **Adding PrismaClient constructor options**:
21+
- Runtime types: `PrismaClientOptions` in `packages/client/src/runtime/getPrismaClient.ts`.
22+
- Validation: `packages/client/src/runtime/utils/validatePrismaClientOptions.ts` (add to `knownProperties` array and `validators` object).
23+
- Engine config: `EngineConfig` interface in `packages/client/src/runtime/core/engines/common/Engine.ts`.
24+
- Generated types: Update both `packages/client-generator-js/src/TSClient/PrismaClient.ts` (`buildClientOptions` method) and `packages/client-generator-ts/src/TSClient/file-generators/PrismaNamespaceFile.ts` (`buildClientOptions` function).
25+
- Use `@prisma/ts-builders` for generating TypeScript type declarations.
26+
27+
- **Creating new packages**:
28+
- Create directory under `packages/`, add `package.json`, `tsconfig.json`, `tsconfig.build.json`, and `helpers/build.ts`.
29+
- Package is auto-discovered via `pnpm-workspace.yaml` glob `packages/*`.
30+
- For type-only packages, use `adapterConfig` from `helpers/compile/configs.ts`.
31+
- Add as dependency to consuming packages using `"workspace:*"` version.
32+
- **Important**: Add resolution path to `tsconfig.build.bundle.json` under `compilerOptions.paths` for go-to-definition to work in editors.
33+
- **Important**: If the package has tests, add it to `.github/workflows/test-template.yml`. Most utility packages go in the `others` job (Linux, no Docker) and `no-docker` job (Windows/macOS). Look at existing packages for patterns.
34+
1135
- **Prisma 7 direction**: Migration from `schema.prisma` datasource URLs / `env()` to `prisma.config.ts`. Commands, tests, and fixtures should read connection settings from `PrismaConfigInternal.datasource` (or driver adapters) rather than CLI flags or environment loading. SQLite datasource URLs now resolve relative to the config file and not to the schema.
1236
- **Test helpers**: `ctx.setConfigFile('<name>')` (from `__helpers__/prismaConfig.ts`) overrides the config used for the next CLI invocation and is automatically reset after each test, so no explicit cleanup is needed. Many migrate fixtures now provide one config per schema variant (e.g. `invalid-url.config.ts` next to `prisma/invalid-url.prisma`) and tests swap them via `ctx.setConfigFile(...)`. `ctx.setDatasource`/`ctx.resetDatasource` continue to override connection URLs when needed.
1337

@@ -28,8 +52,15 @@
2852
- `@prisma/internals` exports CLI utilities: `arg`, `loadSchemaContext` (less used now).
2953
- `packages/migrate/src/__tests__/__helpers__/context.ts` sets up Jest helpers including config contributors.
3054
- `packages/config` defines `PrismaConfigInternal`; inspect when validating config assumptions.
55+
- `@prisma/ts-builders` provides a fluent API for generating TypeScript code (interfaces, types, properties with doc comments).
56+
- `@prisma/driver-adapter-utils` defines core interfaces: `SqlQuery`, `SqlQueryable`, `SqlDriverAdapter`, `SqlDriverAdapterFactory`.
57+
- `@prisma/client-engine-runtime` exports query interpreter, transaction manager, and related utilities.
3158

3259
- **Workflow reminders**:
3360
- Respect existing structure: modifications often require updating both command implementation and tests/fixtures.
3461
- Keep changes ASCII unless a file already uses Unicode (docs sometimes include emojis).
3562
- For new fixtures, prefer minimal config mirroring existing ones to ensure cross-platform compatibility.
63+
- When adding features that span multiple packages, build from root (`pnpm build`) to ensure correct dependency order.
64+
- Type-only imports from workspace packages work at runtime but IDE may show errors until `pnpm install` refreshes the workspace graph.
65+
- Test files named `*.test.ts` are excluded from build output via esbuild config; place tests alongside source files.
66+
- **Update this file** (`AGENTS.md`) whenever you learn something new about the codebase that would be valuable for future tasks.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,16 @@ Prisma has a large and supportive [community](https://www.prisma.io/community) o
333333

334334
## Badges
335335

336-
[![Made with Prisma](http://made-with.prisma.io/dark.svg)](https://prisma.io) [![Made with Prisma](http://made-with.prisma.io/indigo.svg)](https://prisma.io)
336+
[![Made with Prisma](https://made-with.prisma.io/dark.svg)](https://prisma.io) [![Made with Prisma](https://made-with.prisma.io/indigo.svg)](https://prisma.io)
337337

338338
Built something awesome with Prisma? 🌟 Show it off with these [badges](https://github.com/prisma/presskit?tab=readme-ov-file#badges), perfect for your readme or website.
339339

340340
```
341-
[![Made with Prisma](http://made-with.prisma.io/dark.svg)](https://prisma.io)
341+
[![Made with Prisma](https://made-with.prisma.io/dark.svg)](https://prisma.io)
342342
```
343343

344344
```
345-
[![Made with Prisma](http://made-with.prisma.io/indigo.svg)](https://prisma.io)
345+
[![Made with Prisma](https://made-with.prisma.io/indigo.svg)](https://prisma.io)
346346
```
347347

348348
## Security

packages/cli/src/Studio.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { dirname, extname, join, resolve } from 'pathe'
2020
import { runtime } from 'std-env'
2121

2222
import packageJson from '../package.json' assert { type: 'json' }
23+
import { getPpgInfo } from './utils/ppgInfo'
2324

2425
/**
2526
* `prisma dev`'s `51_213 - 1`
@@ -367,6 +368,8 @@ ${bold('Examples')}
367368
let projectHash: string | null = null
368369
const version = packageJson.dependencies['@prisma/studio-core']
369370

371+
const ppgDbInfo = await getPpgInfo(connectionString)
372+
370373
app.post('/telemetry', async (ctx) => {
371374
const { eventId, name, payload, timestamp } =
372375
await ctx.req.json<Parameters<NonNullable<StudioProps['onEvent']>>[0]>()
@@ -379,7 +382,11 @@ ${bold('Examples')}
379382
check_if_update_available: false,
380383
client_event_id: eventId,
381384
command: name,
382-
information: JSON.stringify({ eventPayload: payload, protocol }),
385+
information: JSON.stringify({
386+
eventPayload: payload,
387+
protocol,
388+
...ppgDbInfo,
389+
}),
383390
local_timestamp: timestamp,
384391
product: 'prisma-studio-cli',
385392
project_hash: (projectHash ??= digest(process.cwd())),

0 commit comments

Comments
 (0)