valtyr/prisma-kysely

Use prisma transaction with kysely

Closed this issue · 1 comments

First of all, thanks for your plugin !

I have an integration issue with kysely and prisma, I want to be able to use prisma transaction with kysely query building as possible.

My use case is that I have a function with a prisma transaction as parameter that is using prisma for some queries but I need a kysely query in between for a feature that prisma can't do.
But I want to be using the same transaction as prisma so if it fails, it rollback automatically.

Is there a way of doing it ? I've tried doing this :

const query = await kysely.insertInto("VariableValues")
        .values(variableValuesData)
        .returning("VariableValues.uid")
        .compile()
const variableValues = await tx.$queryRawUnsafe(
        query.sql,
        ...query.parameters
)

But it doesn't seems to work for enums and automatic type conversion that normally would work with kysely or prisma.

Thanks for your help !

Hi there, I'm sorry but this isn't the right forum for this question. Prisma-kysely only deals with generating Kysely types with prisma schemas, not hooking Kysely up to the Prisma client. You might want to try creating this issue on the https://github.com/eoin-obrien/prisma-extension-kysely repository.