MCPcopy
hub / github.com/prisma/prisma / $executeRaw

Method $executeRaw

packages/client/src/runtime/getPrismaClient.ts:569–593  ·  view source on GitHub ↗

* Executes a raw query provided through a safe tag function * @see https://github.com/prisma/prisma/issues/7142 * * @param query * @param values * @returns

(query: TemplateStringsArray | Sql, ...values: any[])

Source from the content-addressed store, hash-verified

567 * @returns
568 */
569 $executeRaw(query: TemplateStringsArray | Sql, ...values: any[]) {
570 return this._createPrismaPromise((transaction) => {
571 if ((query as TemplateStringsArray).raw !== undefined || (query as Sql).sql !== undefined) {
572 const [sql, argsMapper] = toSql(query, values)
573 checkAlter(
574 this._activeProvider,
575 sql.text,
576 sql.values,
577 Array.isArray(query) ? 'prisma.$executeRaw`<SQL>`' : 'prisma.$executeRaw(sql`<SQL>`)',
578 )
579 return this.$executeRawInternal(transaction, '$executeRaw', sql, argsMapper)
580 }
581
582 throw new PrismaClientValidationError(
583 `\`$executeRaw\` is a tag function, please use it like the following:
584\`\`\`
585const result = await prisma.$executeRaw\`UPDATE User SET cool = \${true} WHERE email = \${'user@email.com'};\`
586\`\`\`
587
588Or read our docs at https://www.prisma.io/docs/concepts/components/prisma-client/raw-database-access#executeraw
589`,
590 { clientVersion: this._clientVersion },
591 )
592 })
593 }
594
595 /**
596 * Unsafe counterpart of `$executeRaw` that is susceptible to SQL injections

Callers 15

mainFunction · 0.95
mainFunction · 0.95
test.tsFile · 0.80
test.tsFile · 0.80
test.tsFile · 0.80
tests.tsFile · 0.80
tests.tsFile · 0.80
test.tsFile · 0.80
tests.tsFile · 0.80
test.tsFile · 0.80
tests.tsFile · 0.80

Calls 3

$executeRawInternalMethod · 0.95
checkAlterFunction · 0.90
toSqlFunction · 0.85

Tested by 2

mainFunction · 0.76
mainFunction · 0.76