diff --git a/.envrc b/.envrc index 29a3b25822d5..64aea05c728e 100644 --- a/.envrc +++ b/.envrc @@ -22,6 +22,12 @@ export QE_LOG_LEVEL=debug # Set it to "trace" to enable query-graph debugging lo # export PRISMA_RENDER_DOT_FILE=1 # Uncomment to enable rendering a dot file of the Query Graph from an executed query. # export FMT_SQL=1 # Uncomment it to enable logging formatted SQL queries +### Uncomment to run driver adapters tests. See query-engine-driver-adapters.yml workflow for how tests run in CI. +# export EXTERNAL_TEST_EXECUTOR="$(pwd)/query-engine/driver-adapters/js/connector-test-kit-executor/script/start_node.sh" +# export DRIVER_ADAPTER=pg # Set to pg, neon or planetscale +# export PRISMA_DISABLE_QUAINT_EXECUTORS=1 # Disable quaint executors for driver adapters +# export DRIVER_ADAPTER_URL_OVERRIDE ="postgres://USER:PASSWORD@DATABASExxxx" # Override the database url for the driver adapter tests + # Mongo image requires additional wait time on arm arch for some reason. if uname -a | grep -q 'arm64'; then export INIT_WAIT_SEC="10" diff --git a/.github/workflows/query-engine-driver-adapters.yml b/.github/workflows/query-engine-driver-adapters.yml index 9a5af5f6d03e..ad7b51fc2beb 100644 --- a/.github/workflows/query-engine-driver-adapters.yml +++ b/.github/workflows/query-engine-driver-adapters.yml @@ -28,20 +28,24 @@ jobs: version: "13" driver_adapter: "pg" node_version: ["18"] - env: LOG_LEVEL: "info" LOG_QUERIES: "y" RUST_LOG: "info" RUST_LOG_FORMAT: "devel" RUST_BACKTRACE: "1" + PRISMA_DISABLE_QUAINT_EXECUTORS: "1" CLICOLOR_FORCE: "1" CLOSED_TX_CLEANUP: "2" SIMPLE_TEST_MODE: "1" QUERY_BATCH_SIZE: "10" TEST_CONNECTOR: ${{ matrix.database.connector }} TEST_CONNECTOR_VERSION: ${{ matrix.database.version }} - TEST_DRIVER_ADAPTER: ${{ matrix.database.driver_adapter }} + WORKSPACE_ROOT: ${{ github.workspace }} + # Driver adapter testing specific env vars + EXTERNAL_TEST_EXECUTOR: "${{ github.workspace }}/query-engine/driver-adapters/js/connector-test-kit-executor/script/start_node.sh" + DRIVER_ADAPTER: ${{ matrix.database.driver_adapter }} + DRIVER_ADAPTER_URL_OVERRIDE: ${{ matrix.database.driver_adapter_url }} runs-on: buildjet-16vcpu-ubuntu-2004 steps: @@ -77,7 +81,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: "Start ${{ matrix.database.name }} (${{ matrix.engine_protocol }})" + - name: "Start ${{ matrix.database.name }}" run: make start-${{ matrix.database.name }} - uses: dtolnay/rust-toolchain@stable @@ -90,8 +94,5 @@ jobs: - name: "Run tests" run: cargo test --package query-engine-tests -- --test-threads=1 - env: - CLICOLOR_FORCE: 1 - WORKSPACE_ROOT: ${{ github.workspace }} - NODE_TEST_EXECUTOR: "${{ github.workspace }}/query-engine/driver-adapters/js/connector-test-kit-executor/script/start_node.sh" + diff --git a/query-engine/connector-test-kit-rs/README.md b/query-engine/connector-test-kit-rs/README.md index e6821193a628..3cbaadb63523 100644 --- a/query-engine/connector-test-kit-rs/README.md +++ b/query-engine/connector-test-kit-rs/README.md @@ -1,6 +1,5 @@ # Query Engine Test Kit - A Full Guide -The test kit is a (currently incomplete) port of the Scala test kit, located in `../connector-test-kit`. -It's fully focused on integration testing the query engine through request-response assertions. +The test kit is focused on integration testing the query engine through request-response assertions. ## Test organization @@ -35,8 +34,10 @@ Contains the main bulk of logic to make tests run, which is mostly invisible to Tests are executed in the context of *one* _connector_ (with version) and _runner_. Some tests may only be specified to run for a subset of connectors or versions, in which case they will be skipped. Testing all connectors at once is not supported, however, for example, CI will run all the different connectors and versions concurrently in separate runs. ### Configuration + Tests must be configured to run There's a set of env vars that is always useful to have and an optional one. Always useful to have: + ```shell export WORKSPACE_ROOT=/path/to/engines/repository/root ``` @@ -54,6 +55,7 @@ As previously stated, the above can be omitted in favor of the `.test_config` co "version": "10" } ``` + The config file must be either in the current working folder from which you invoke a test run or in `$WORKSPACE_ROOT`. It's recommended to use the file-based config as it's easier to switch between providers with an open IDE (reloading env vars would usually require reloading the IDE). The workspace root makefile contains a series of convenience commands to setup different connector test configs, e.g. `make dev-postgres10` sets up the correct test config file for the tests to pick up. @@ -62,7 +64,29 @@ On the note of docker containers: Most connectors require an endpoint to run aga If you choose to set up the databases yourself, please note that the connection strings used in the tests (found in the files in `/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/`) to set up user, password and database for the test user. +#### Running tests through driver adapters + +The query engine is able to delegate query execution to javascript through [driver adapters](query-engine/driver-adapters/js/README.md). +This means that instead of drivers being implemented in Rust, it's a layer of adapters over NodeJs drivers the code that actually communicates with the databases. + +To run tests through a driver adapters, you should also configure the following environment variables: + +* `EXTERNAL_TEST_EXECUTOR`: tells the query engine test kit to use an external process to run the queries, this is a node process running +a program that will read the queries to run from STDIN, and return responses to STDOUT. The connector kit follows a protocol over JSON RPC for this communication. +* `DRIVER_ADAPTER`: tells the test executor to use a particular driver adapter. Set to `neon`, `planetscale` or any other supported adapter. +* `DRIVER_ADAPTER_URL_OVERRIDE`: it overrides the schema URL for the database to use one understood by the driver adapter (ex. neon, planetscale) + + +Example: + +```shell +export EXTERNAL_TEST_EXECUTOR="$WORKSPACE_ROOT/query-engine/driver-adapters/js/connector-test-kit-executor/script/start_node.sh" +export DRIVER_ADAPTER=neon +export DRIVER_ADAPTER_URL_OVERRIDE ="postgres://USER:PASSWORD@DATABASExxxx" +```` + ### Running + Note that by default tests run concurrently. - VSCode should automatically detect tests and display `run test`. diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js.rs index 6e174808a38d..2ec8513baeda 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js.rs @@ -1,7 +1,7 @@ -mod node_process; +mod external_process; use super::*; -use node_process::*; +use external_process::*; use serde::de::DeserializeOwned; use std::{collections::HashMap, sync::atomic::AtomicU64}; use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; @@ -10,5 +10,5 @@ pub(crate) async fn executor_process_request( method: &str, params: serde_json::Value, ) -> Result> { - NODE_PROCESS.request(method, params).await + EXTERNAL_PROCESS.request(method, params).await } diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js/node_process.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js/external_process.rs similarity index 97% rename from query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js/node_process.rs rename to query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js/external_process.rs index 3b58ad527925..332eb3ea50d2 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js/node_process.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/connector_tag/js/external_process.rs @@ -69,7 +69,7 @@ impl ExecutorProcess { } } -pub(super) static NODE_PROCESS: Lazy = +pub(super) static EXTERNAL_PROCESS: Lazy = Lazy::new(|| match std::thread::spawn(ExecutorProcess::new).join() { Ok(Ok(process)) => process, Ok(Err(err)) => exit_with_message(1, &format!("Failed to start node process. Details: {err}")), @@ -87,7 +87,10 @@ fn start_rpc_thread(mut receiver: mpsc::Receiver) -> Result<()> { let env_var = match crate::EXTERNAL_TEST_EXECUTOR.as_ref() { Some(env_var) => env_var, - None => exit_with_message(1, "start_rpc_thread() error: NODE_TEST_EXECUTOR env var is not defined"), + None => exit_with_message( + 1, + "start_rpc_thread() error: EXTERNAL_TEST_EXECUTOR env var is not defined", + ), }; tokio::runtime::Builder::new_current_thread() diff --git a/query-engine/connector-test-kit-rs/query-tests-setup/src/lib.rs b/query-engine/connector-test-kit-rs/query-tests-setup/src/lib.rs index f1a53f6b2f53..99bd486f51d3 100644 --- a/query-engine/connector-test-kit-rs/query-tests-setup/src/lib.rs +++ b/query-engine/connector-test-kit-rs/query-tests-setup/src/lib.rs @@ -42,8 +42,7 @@ pub static ENV_LOG_LEVEL: Lazy = Lazy::new(|| std::env::var("LOG_LEVEL") pub static ENGINE_PROTOCOL: Lazy = Lazy::new(|| std::env::var("PRISMA_ENGINE_PROTOCOL").unwrap_or_else(|_| "graphql".to_owned())); -// TODO: rename env var to EXTERNAL_TEST_EXECUTOR -static EXTERNAL_TEST_EXECUTOR: Lazy> = Lazy::new(|| std::env::var("NODE_TEST_EXECUTOR").ok()); +static EXTERNAL_TEST_EXECUTOR: Lazy> = Lazy::new(|| std::env::var("EXTERNAL_TEST_EXECUTOR").ok()); /// Teardown of a test setup. async fn teardown_project(datamodel: &str, db_schemas: &[&str], schema_id: Option) -> TestResult<()> { diff --git a/query-engine/driver-adapters/js/connector-test-kit-executor/package.json b/query-engine/driver-adapters/js/connector-test-kit-executor/package.json index 38cb115ace79..1dc1315afc83 100644 --- a/query-engine/driver-adapters/js/connector-test-kit-executor/package.json +++ b/query-engine/driver-adapters/js/connector-test-kit-executor/package.json @@ -13,9 +13,12 @@ "sideEffects": false, "license": "Apache-2.0", "dependencies": { + "@neondatabase/serverless": "^0.6.0", + "@prisma/adapter-neon": "workspace:*", "@prisma/adapter-pg": "workspace:*", "@prisma/driver-adapter-utils": "workspace:*", + "@types/pg": "^8.10.2", "pg": "^8.11.3", - "@types/pg": "^8.10.2" + "undici": "^5.23.0" } } diff --git a/query-engine/driver-adapters/js/connector-test-kit-executor/src/index.ts b/query-engine/driver-adapters/js/connector-test-kit-executor/src/index.ts index 3648276c37f3..78e1b8954ae5 100644 --- a/query-engine/driver-adapters/js/connector-test-kit-executor/src/index.ts +++ b/query-engine/driver-adapters/js/connector-test-kit-executor/src/index.ts @@ -1,10 +1,22 @@ -import pgDriver from 'pg' -import * as pg from '@prisma/adapter-pg' import * as qe from './qe' import * as engines from './engines/Library' import * as readline from 'node:readline' import * as jsonRpc from './jsonRpc' -import {bindAdapter, ErrorCapturingDriverAdapter} from "@prisma/driver-adapter-utils"; + +// pg dependencies +import pgDriver from 'pg' +import * as prismaPg from '@prisma/adapter-pg' + +// neon dependencies +import { Pool as NeonPool, neonConfig } from '@neondatabase/serverless' +import { WebSocket } from 'undici' +import * as prismaNeon from '@prisma/adapter-neon' +neonConfig.webSocketConstructor = WebSocket + +import {bindAdapter, DriverAdapter, ErrorCapturingDriverAdapter} from "@prisma/driver-adapter-utils"; + +const SUPPORTED_ADAPTERS: Record Promise> + = {pg: pgAdapter, neon: neonAdapter}; async function main(): Promise { const iface = readline.createInterface({ @@ -94,13 +106,11 @@ async function handleRequest(method: string, params: unknown): Promise schemaId: number, options: unknown } + console.error("Got `startTx", params) - const { schemaId, options } = params as StartTxPayload + const {schemaId, options} = params as StartTxPayload const result = await schemas[schemaId].startTransaction(JSON.stringify(options), "") return JSON.parse(result) - - - } case 'commitTx': { @@ -108,8 +118,9 @@ async function handleRequest(method: string, params: unknown): Promise schemaId: number, txId: string, } + console.error("Got `commitTx", params) - const { schemaId, txId } = params as CommitTxPayload + const {schemaId, txId} = params as CommitTxPayload const result = await schemas[schemaId].commitTransaction(txId, '{}') return JSON.parse(result) } @@ -119,8 +130,9 @@ async function handleRequest(method: string, params: unknown): Promise schemaId: number, txId: string, } + console.error("Got `rollbackTx", params) - const { schemaId, txId } = params as RollbackTxPayload + const {schemaId, txId} = params as RollbackTxPayload const result = await schemas[schemaId].rollbackTransaction(txId, '{}') return JSON.parse(result) } @@ -132,15 +144,15 @@ async function handleRequest(method: string, params: unknown): Promise const castParams = params as TeardownPayload; await schemas[castParams.schemaId].disconnect("") delete schemas[castParams.schemaId] + delete adapters[castParams.schemaId] delete queryLogs[castParams.schemaId] return {} - } - case 'getLogs': { interface GetLogsPayload { schemaId: number } + const castParams = params as GetLogsPayload return queryLogs[castParams.schemaId] ?? [] } @@ -170,10 +182,39 @@ function respondOk(requestId: number, payload: unknown) { } async function initQe(url: string, prismaSchema: string, logCallback: qe.QueryLogCallback): Promise<[engines.QueryEngineInstance, ErrorCapturingDriverAdapter]> { - const pool = new pgDriver.Pool({ connectionString: url }) - const adapter = bindAdapter(new pg.PrismaPg(pool)) - const engineInstance = qe.initQueryEngine(adapter, prismaSchema, logCallback) - return [engineInstance, adapter]; + const adapter = await adapterFromEnv(url) as DriverAdapter + const errorCapturingAdapter = bindAdapter(adapter) + const engineInstance = qe.initQueryEngine(errorCapturingAdapter, prismaSchema, logCallback) + return [engineInstance, errorCapturingAdapter]; +} + +async function adapterFromEnv(url: string): Promise { + const adapter = process.env.DRIVER_ADAPTER ?? '' + + if (adapter == '') { + throw new Error("DRIVER_ADAPTER is not defined or empty.") + } + + if (!(adapter in SUPPORTED_ADAPTERS)) { + throw new Error(`Unsupported driver adapter: ${adapter}`) + } + + return await SUPPORTED_ADAPTERS[adapter](url); +} + +async function pgAdapter(url: string): Promise { + const pool = new pgDriver.Pool({connectionString: url}) + return new prismaPg.PrismaPg(pool) +} + +async function neonAdapter(_: string): Promise { + const connectionString = process.env.DRIVER_ADAPTER_URL_OVERRIDE ?? '' + if (connectionString == '') { + throw new Error("DRIVER_ADAPTER_URL_OVERRIDE is not defined or empty, but its required for neon adapter."); + } + + const pool = new NeonPool({ connectionString }) + return new prismaNeon.PrismaNeon(pool) } main().catch(console.error) diff --git a/query-engine/driver-adapters/js/connector-test-kit-executor/src/qe.ts b/query-engine/driver-adapters/js/connector-test-kit-executor/src/qe.ts index af32bd0bdb8b..a8256bf08b3f 100644 --- a/query-engine/driver-adapters/js/connector-test-kit-executor/src/qe.ts +++ b/query-engine/driver-adapters/js/connector-test-kit-executor/src/qe.ts @@ -28,14 +28,18 @@ export function initQueryEngine(adapter: ErrorCapturingDriverAdapter, datamodel: ignoreEnvVarErrors: false, } + const logCallback = (event: any) => { const parsed = JSON.parse(event) if (parsed.is_query) { queryLogCallback(parsed.query) } - console.error("[nodejs] ", parsed) + + const level = process.env.LOG_LEVEL ?? '' + if (level.toLowerCase() == 'debug') { + console.error("[nodejs] ", parsed) + } } - const engine = new QueryEngine(queryEngineOptions, logCallback, adapter) - return engine + return new QueryEngine(queryEngineOptions, logCallback, adapter) } diff --git a/query-engine/driver-adapters/js/pnpm-lock.yaml b/query-engine/driver-adapters/js/pnpm-lock.yaml index 123db305f805..f919d4a1a066 100644 --- a/query-engine/driver-adapters/js/pnpm-lock.yaml +++ b/query-engine/driver-adapters/js/pnpm-lock.yaml @@ -53,6 +53,12 @@ importers: connector-test-kit-executor: dependencies: + '@neondatabase/serverless': + specifier: ^0.6.0 + version: 0.6.0 + '@prisma/adapter-neon': + specifier: workspace:* + version: link:../adapter-neon '@prisma/adapter-pg': specifier: workspace:* version: link:../adapter-pg @@ -65,6 +71,9 @@ importers: pg: specifier: ^8.11.3 version: 8.11.3 + undici: + specifier: ^5.23.0 + version: 5.23.0 driver-adapter-utils: dependencies: diff --git a/query-engine/driver-adapters/js/smoke-test-js/src/client/neon.http.test.ts b/query-engine/driver-adapters/js/smoke-test-js/src/client/neon.http.test.ts index 137bb0ed9835..44cb1fde98a8 100644 --- a/query-engine/driver-adapters/js/smoke-test-js/src/client/neon.http.test.ts +++ b/query-engine/driver-adapters/js/smoke-test-js/src/client/neon.http.test.ts @@ -4,7 +4,7 @@ import { PrismaNeonHTTP } from '@prisma/adapter-neon' import { smokeTestClient } from './client' describe('neon with @prisma/client', async () => { - const connectionString = `${process.env.JS_NEON_DATABASE_URL as string}` + const connectionString = process.env.JS_NEON_DATABASE_URL ?? '' const connection = neon(connectionString, { arrayMode: false, diff --git a/query-engine/driver-adapters/js/smoke-test-js/src/client/neon.ws.test.ts b/query-engine/driver-adapters/js/smoke-test-js/src/client/neon.ws.test.ts index c6e85eca0891..37b0a9088bb7 100644 --- a/query-engine/driver-adapters/js/smoke-test-js/src/client/neon.ws.test.ts +++ b/query-engine/driver-adapters/js/smoke-test-js/src/client/neon.ws.test.ts @@ -7,7 +7,7 @@ import { smokeTestClient } from './client' neonConfig.webSocketConstructor = WebSocket describe('neon with @prisma/client', async () => { - const connectionString = `${process.env.JS_NEON_DATABASE_URL as string}` + const connectionString = process.env.JS_NEON_DATABASE_URL ?? '' const pool = new Pool({ connectionString }) const adapter = new PrismaNeon(pool) diff --git a/query-engine/driver-adapters/js/smoke-test-js/src/client/pg.test.ts b/query-engine/driver-adapters/js/smoke-test-js/src/client/pg.test.ts index 7394e5f55e89..99048ad3d95f 100644 --- a/query-engine/driver-adapters/js/smoke-test-js/src/client/pg.test.ts +++ b/query-engine/driver-adapters/js/smoke-test-js/src/client/pg.test.ts @@ -4,10 +4,10 @@ import { PrismaPg } from '@prisma/adapter-pg' import { smokeTestClient } from './client' describe('pg with @prisma/client', async () => { - const connectionString = `${process.env.JS_PG_DATABASE_URL as string}` + const connectionString = process.env.JS_PG_DATABASE_URL ?? '' const pool = new pg.Pool({ connectionString }) const adapter = new PrismaPg(pool) - + smokeTestClient(adapter) }) diff --git a/query-engine/driver-adapters/js/smoke-test-js/src/client/planetscale.test.ts b/query-engine/driver-adapters/js/smoke-test-js/src/client/planetscale.test.ts index e82e209247f4..3c22b7aa3062 100644 --- a/query-engine/driver-adapters/js/smoke-test-js/src/client/planetscale.test.ts +++ b/query-engine/driver-adapters/js/smoke-test-js/src/client/planetscale.test.ts @@ -4,10 +4,10 @@ import { describe } from 'node:test' import { smokeTestClient } from './client' describe('planetscale with @prisma/client', async () => { - const connectionString = `${process.env.JS_PLANETSCALE_DATABASE_URL as string}` + const connectionString = process.env.JS_PLANETSCALE_DATABASE_URL ?? '' const connnection = connect({ url: connectionString }) const adapter = new PrismaPlanetScale(connnection) - + smokeTestClient(adapter) }) diff --git a/query-engine/driver-adapters/js/smoke-test-js/src/libquery/neon.http.test.ts b/query-engine/driver-adapters/js/smoke-test-js/src/libquery/neon.http.test.ts index dc839405b21f..ac165d29f584 100644 --- a/query-engine/driver-adapters/js/smoke-test-js/src/libquery/neon.http.test.ts +++ b/query-engine/driver-adapters/js/smoke-test-js/src/libquery/neon.http.test.ts @@ -5,7 +5,7 @@ import { describe } from 'node:test' import { smokeTestLibquery } from './libquery' describe('neon (HTTP)', () => { - const connectionString = `${process.env.JS_NEON_DATABASE_URL as string}` + const connectionString = process.env.JS_NEON_DATABASE_URL ?? '' const neonConnection = neon(connectionString) diff --git a/query-engine/driver-adapters/js/smoke-test-js/src/libquery/neon.ws.test.ts b/query-engine/driver-adapters/js/smoke-test-js/src/libquery/neon.ws.test.ts index 017cb8f1c31d..54765f5961ba 100644 --- a/query-engine/driver-adapters/js/smoke-test-js/src/libquery/neon.ws.test.ts +++ b/query-engine/driver-adapters/js/smoke-test-js/src/libquery/neon.ws.test.ts @@ -8,7 +8,7 @@ import { smokeTestLibquery } from './libquery' neonConfig.webSocketConstructor = WebSocket describe('neon (WebSocket)', () => { - const connectionString = `${process.env.JS_NEON_DATABASE_URL as string}` + const connectionString = process.env.JS_NEON_DATABASE_URL ?? '' const pool = new Pool({ connectionString }) const adapter = new PrismaNeon(pool) diff --git a/query-engine/driver-adapters/js/smoke-test-js/src/libquery/pg.test.ts b/query-engine/driver-adapters/js/smoke-test-js/src/libquery/pg.test.ts index ca4f297bb1f2..9b79e7284be8 100644 --- a/query-engine/driver-adapters/js/smoke-test-js/src/libquery/pg.test.ts +++ b/query-engine/driver-adapters/js/smoke-test-js/src/libquery/pg.test.ts @@ -5,11 +5,11 @@ import { describe } from 'node:test' import { smokeTestLibquery } from './libquery' describe('pg', () => { - const connectionString = `${process.env.JS_PG_DATABASE_URL as string}` + const connectionString = process.env.JS_PG_DATABASE_URL ?? '' const pool = new pg.Pool({ connectionString }) const adapter = new PrismaPg(pool) const driverAdapter = bindAdapter(adapter) - + smokeTestLibquery(driverAdapter, '../../prisma/postgres/schema.prisma') }) diff --git a/query-engine/driver-adapters/js/smoke-test-js/src/libquery/planetscale.test.ts b/query-engine/driver-adapters/js/smoke-test-js/src/libquery/planetscale.test.ts index 2d3137fbe500..bb7c81805adc 100644 --- a/query-engine/driver-adapters/js/smoke-test-js/src/libquery/planetscale.test.ts +++ b/query-engine/driver-adapters/js/smoke-test-js/src/libquery/planetscale.test.ts @@ -2,14 +2,14 @@ import { connect } from '@planetscale/database' import { PrismaPlanetScale } from '@prisma/adapter-planetscale' import { bindAdapter } from '@prisma/driver-adapter-utils' import { describe } from 'node:test' -import { smokeTestLibquery } from './libquery' +import { smokeTestLibquery } from './libquery' describe('planetscale', () => { - const connectionString = `${process.env.JS_PLANETSCALE_DATABASE_URL as string}` + const connectionString = process.env.JS_PLANETSCALE_DATABASE_URL ?? '' const connnection = connect({ url: connectionString }) const adapter = new PrismaPlanetScale(connnection) const driverAdapter = bindAdapter(adapter) - + smokeTestLibquery(driverAdapter, '../../prisma/mysql/schema.prisma') }) diff --git a/query-engine/query-engine-node-api/src/engine.rs b/query-engine/query-engine-node-api/src/engine.rs index 8d5f56ca7bfa..e376cf16a049 100644 --- a/query-engine/query-engine-node-api/src/engine.rs +++ b/query-engine/query-engine-node-api/src/engine.rs @@ -147,7 +147,7 @@ impl QueryEngine { napi_env: Env, options: JsUnknown, callback: JsFunction, - maybe_driver: Option, + maybe_adapter: Option, ) -> napi::Result { let mut log_callback = callback.create_threadsafe_function(0usize, |ctx: ThreadSafeCallContext| { Ok(vec![ctx.env.create_string(&ctx.value)?]) @@ -181,8 +181,8 @@ impl QueryEngine { ); } else { #[cfg(feature = "driver-adapters")] - if let Some(driver) = maybe_driver { - let js_queryable = driver_adapters::from_napi(driver); + if let Some(adapter) = maybe_adapter { + let js_queryable = driver_adapters::from_napi(adapter); sql_connector::activate_driver_adapter(Arc::new(js_queryable)); connector_mode = ConnectorMode::Js;