-
Notifications
You must be signed in to change notification settings - Fork 15
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: rollback called explicitly working. #47
base: main
Are you sure you want to change the base?
Conversation
@@ -33,12 +34,13 @@ const prisma = new PrismaClient({ log: ["query"] }).$extends({ | |||
) { | |||
const tx = prisma.$transaction((txClient) => { | |||
setTxClient(txClient as unknown as Prisma.TransactionClient); | |||
|
|||
return txPromise.catch((e) => { | |||
if (e === ROLLBACK) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this swallows the exception that actually triggers the rollback.
@@ -17,7 +18,7 @@ const prisma = new PrismaClient({ log: ["query"] }).$extends({ | |||
|
|||
// a promise for getting the tx inner client | |||
const txClient = new Promise<Prisma.TransactionClient>((res) => { | |||
setTxClient = (txClient) => res(txClient); | |||
setTxClient = res; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary function.
const tx2 = await prisma.$begin(); | ||
await tx2.user.findMany(); | ||
// const tx2 = await prisma.$begin(); | ||
// await tx2.user.findMany(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to me the important part to show in transactions is rollback, maybe we should show both.
@jspears Thanks!! Your PR helped me a lot. |
* feat(be): implement transaction extension for prisma client prisma/prisma-client-extensions#47 참고하여 작성했습니다 * feat(be): add transaction extension on index ts file * feat(be): implement transaction rollback for group service unit test * test(be): add comments and type * test(be): add await keyword * test(be): add chai exclude * test(be): delete override prisma service func * test(be): increase timeout for before each hook * test(be): disable timeout for before each hook * test(be): add comment * test(be): fix comment
Rollback was not working when explicitly called.
This PR changes the script to test that and actually call rollback. This code should be much more rigorously tested than this, but alas I do not have time.