Feature/Question: Would like to execute query with Prisma.$queryRaw or $executeRaw
I use prisma-kysely to generate my kysely types and i find this to be a great workflow. I still like using prisma for most of my usecase because I have other implementations to enforce security and business logic. I find it unnecessary to include
pg
module if i already have a query-executor and a connection with prisma. It would be nice to do something like the following:
instead of:
Use the dialect without a connection or pool:
Use the dialect passing a custom runner:
Solution:Jump to solution
9 Replies
Solution
You could also implement a custom
Driver
that uses the prisma instance. The Driver
interface is pretty simple. You can get inspiration from the built-in and 3rd party dialects.A prisma dialect is actually a great idea, since many of our users use Kysely with prisma-kysely, and if cold starts are not an issue, could call prisma directly from kysely executes.
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
Like this
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Every query builder not written by complete morons take care of parameterizing inputs. If you doubt we haven't considered SQL injection, or don't know what it is, you should stay far far away from us.
However, if you explicitly use unsafe SQL functions like
sql.lit
or sql.raw
, everything's possible.
Another way to think about this: Kysely uses similar code internally to execute the queries.
1. The query is compiled into a CompiledQuery
instance
2. The compiled sql and parameters are given to the underlying DB driver
You can easily try stuff and see the generated SQL here https://kyse.linkUnsafe functions only exist under the
sql
object. Each unsafe function has this warning when you hover over itUnknown User•10mo ago
Message Not Public
Sign In & Join Server To View