Skip to content

Commit 0173706

Browse files
authored
fix: prisma-7 compatibility issue caused by @prisma/internals version mismatch (#2323)
1 parent ea93dd6 commit 0173706

File tree

3 files changed

+137
-4
lines changed

3 files changed

+137
-4
lines changed

packages/sdk/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"dependencies": {
2121
"@prisma/generator-helper": "6.19.x",
2222
"@prisma/internals": "6.19.x",
23+
"@prisma/internals-v7": "npm:@prisma/internals@7",
2324
"@zenstackhq/language": "workspace:*",
2425
"@zenstackhq/runtime": "workspace:*",
2526
"langium": "1.3.1",

packages/sdk/src/prisma.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
import type { DMMF } from '@prisma/generator-helper';
44
import { getDMMF as _getDMMF, type GetDMMFOptions } from '@prisma/internals';
5+
import { getDMMF as _getDMMF7 } from '@prisma/internals-v7';
56
import { DEFAULT_RUNTIME_LOAD_PATH } from '@zenstackhq/runtime';
67
import path from 'path';
78
import semver from 'semver';
89
import { Model } from './ast';
910
import { RUNTIME_PACKAGE } from './constants';
11+
import { normalizedRelative } from './path';
1012
import type { PluginOptions } from './types';
1113
import { getDataSourceProvider } from './utils';
12-
import { normalizedRelative } from './path';
1314

1415
/**
1516
* Given an import context directory and plugin options, compute the import spec for the Prisma Client.
@@ -51,7 +52,12 @@ function normalizePath(p: string) {
5152
* Loads Prisma DMMF
5253
*/
5354
export function getDMMF(options: GetDMMFOptions): Promise<DMMF.Document> {
54-
return _getDMMF(options);
55+
const prismaVersion = getPrismaVersion();
56+
if (prismaVersion && semver.gte(prismaVersion, '7.0.0')) {
57+
return _getDMMF7(options);
58+
} else {
59+
return _getDMMF(options);
60+
}
5561
}
5662

5763
/**

pnpm-lock.yaml

Lines changed: 128 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)