Skip to content

Commit

Permalink
driver-adapters: Pin drivers to the versions, used in prisma/prisma (#…
Browse files Browse the repository at this point in the history
…4721)

* driver-adapters: Pin drivers to the versions, used in prisma/prisma

See prisma/prisma#23087
Removes direct depenencies on the driver packages and picks them from
the meta-package in prisma/prisma. Should avoid disaster on every
update.

Fix prisma/team-orm#940

* Read GITHUB_BRANCH in benchmarks job too

* DRIVER_ADAPTERS_BRANCH=chore/bundled-js-drivers
  • Loading branch information
SevInf authored Feb 13, 2024
1 parent e24eacf commit 3f0cbe1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/wasm-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: "Setup Node.js"
uses: actions/setup-node@v4
Expand All @@ -43,9 +45,16 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract Branch Name
run: |
branch="$(git show -s --format=%s | grep -o "DRIVER_ADAPTERS_BRANCH=[^ ]*" | cut -f2 -d=)"
if [ -n "$branch" ]; then
echo "Using $branch branch of driver adapters"
echo "DRIVER_ADAPTERS_BRANCH=$branch" >> "$GITHUB_ENV"
fi
- uses: cachix/install-nix-action@v24

- name: Setup benchmark
run: make setup-pg-bench

Expand Down
6 changes: 1 addition & 5 deletions query-engine/driver-adapters/executor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@
"sideEffects": false,
"license": "Apache-2.0",
"dependencies": {
"@libsql/client": "0.3.6",
"@neondatabase/serverless": "0.8.1",
"@planetscale/database": "1.16.0",
"query-engine-wasm-latest": "npm:@prisma/query-engine-wasm@latest",
"query-engine-wasm-baseline": "npm:@prisma/[email protected]",
"@prisma/adapter-libsql": "workspace:*",
"@prisma/adapter-neon": "workspace:*",
"@prisma/adapter-pg": "workspace:*",
"@prisma/adapter-planetscale": "workspace:*",
"@prisma/driver-adapter-utils": "workspace:*",
"@types/pg": "8.10.9",
"@prisma/bundled-js-drivers": "workspace:*",
"mitata": "^0.1.6",
"pg": "8.11.3",
"undici": "6.0.1",
"ws": "8.14.2"
},
Expand Down
4 changes: 2 additions & 2 deletions query-engine/driver-adapters/executor/src/bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { fileURLToPath } from "node:url";

import * as qe from "./qe";

import pgDriver from "pg";
import { pg } from "@prisma/bundled-js-drivers";
import * as prismaPg from "@prisma/adapter-pg";
import { bindAdapter, DriverAdapter } from "@prisma/driver-adapter-utils";

Expand Down Expand Up @@ -176,7 +176,7 @@ async function pgAdapter(url: string): Promise<DriverAdapter> {
if (schemaName != null) {
args.options = `--search_path="${schemaName}"`;
}
const pool = new pgDriver.Pool(args);
const pool = new pg.Pool(args);

return new prismaPg.PrismaPg(pool, {
schema: schemaName,
Expand Down
12 changes: 5 additions & 7 deletions query-engine/driver-adapters/executor/src/testd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@ import * as readline from 'node:readline'
import * as jsonRpc from './jsonRpc'

// pg dependencies
import pgDriver from 'pg'
import * as prismaPg from '@prisma/adapter-pg'

// neon dependencies
import { Pool as NeonPool, neonConfig } from '@neondatabase/serverless'
import { fetch } from 'undici'
import { WebSocket } from 'ws'
import { pg, neon, planetScale, libSql } from '@prisma/bundled-js-drivers'
import * as prismaNeon from '@prisma/adapter-neon'

// libsql dependencies
import { createClient } from '@libsql/client'
import { PrismaLibSQL } from '@prisma/adapter-libsql'

// planetscale dependencies
import { Client as PlanetscaleClient } from '@planetscale/database'
import { PrismaPlanetScale } from '@prisma/adapter-planetscale'


Expand Down Expand Up @@ -256,14 +253,15 @@ function postgresSchemaName(url: string) {

async function pgAdapter(url: string): Promise<DriverAdapter> {
const schemaName = postgresSchemaName(url)
const pool = new pgDriver.Pool(postgres_options(url))
const pool = new pg.Pool(postgres_options(url))
return new prismaPg.PrismaPg(pool, {
schema: schemaName
})

}

async function neonWsAdapter(url: string): Promise<DriverAdapter> {
const { neonConfig, Pool: NeonPool } = neon
const proxyURL = JSON.parse(process.env.DRIVER_ADAPTER_CONFIG || '{}').proxy_url ?? ''
if (proxyURL == '') {
throw new Error("DRIVER_ADAPTER_CONFIG is not defined or empty, but its required for neon adapter.");
Expand All @@ -281,7 +279,7 @@ async function neonWsAdapter(url: string): Promise<DriverAdapter> {
}

async function libsqlAdapter(url: string): Promise<DriverAdapter> {
const libsql = createClient({ url, intMode: 'bigint' })
const libsql = libSql.createClient({ url, intMode: 'bigint' })
return new PrismaLibSQL(libsql)
}

Expand All @@ -291,7 +289,7 @@ async function planetscaleAdapter(url: string): Promise<DriverAdapter> {
throw new Error("DRIVER_ADAPTER_CONFIG is not defined or empty, but its required for planetscale adapter.");
}

const client = new PlanetscaleClient({
const client = new planetScale.Client({
// preserving path name so proxy url would look like real DB url
url: copyPathName(url, proxyUrl),
fetch,
Expand Down
1 change: 1 addition & 0 deletions query-engine/driver-adapters/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ packages:
- '../../../prisma/packages/adapter-planetscale'
- '../../../prisma/packages/driver-adapter-utils'
- '../../../prisma/packages/debug'
- '../../../prisma/packages/bundled-js-drivers'
- './executor'

0 comments on commit 3f0cbe1

Please sign in to comment.