-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: run query engine tests with query compiler
Closes: https://linear.app/prisma-company/issue/ORM-555/make-prisma-engines-tests-run-with-query-compiler
- Loading branch information
Showing
16 changed files
with
533 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
tabWidth = 2 | ||
semi = false | ||
singleQuote = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,9 @@ | |
"description": "", | ||
"private": true, | ||
"scripts": { | ||
"build": "tsup ./src/testd-qe.ts ./src/demo-se.ts ./src/bench.ts --format esm --dts", | ||
"build": "tsup ./src/testd-qe.ts ./src/testd-qc.ts ./src/demo-se.ts ./src/bench.ts --format esm --dts", | ||
"test:qe": "node --import tsx ./src/testd-qe.ts", | ||
"test:qc": "node --import tsx ./src/testd-qc.ts", | ||
"demo:se": "node --import tsx ./src/demo-se.ts", | ||
"demo:qc": "node --import tsx ./src/demo-qc.ts", | ||
"clean:d1": "rm -rf ../../connector-test-kit-rs/query-engine-tests/.wrangler" | ||
|
@@ -27,6 +28,7 @@ | |
"@prisma/adapter-pg": "workspace:*", | ||
"@prisma/adapter-planetscale": "workspace:*", | ||
"@prisma/bundled-js-drivers": "workspace:*", | ||
"@prisma/client-engine-runtime": "workspace:*", | ||
"@prisma/driver-adapter-utils": "workspace:*", | ||
"mitata": "0.1.11", | ||
"query-engine-wasm-baseline": "npm:@prisma/[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env bash | ||
node "$(dirname "${BASH_SOURCE[0]}")/../dist/testd-qc.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
type GlobalWithPanicHandler = typeof globalThis & { | ||
PRISMA_WASM_PANIC_REGISTRY: { | ||
set_message: (message: string) => void | ||
} | ||
} | ||
|
||
export function setupPanicHandler() { | ||
;(globalThis as GlobalWithPanicHandler).PRISMA_WASM_PANIC_REGISTRY = { | ||
set_message(message: string) { | ||
throw new Error('Panic in WASM module: ' + message) | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import { ConnectionInfo } from "@prisma/driver-adapter-utils"; | ||
import { __dirname } from "./utils"; | ||
import { ConnectionInfo } from '@prisma/driver-adapter-utils' | ||
import { __dirname } from './utils' | ||
|
||
export type QueryCompilerParams = { | ||
// TODO: support multiple datamodels | ||
datamodel: string; | ||
flavour: 'postgres' | 'mysql' | 'sqlite'; | ||
connectionInfo: ConnectionInfo; | ||
}; | ||
datamodel: string | ||
provider: 'postgres' | 'mysql' | 'sqlite' | ||
connectionInfo: ConnectionInfo | ||
} | ||
|
||
export interface QueryCompiler { | ||
new (params: QueryCompilerParams): QueryCompiler; | ||
compile(query: string): Promise<string>; | ||
new (params: QueryCompilerParams): QueryCompiler | ||
compile(query: string): string | ||
} | ||
|
||
export async function initQueryCompiler( | ||
params: QueryCompilerParams, | ||
): Promise<QueryCompiler> { | ||
const { getQueryCompilerForProvider } = await import("./query-compiler-wasm"); | ||
const { getQueryCompilerForProvider } = await import('./query-compiler-wasm') | ||
const WasmQueryCompiler = (await getQueryCompilerForProvider( | ||
params.flavour, | ||
)) as QueryCompiler; | ||
return new WasmQueryCompiler(params); | ||
params.provider, | ||
)) as QueryCompiler | ||
return new WasmQueryCompiler(params) | ||
} |
Oops, something went wrong.