Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client, debug): query catch & debug types #8706

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 17 additions & 5 deletions .buildkite/test/run.sh
Expand Up @@ -41,20 +41,32 @@ function retry {
return 0
}

# Only for job 2 = Node-API
if [ "$BUILDKITE_PARALLEL_JOB" = "2" ]; then
export PRISMA_FORCE_NAPI=true
# The below is required as during install required engines are downloaded, so this makes sure the engines being tested are already present

# JOB 0 - Node-API Library
if [ "$BUILDKITE_PARALLEL_JOB" = "0" ]; then
export PRISMA_CLIENT_ENGINE_TYPE='library'
export PRISMA_CLI_QUERY_ENGINE_TYPE='library'
fi
# JOB 1 - Binary
if [ "$BUILDKITE_PARALLEL_JOB" = "1" ]; then
export PRISMA_CLIENT_ENGINE_TYPE='binary'
export PRISMA_CLI_QUERY_ENGINE_TYPE='binary'
fi

npm i --silent -g pnpm@6 --unsafe-perm

retry 6 pnpm i --no-prefer-frozen-lockfile

# Only run lint for job 0

# JOB 0
if [ "$BUILDKITE_PARALLEL_JOB" = "0" ]; then
pnpm run lint
# Only run lint for job 0
pnpm run lint
fi



node -v
npm -v

Expand Down
2 changes: 1 addition & 1 deletion .buildkite/test/test.yml
@@ -1,6 +1,6 @@
steps:
- label: ':coverage: Test %n - Node 14 (Search for `BUILDKITE_PARALLEL_JOB` in test output for definition what is being tested)'
parallelism: 3
parallelism: 2
timeout_in_minutes: 25
plugins:
- docker-compose#v3.8.0:
Expand Down
31 changes: 13 additions & 18 deletions .github/workflows/test.yml
Expand Up @@ -116,17 +116,16 @@ jobs:
strategy:
fail-fast: false
matrix:
engine: ['napi', 'binary']
engineType: ['library', 'binary']
os: [ubuntu-20.04] # macos-latest, windows-latest
node: [12]

steps:
- uses: actions/checkout@v2

- name: Set Engine Type
if: ${{ matrix.engine == 'napi' }}
run: |
echo "PRISMA_FORCE_NAPI=true" >> $GITHUB_ENV
echo "PRISMA_CLIENT_ENGINE_TYPE={{ matrix.engine }}" >> $GITHUB_ENV

- run: docker-compose -f docker/docker-compose.yml up --detach postgres postgres_isolated mysql mysql_isolated mssql

Expand Down Expand Up @@ -225,7 +224,7 @@ jobs:
strategy:
fail-fast: false
matrix:
engine: ['napi', 'binary']
engineType: ['library', 'binary']
database:
- sqlite
- postgres
Expand All @@ -238,9 +237,8 @@ jobs:
- uses: actions/checkout@v2

- name: Set Engine Type
if: ${{ matrix.engine == 'napi' }}
run: |
echo "PRISMA_FORCE_NAPI=true" >> $GITHUB_ENV
echo "PRISMA_CLIENT_ENGINE_TYPE=${{ matrix.engine }}" >> $GITHUB_ENV

- run: docker-compose -f docker/docker-compose.yml up --detach ${{matrix.database}}
if: matrix.database != 'sqlite'
Expand Down Expand Up @@ -302,17 +300,16 @@ jobs:
strategy:
fail-fast: false
matrix:
engine: ['napi', 'binary']
cliQueryEngine: ['library', 'binary']
os: [ubuntu-20.04] # macos-latest, windows-latest
node: [12]

steps:
- uses: actions/checkout@v2

- name: Set Engine Type
if: ${{ matrix.engine == 'napi' }}
- name: Set CLI Engine Type
run: |
echo "PRISMA_FORCE_NAPI=true" >> $GITHUB_ENV
echo "PRISMA_CLI_QUERY_ENGINE_TYPE={{ matrix.cliQueryEngine }}" >> $GITHUB_ENV

- name: Cache .pnpm-store # From https://pnpm.io/continuous-integration
uses: actions/cache@v1
Expand Down Expand Up @@ -356,7 +353,7 @@ jobs:
strategy:
fail-fast: false
matrix:
engine: ['napi', 'binary']
cliQueryEngine: ['library', 'binary']
os: [ubuntu-20.04] # macos-latest, windows-latest
node: [12]

Expand All @@ -365,10 +362,9 @@ jobs:

- run: docker-compose -f docker/docker-compose.yml up --detach postgres mysql mssql

- name: Set Engine Type
if: ${{ matrix.engine == 'napi' }}
- name: Set CLI Engine Type
run: |
echo "PRISMA_FORCE_NAPI=true" >> $GITHUB_ENV
echo "PRISMA_CLI_QUERY_ENGINE_TYPE={{ matrix.cliQueryEngine }}" >> $GITHUB_ENV

- name: Cache .pnpm-store # From https://pnpm.io/continuous-integration
uses: actions/cache@v1
Expand Down Expand Up @@ -424,17 +420,16 @@ jobs:
strategy:
fail-fast: false
matrix:
engine: ['napi', 'binary']
cliQueryEngine: ['library', 'binary']
os: [ubuntu-20.04] # macos-latest, windows-latest
node: [12]

steps:
- uses: actions/checkout@v2

- name: Set Engine Type
if: ${{ matrix.engine == 'napi' }}
- name: Set CLI Engine Type
run: |
echo "PRISMA_FORCE_NAPI=true" >> $GITHUB_ENV
echo "PRISMA_CLI_QUERY_ENGINE_TYPE={{ matrix.cliQueryEngine }}" >> $GITHUB_ENV

- name: Cache .pnpm-store # From https://pnpm.io/continuous-integration
uses: actions/cache@v1
Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -27,10 +27,10 @@
"@types/benchmark": "2.1.1",
"@types/debug": "4.1.7",
"@types/graphviz": "0.0.33",
"@types/node": "14.17.7",
"@types/node": "14.17.9",
"@types/redis": "2.8.31",
"@typescript-eslint/eslint-plugin": "4.29.0",
"@typescript-eslint/parser": "4.29.0",
"@typescript-eslint/eslint-plugin": "4.29.1",
"@typescript-eslint/parser": "4.29.1",
"arg": "5.0.0",
"batching-toposort": "1.2.0",
"benchmark": "2.1.4",
Expand All @@ -56,7 +56,7 @@
"redis-lock": "0.1.4",
"semver": "7.3.5",
"staged-git-files": "1.2.0",
"ts-node": "10.1.0",
"ts-node": "10.2.0",
"typescript": "4.3.5"
}
}
45 changes: 0 additions & 45 deletions packages/README.md

This file was deleted.

16 changes: 8 additions & 8 deletions packages/cli/package.json
Expand Up @@ -63,18 +63,18 @@
"devDependencies": {
"@prisma/client": "workspace:*",
"@prisma/debug": "workspace:*",
"@prisma/fetch-engine": "2.29.0-34.1be4cd60b89afa04b192acb1ef47758a39810f3a",
"@prisma/fetch-engine": "2.30.0-2.71d96e8bbd21982078694f00add0f51da2056a8b",
"@prisma/generator-helper": "workspace:*",
"@prisma/get-platform": "2.29.0-34.1be4cd60b89afa04b192acb1ef47758a39810f3a",
"@prisma/get-platform": "2.30.0-2.71d96e8bbd21982078694f00add0f51da2056a8b",
"@prisma/migrate": "workspace:*",
"@prisma/sdk": "workspace:*",
"@prisma/studio-server": "0.419.0",
"@timsuchanek/copy": "1.4.5",
"@types/jest": "26.0.24",
"@types/jest": "27.0.0",
"@types/rimraf": "3.0.1",
"@types/ws": "7.4.7",
"@typescript-eslint/eslint-plugin": "4.29.0",
"@typescript-eslint/parser": "4.29.0",
"@typescript-eslint/eslint-plugin": "4.29.1",
"@typescript-eslint/parser": "4.29.1",
"chalk": "4.1.2",
"checkpoint-client": "1.1.20",
"dotenv": "10.0.0",
Expand All @@ -87,14 +87,14 @@
"eslint-plugin-prettier": "3.4.0",
"execa": "5.1.1",
"fast-deep-equal": "3.1.3",
"fs-jetpack": "4.1.0",
"fs-jetpack": "4.1.1",
"get-port": "5.1.1",
"global-dirs": "3.0.0",
"indent-string": "4.0.0",
"is-installed-globally": "0.4.0",
"jest": "27.0.6",
"line-replace": "2.0.1",
"lint-staged": "11.1.1",
"lint-staged": "11.1.2",
"log-update": "4.0.0",
"make-dir": "3.1.0",
"node-fetch": "2.6.1",
Expand Down Expand Up @@ -127,7 +127,7 @@
"precommit": "lint-staged"
},
"dependencies": {
"@prisma/engines": "2.29.0-34.1be4cd60b89afa04b192acb1ef47758a39810f3a"
"@prisma/engines": "2.30.0-2.71d96e8bbd21982078694f00add0f51da2056a8b"
},
"lint-staged": {
"*.ts": [
Expand Down
13 changes: 8 additions & 5 deletions packages/cli/src/Version.ts
@@ -1,3 +1,4 @@
import { getCliQueryEngineBinaryType } from '@prisma/engines'
import { getPlatform } from '@prisma/get-platform'
import {
arg,
Expand Down Expand Up @@ -66,15 +67,13 @@ export class Version implements Command {
}

const platform = await getPlatform()
const useNodeAPI = process.env.PRISMA_FORCE_NAPI === 'true'
const cliQueryEngineBinaryType = getCliQueryEngineBinaryType()
const introspectionEngine = await this.resolveEngine(
BinaryType.introspectionEngine,
)
const migrationEngine = await this.resolveEngine(BinaryType.migrationEngine)
// TODO This conditional does not really belong here, CLI should be able to tell you which engine it is _actually_ using
const queryEngine = await this.resolveEngine(
useNodeAPI ? BinaryType.libqueryEngine : BinaryType.queryEngine,
)
const queryEngine = await this.resolveEngine(cliQueryEngineBinaryType)
const fmtBinary = await this.resolveEngine(BinaryType.prismaFmt)

const prismaClientVersion = await getInstalledPrismaClientVersion()
Expand All @@ -84,7 +83,11 @@ export class Version implements Command {
['@prisma/client', prismaClientVersion ?? 'Not found'],
['Current platform', platform],
[
`Query Engine${useNodeAPI ? ' (Node-API)' : ''}`,
`Query Engine${
cliQueryEngineBinaryType === BinaryType.libqueryEngine
? ' (Node-API)'
: ' (Binary)'
}`,
this.printBinaryInfo(queryEngine),
],
['Migration Engine', this.printBinaryInfo(migrationEngine)],
Expand Down
36 changes: 18 additions & 18 deletions packages/cli/src/__tests__/__snapshots__/version.test.ts.snap
Expand Up @@ -13,15 +13,15 @@ Studio : placeholder
`;

exports[`version basic version 1`] = `
prisma : placeholder
@prisma/client : placeholder
Current platform : placeholder
Query Engine : placeholder
Migration Engine : placeholder
Introspection Engine : placeholder
Format Binary : placeholder
Default Engines Hash : placeholder
Studio : placeholder
prisma : placeholder
@prisma/client : placeholder
Current platform : placeholder
Query Engine (Binary) : placeholder
Migration Engine : placeholder
Introspection Engine : placeholder
Format Binary : placeholder
Default Engines Hash : placeholder
Studio : placeholder
`;

exports[`version version with custom binaries (Node-API) 1`] = `
Expand All @@ -37,13 +37,13 @@ Studio : placeholder
`;

exports[`version version with custom binaries 1`] = `
prisma : placeholder
@prisma/client : placeholder
Current platform : placeholder
Query Engine : placeholder
Migration Engine : placeholder
Introspection Engine : placeholder
Format Binary : placeholder
Default Engines Hash : placeholder
Studio : placeholder
prisma : placeholder
@prisma/client : placeholder
Current platform : placeholder
Query Engine (Binary) : placeholder
Migration Engine : placeholder
Introspection Engine : placeholder
Format Binary : placeholder
Default Engines Hash : placeholder
Studio : placeholder
`;
5 changes: 3 additions & 2 deletions packages/cli/src/__tests__/version.test.ts
@@ -1,4 +1,5 @@
import { download } from '@prisma/fetch-engine'
import { getCliQueryEngineBinaryType } from '@prisma/engines'
import { BinaryType, download } from '@prisma/fetch-engine'
import { getPlatform } from '@prisma/get-platform'
import { engineEnvVarMap } from '@prisma/sdk'
import makeDir from 'make-dir'
Expand All @@ -7,7 +8,7 @@ import { consoleContext, Context } from './__helpers__/context'

const ctx = Context.new().add(consoleContext()).assemble()
const testIf = (condition: boolean) => (condition ? test : test.skip)
const useNodeAPI = process.env.PRISMA_FORCE_NAPI === 'true'
const useNodeAPI = getCliQueryEngineBinaryType() === BinaryType.libqueryEngine
const version = 'e6bd3dc12d849124a04c3a8e6bd9c194381afda3'

describe('version', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/client/fixtures/blog/main.ts
Expand Up @@ -24,7 +24,10 @@ async function main() {
_count: true,
})
const count = await prisma.user.count()

console.log({
//@ts-ignore
engineType: prisma._clientEngineType,
aggregate,
groupBy,
count,
Expand Down
3 changes: 2 additions & 1 deletion packages/client/fixtures/blog/prisma/schema.prisma
Expand Up @@ -5,7 +5,8 @@ datasource db {

generator client {
provider = "prisma-client-js"
previewFeatures = ["napi", "selectRelationCount"]
previewFeatures = ["selectRelationCount"]
engineType = "binary"
}

model Events {
Expand Down