From 59a5195d29b8995678ed51e647066650240f79ec Mon Sep 17 00:00:00 2001 From: Jon Harrell <4829245+jharrell@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:49:18 -0500 Subject: [PATCH] slight tweaks to title and naming --- .../150-writing-custom-sql/200-raw-queries.mdx | 6 +++--- .../150-writing-custom-sql/index.mdx | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/content/200-orm/200-prisma-client/150-writing-custom-sql/200-raw-queries.mdx b/content/200-orm/200-prisma-client/150-writing-custom-sql/200-raw-queries.mdx index b1a974d187..ab6b75993c 100644 --- a/content/200-orm/200-prisma-client/150-writing-custom-sql/200-raw-queries.mdx +++ b/content/200-orm/200-prisma-client/150-writing-custom-sql/200-raw-queries.mdx @@ -7,7 +7,7 @@ tocDepth: 3 :::warning -With Prisma ORM 5.18.0, we have released [TypedSQL](/orm/prisma-client/writing-custom-sql). TypedSQL is a new way to write type-safe SQL queries that are type-safe and even easier to add to your workflow. Whenever possible, we recommend using TypedSQL queries over legacy raw queries. +With Prisma ORM 5.18.0, we have released [TypedSQL](/orm/prisma-client/writing-custom-sql). TypedSQL is a new way to write type-safe SQL queries that are type-safe and even easier to add to your workflow. We strongly recommend using TypedSQL queries over the legacy raw queries described in this document whenever possible. The following information is maintained for backward compatibility and specific use cases where TypedSQL may not be applicable. ::: @@ -797,11 +797,11 @@ prisma.$runCommandRaw({ }) ``` - +:::warning Do not use `$runCommandRaw()` for queries which contain the `"find"` or `"aggregate"` commands, because you might be unable to fetch all data. This is because MongoDB returns a [cursor](https://docs.mongodb.com/manual/tutorial/iterate-a-cursor/) that is attached to your MongoDB session, and you might not hit the same MongoDB session every time. For these queries, you should use the specialised [`findRaw()`](#findraw) and [`aggregateRaw()`](#aggregateraw) methods instead. - +::: #### Return type diff --git a/content/200-orm/200-prisma-client/150-writing-custom-sql/index.mdx b/content/200-orm/200-prisma-client/150-writing-custom-sql/index.mdx index 0073469c26..ba61c0954d 100644 --- a/content/200-orm/200-prisma-client/150-writing-custom-sql/index.mdx +++ b/content/200-orm/200-prisma-client/150-writing-custom-sql/index.mdx @@ -1,7 +1,7 @@ --- -title: 'Writing SQL' -metaTitle: 'Writing Custom SQL in Prisma Client' -metaDescription: 'Learn how to use your own custom SQL queries in Prisma Client.' +title: 'Using Raw SQL' +metaTitle: 'Using Raw SQL in Prisma Client' +metaDescription: 'Learn how to use raw SQL queries in Prisma Client.' hide_table_of_contents: true --- @@ -23,7 +23,7 @@ TypedSQL is available in Prisma ORM 5.18.0 and later. For raw database access in ### What is TypedSQL? -TypedSQL is new feature in Prisma ORM that bridges the gap between raw SQL and type-safe TypeScript code. It allows you to write SQL queries in dedicated `.sql` files while leveraging the full type safety and developer experience of Prisma Client. +TypedSQL is a feature in Prisma ORM that bridges the gap between raw SQL and type-safe TypeScript code. It allows you to write SQL queries in dedicated `.sql` files while leveraging the full type safety and developer experience of Prisma Client. With TypedSQL, you can: @@ -42,11 +42,13 @@ By using TypedSQL, you can write efficient, type-safe database queries without s For a detailed guide on how to get started with TypedSQL, including setup instructions and usage examples, please refer to our [TypedSQL documentation](/orm/prisma-client/writing-custom-sql/typedsql). -## Raw SQL queries +## Raw queries -Prior to version 5.18.0, Prisma Client only supported raw SQL queries that were not type-safe and required manual mapping of the query result to the desired type. While not as ergonomic as [TypedSQL](#writing-type-safe-queries-with-prisma-client-and-typedsql), these queries are still supported and are useful when a query is dynamically generated. +Prior to version 5.18.0, Prisma Client only supported raw SQL queries that were not type-safe and required manual mapping of the query result to the desired type. -### Legacy raw queries in relational databases +While not as ergonomic as [TypedSQL](#writing-type-safe-queries-with-prisma-client-and-typedsql), these queries are still supported and are useful when TypedSQL queries are not possible either due to features not yet supported in TypedSQL or when the query is dynamically generated. + +### Legacy raw SQL queries in relational databases Prisma ORM supports four methods to execute raw SQL queries in relational databases: