Skip to content

Commit

Permalink
Merge branch 'deps/engines-5.15.0-26.9599c67575e2ecde6e2aa528c1f8e287…
Browse files Browse the repository at this point in the history
…52413cd0' into integration/fix-sqlite-d1-max-bind-values
  • Loading branch information
jkomyno committed May 31, 2024
2 parents 4d058ed + 9156baa commit 84acdf8
Show file tree
Hide file tree
Showing 56 changed files with 708 additions and 149 deletions.
2 changes: 1 addition & 1 deletion packages/adapter-neon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"devDependencies": {
"@neondatabase/serverless": "0.9.3",
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"jest": "29.7.0",
"jest-junit": "16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-pg-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"devDependencies": {
"@prisma/pg-worker": "workspace:*",
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"jest": "29.7.0",
"jest-junit": "16.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-pg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"postgres-array": "3.0.2"
},
"devDependencies": {
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"@types/pg": "8.11.6",
"jest": "29.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-planetscale/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"devDependencies": {
"@planetscale/database": "1.18.0",
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"jest": "29.7.0",
"jest-junit": "16.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@prisma/mini-proxy": "0.9.5",
"@prisma/studio": "0.500.0",
"@prisma/studio-server": "0.500.0",
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"@types/debug": "4.1.12",
"@types/fs-extra": "9.0.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/test-handlePanic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function main() {
projectDir: dirPath,
})

await engine.introspect({ schema: toSchemasContainer(schemas), force: false })
await engine.introspect({ schema: toSchemasContainer(schemas), baseDirectoryPath: dirPath, force: false })
await engine.debugPanic()
} catch (err) {
console.debug({ err })
Expand Down
6 changes: 3 additions & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
"@prisma/debug": "workspace:*",
"@prisma/driver-adapter-utils": "workspace:*",
"@prisma/engines": "workspace:*",
"@prisma/engines-version": "5.15.0-24.9ee43833e58f4ec014ce0f45b6ae27ee7e0165fc",
"@prisma/engines-version": "5.15.0-26.9599c67575e2ecde6e2aa528c1f8e28752413cd0",
"@prisma/fetch-engine": "workspace:*",
"@prisma/generator-helper": "workspace:*",
"@prisma/get-platform": "workspace:*",
Expand All @@ -192,10 +192,10 @@
"@prisma/migrate": "workspace:*",
"@prisma/mini-proxy": "0.9.5",
"@prisma/pg-worker": "workspace:*",
"@prisma/query-engine-wasm": "5.15.0-24.9ee43833e58f4ec014ce0f45b6ae27ee7e0165fc",
"@prisma/query-engine-wasm": "5.15.0-26.9599c67575e2ecde6e2aa528c1f8e28752413cd0",
"@snaplet/copycat": "0.17.3",
"@swc-node/register": "1.9.1",
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"@timsuchanek/copy": "1.4.5",
"@types/debug": "4.1.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/engines/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "Apache-2.0",
"author": "Tim Suchanek <suchanek@prisma.io>",
"devDependencies": {
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"@types/jest": "29.5.12",
"@types/node": "18.19.31",
Expand All @@ -22,7 +22,7 @@
},
"dependencies": {
"@prisma/debug": "workspace:*",
"@prisma/engines-version": "5.15.0-24.9ee43833e58f4ec014ce0f45b6ae27ee7e0165fc",
"@prisma/engines-version": "5.15.0-26.9599c67575e2ecde6e2aa528c1f8e28752413cd0",
"@prisma/fetch-engine": "workspace:*",
"@prisma/get-platform": "workspace:*"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/fetch-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"bugs": "https://github.com/prisma/prisma/issues",
"enginesOverride": {},
"devDependencies": {
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"@types/jest": "29.5.12",
"@types/node": "18.19.31",
Expand Down Expand Up @@ -43,7 +43,7 @@
},
"dependencies": {
"@prisma/debug": "workspace:*",
"@prisma/engines-version": "5.15.0-24.9ee43833e58f4ec014ce0f45b6ae27ee7e0165fc",
"@prisma/engines-version": "5.15.0-26.9599c67575e2ecde6e2aa528c1f8e28752413cd0",
"@prisma/get-platform": "workspace:*"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/generator-helper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"devDependencies": {
"@swc-node/register": "1.9.1",
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"@types/jest": "29.5.12",
"@types/node": "18.19.31",
Expand Down
2 changes: 1 addition & 1 deletion packages/get-platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"bugs": "https://github.com/prisma/prisma/issues",
"devDependencies": {
"@codspeed/benchmark.js-plugin": "3.1.0",
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"@types/jest": "29.5.12",
"@types/node": "18.19.31",
Expand Down
10 changes: 10 additions & 0 deletions packages/get-platform/src/test-utils/jestContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export type BaseContext = {
* For this to work the source must be built
*/
cli: (...input: string[]) => ExecaChildProcess<string>

printDir(dir: string, extensions: string[]): void
}

/**
Expand Down Expand Up @@ -63,6 +65,14 @@ export const jestContext = {
all: true,
})
}
c.printDir = (dir, extensions) => {
const content = c.fs.list(dir) ?? []
content.sort((a, b) => a.localeCompare(b))
return content
.filter((name) => extensions.includes(path.extname(name)))
.map((name) => `${name}:\n\n${c.fs.read(path.join(dir, name))}`)
.join('\n\n')
}
process.chdir(c.tmpDir)
})

Expand Down
2 changes: 1 addition & 1 deletion packages/instrumentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"bugs": "https://github.com/prisma/prisma/issues",
"devDependencies": {
"@prisma/internals": "workspace:*",
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@types/jest": "29.5.12",
"@types/node": "18.19.31",
"jest": "29.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@prisma/internals": "workspace:*",
"@prisma/migrate": "workspace:*",
"@sindresorhus/slugify": "1.1.2",
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"@types/jest": "29.5.12",
"@types/mssql": "9.1.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ export function introspectionIntegrationTest<Client>(input: Input<Client>) {
const { state, introspectionResult } = await setupScenario(kind, input, scenario)
states[scenario.name] = state

expect(introspectionResult.datamodel).toMatchSnapshot(`datamodel`)
expect(introspectionResult.schema.files.length).toBe(1)
expect(introspectionResult.schema.files[0].content).toMatchSnapshot(`datamodel`)
expect(introspectionResult.warnings).toMatchSnapshot(`warnings`)

await teardownScenario(state)
Expand Down Expand Up @@ -308,11 +309,12 @@ async function setupScenario(kind: string, input: Input, scenario: Scenario) {
schema: {
files: [{ path: 'schema.prisma', content: schemaBase }],
},
baseDirectoryPath: process.cwd(),
})

const prismaSchemaPath = ctx.fs.path('schema.prisma')

await fs.writeAsync(prismaSchemaPath, introspectionResult.datamodel)
await fs.writeAsync(prismaSchemaPath, introspectionResult.schema.files[0].content)
return {
introspectionResult,
state,
Expand Down
2 changes: 1 addition & 1 deletion packages/internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@prisma/fetch-engine": "workspace:*",
"@prisma/generator-helper": "workspace:*",
"@prisma/get-platform": "workspace:*",
"@prisma/prisma-schema-wasm": "5.15.0-24.9ee43833e58f4ec014ce0f45b6ae27ee7e0165fc",
"@prisma/prisma-schema-wasm": "5.15.0-26.9599c67575e2ecde6e2aa528c1f8e28752413cd0",
"@prisma/schema-files-loader": "workspace:*",
"arg": "5.0.2",
"prompts": "2.4.2"
Expand Down
18 changes: 16 additions & 2 deletions packages/internals/src/cli/getSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ const readFile = promisify(fs.readFile)
const debug = Debug('prisma:getSchema')

export type GetSchemaResult = {
/**
* A path from which schema was loaded
* Can be either folder or a single file
*/
schemaPath: string
/**
* Base dir for all of the schema files.
* In-multi file mode, this is equal to `schemaPath`.
* In single-file mode, this is a parent directory of
* a file
*/
schemaRootDir: string
/**
* All loaded schema files
*/
schemas: MultipleSchemas
}

Expand Down Expand Up @@ -45,7 +59,7 @@ export async function readSchemaFromSingleFile(schemaPath: string): Promise<GetS
debug('Reading schema from single file', schemaPath)
const file = await readFile(schemaPath, { encoding: 'utf-8' })
const schemaTuple: MultipleSchemaTuple = [schemaPath, file]
return { schemaPath, schemas: [schemaTuple] } as const
return { schemaPath, schemaRootDir: path.dirname(schemaPath), schemas: [schemaTuple] } as const
}

async function readSchemaFromMultiFiles(schemaPath: string): Promise<GetSchemaResult | null> {
Expand All @@ -63,7 +77,7 @@ async function readSchemaFromMultiFiles(schemaPath: string): Promise<GetSchemaRe
debug('Ok')

if (usesPrismaSchemaFolder(config)) {
return { schemaPath, schemas: files } as const
return { schemaPath, schemaRootDir: schemaPath, schemas: files } as const
}

return null
Expand Down
4 changes: 2 additions & 2 deletions packages/migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"devDependencies": {
"@sindresorhus/slugify": "1.1.2",
"@swc/core": "1.5.7",
"@swc/core": "1.5.24",
"@swc/jest": "0.2.36",
"@types/jest": "29.5.12",
"@types/node": "18.19.31",
Expand Down Expand Up @@ -57,7 +57,7 @@
},
"dependencies": {
"@prisma/debug": "workspace:*",
"@prisma/engines-version": "5.15.0-24.9ee43833e58f4ec014ce0f45b6ae27ee7e0165fc",
"@prisma/engines-version": "5.15.0-26.9599c67575e2ecde6e2aa528c1f8e28752413cd0",
"@prisma/generator-helper": "workspace:*",
"@prisma/get-platform": "workspace:*",
"@prisma/internals": "workspace:*",
Expand Down
34 changes: 34 additions & 0 deletions packages/migrate/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
generator client {
provider = "prisma-client-js"
output = "../generated/client"
}

datasource db {
provider = "sqlite"
url = "file:dev.db"
}

model Post {
authorId Int
content String?
createdAt DateTime @default(now())
id Int @id @default(autoincrement())
published Boolean @default(false)
title String
User User @relation(fields: [authorId], references: [id], onDelete: Cascade)
}

model Profile {
bio String?
id Int @id @default(autoincrement())
userId Int @unique(map: "Profile.userId")
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
email String @unique(map: "User.email")
id Int @id @default(autoincrement())
name String?
Post Post[]
Profile Profile?
}
4 changes: 3 additions & 1 deletion packages/migrate/src/SchemaEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,17 @@ export class SchemaEngine {
public async introspect({
schema,
force = false,
baseDirectoryPath,
compositeTypeDepth = -1, // cannot be undefined
namespaces,
}: EngineArgs.IntrospectParams): Promise<EngineArgs.IntrospectResult> {
this.latestSchema = schema

try {
const introspectResult: EngineArgs.IntrospectResult = await this.runCommand(
this.getRPCPayload('introspect', { schema, force, compositeTypeDepth, namespaces }),
this.getRPCPayload('introspect', { schema, force, compositeTypeDepth, namespaces, baseDirectoryPath }),
)

const { views } = introspectResult

if (views) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`reintrospection - no changes 2`] = `
"Prisma schema loaded from prisma/schema
Datasource "my_db": SQLite database "dev.db" at "file:dev.db"
- Introspecting based on datasource defined in prisma/schema
✔ Introspected 2 models and wrote them into prisma/schema in XXXms
Run prisma generate to generate Prisma Client.
"
`;

exports[`reintrospection - with --print 2`] = `
"// prisma/schema/Blog.prisma
model Blog {
id Int @id @default(autoincrement())
viewCount20 Int
ownerId Int
owner User @relation(fields: [ownerId], references: [id])
}
// prisma/schema/config.prisma
generator client {
provider = "prisma-client-js"
output = "@prisma/client"
previewFeatures = ["prismaSchemaFolder"]
}
datasource my_db {
provider = "sqlite"
url = "file:dev.db"
}
// prisma/schema/User.prisma
model User {
id Int @id @default(autoincrement())
blogs Blog[]
}
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe('postgresql-views', () => {

const introspectionResult = await engine.introspect({
schema: toSchemasContainer(schemas),
baseDirectoryPath: ctx.tmpDir,
force: false,
})

Expand All @@ -126,6 +127,7 @@ describe('postgresql-views', () => {

const introspectionResult = await engine.introspect({
schema: toSchemasContainer(schemas),
baseDirectoryPath: ctx.tmpDir,
force: false,
})

Expand Down Expand Up @@ -154,6 +156,7 @@ describe('postgresql-views', () => {

const introspectionResult = await engine.introspect({
schema: toSchemasContainer(schemas),
baseDirectoryPath: ctx.tmpDir,
force: false,
})

Expand Down Expand Up @@ -182,6 +185,7 @@ describe('postgresql-views', () => {

const introspectionResult = await engine.introspect({
schema: toSchemasContainer(schemas),
baseDirectoryPath: ctx.tmpDir,
force: false,
})

Expand Down
Loading

0 comments on commit 84acdf8

Please sign in to comment.