Skip to content

Commit

Permalink
added patch for client type in transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
HRM committed Sep 9, 2024
1 parent 0dcf7f4 commit f868980
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prisma-nitro-patcher",
"version": "0.0.8",
"version": "0.0.9",
"description": "Applies a patch on the prisma client to improve the performance of extensions",
"files": [ "dist" ],
"bin": {
Expand Down
16 changes: 11 additions & 5 deletions src/patchPrisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export function patchPrisma(contents: string): string {
}
if (
contents.indexOf('runtime.Types.Result') == -1 ||
contents.indexOf('$extends: $Extensions.ExtendsHook') == -1
contents.indexOf('$extends: $Extensions.ExtendsHook') == -1 ||
contents.indexOf('$transaction<R>(fn: (prisma: Omit<PrismaClient') == -1
) {
throw new PresentableError(
'The prisma version or file provided is not compatible with patching',
Expand All @@ -85,8 +86,13 @@ export function patchPrisma(contents: string): string {
1,
extendsHookModified,
);
return contentWithPatchType.replace(
'$extends: $Extensions.ExtendsHook',
'$extends: ExtendsHookModified',
);
return contentWithPatchType
.replace(
'$extends: $Extensions.ExtendsHook',
'$extends: ExtendsHookModified',
)
.replace(
'$transaction<R>(fn: (prisma: Omit<PrismaClient',
'$transaction<R>(fn: (prisma: Omit<this',
);
}
2 changes: 1 addition & 1 deletion tests/files/ver-5.19.1/index-patched.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class PrismaClient<
*/
$transaction<P extends Prisma.PrismaPromise<any>[]>(arg: [...P], options?: { isolationLevel?: Prisma.TransactionIsolationLevel }): $Utils.JsPromise<runtime.Types.Utils.UnwrapTuple<P>>

$transaction<R>(fn: (prisma: Omit<PrismaClient, runtime.ITXClientDenyList>) => $Utils.JsPromise<R>, options?: { maxWait?: number, timeout?: number, isolationLevel?: Prisma.TransactionIsolationLevel }): $Utils.JsPromise<R>
$transaction<R>(fn: (prisma: Omit<this, runtime.ITXClientDenyList>) => $Utils.JsPromise<R>, options?: { maxWait?: number, timeout?: number, isolationLevel?: Prisma.TransactionIsolationLevel }): $Utils.JsPromise<R>


$extends: ExtendsHookModified<"extends", Prisma.TypeMapCb, ExtArgs>
Expand Down

0 comments on commit f868980

Please sign in to comment.