Skip to content
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

new raw sql pages #6170

Merged
merged 31 commits into from
Aug 27, 2024
Merged

new raw sql pages #6170

merged 31 commits into from
Aug 27, 2024

Conversation

jharrell
Copy link
Member

@jharrell jharrell commented Jul 30, 2024

Resolves DA-1117
Resolves DA-1116
Resolves DA-1227

@jharrell jharrell self-assigned this Jul 30, 2024
Copy link
Contributor

Absolute URL check

No absolute URLs to prisma.io/docs found.

Copy link
Contributor

github-actions bot commented Jul 30, 2024

original preview
content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx content/200-orm/200-prisma-client/150-using-raw-sql/100-typedsql.mdx
content/200-orm/200-prisma-client/150-using-raw-sql/index.mdx content/200-orm/200-prisma-client/150-using-raw-sql/index.mdx
content/200-orm/050-overview/100-introduction/250-should-you-use-prisma.mdx content/200-orm/050-overview/100-introduction/250-should-you-use-prisma.mdx
content/200-orm/100-prisma-schema/20-data-model/10-models.mdx content/200-orm/100-prisma-schema/20-data-model/10-models.mdx
content/200-orm/100-prisma-schema/20-data-model/40-views.mdx content/200-orm/100-prisma-schema/20-data-model/40-views.mdx
content/200-orm/200-prisma-client/000-setup-and-configuration/200-read-replicas.mdx content/200-orm/200-prisma-client/000-setup-and-configuration/200-read-replicas.mdx
content/200-orm/200-prisma-client/100-queries/030-crud.mdx content/200-orm/200-prisma-client/100-queries/030-crud.mdx
content/200-orm/200-prisma-client/100-queries/058-transactions.mdx content/200-orm/200-prisma-client/100-queries/058-transactions.mdx
content/200-orm/200-prisma-client/100-queries/060-full-text-search.mdx content/200-orm/200-prisma-client/100-queries/060-full-text-search.mdx
content/200-orm/200-prisma-client/300-client-extensions/120-query.mdx content/200-orm/200-prisma-client/300-client-extensions/120-query.mdx
content/200-orm/500-reference/050-prisma-client-reference.mdx content/200-orm/500-reference/050-prisma-client-reference.mdx
content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx content/200-orm/500-reference/500-preview-features/050-client-preview-features.mdx
content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/700-upgrading-to-prisma-4.mdx content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/700-upgrading-to-prisma-4.mdx
content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/150-referential-actions.mdx content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/150-referential-actions.mdx
content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/index.mdx content/200-orm/800-more/300-upgrade-guides/200-upgrading-versions/800-upgrading-to-prisma-3/index.mdx
content/200-orm/800-more/400-comparisons/01-prisma-and-typeorm.mdx content/200-orm/800-more/400-comparisons/01-prisma-and-typeorm.mdx
content/200-orm/800-more/400-comparisons/04-prisma-and-drizzle.mdx content/200-orm/800-more/400-comparisons/04-prisma-and-drizzle.mdx
content/200-orm/800-more/600-help-and-troubleshooting/100-help-articles/500-comparing-columns-through-raw-queries.mdx content/200-orm/800-more/600-help-and-troubleshooting/100-help-articles/500-comparing-columns-through-raw-queries.mdx
content/300-accelerate/500-limitations.mdx content/300-accelerate/500-limitations.mdx
content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx content/200-orm/200-prisma-client/150-using-raw-sql/200-raw-queries.mdx
content/200-orm/200-prisma-client/150-using-raw-sql/300-safeql.mdx content/200-orm/200-prisma-client/150-using-raw-sql/300-safeql.mdx

Copy link
Contributor

github-actions bot commented Jul 30, 2024

Redirect check

This PR probably requires the following redirects to be added to static/_redirects:

/orm/prisma-client/queries/raw-database-access /docs/##( TODO: Path of page that replaces deleted page )##
/orm/prisma-client/queries/raw-database-access/raw-queries /docs/orm/prisma-client/using-raw-sql/raw-queries
/orm/prisma-client/queries/raw-database-access/custom-and-type-safe-queries /docs/orm/prisma-client/using-raw-sql/safeql

Copy link

cloudflare-workers-and-pages bot commented Jul 30, 2024

Deploying docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6bee122
Status: ✅  Deploy successful!
Preview URL: https://f61a8c31.docs-51g.pages.dev
Branch Preview URL: https://feat-typedsql.docs-51g.pages.dev

View logs

@jharrell jharrell marked this pull request as ready for review August 1, 2024 16:37
@ankur-arch
Copy link
Contributor

@jharrell I like most of the changes. One suggestion and a nice to have IMO is a limitations section and a usage section.

The usage section can be done incrementally, post launch as you've added a guide and also an example project. It would have explanations on how to pass in parameters, and write different types of queries.

For the limitations section, we could have something like this:

Limitations of TypeSQL

Supported Databases

TypeSQL supports a variety of databases, ensuring broad compatibility. For the most current list of supported databases, please consult the official documentation, as new database support may be added over time.

Dynamic SQL Queries with Dynamic Columns

TypeSQL does not natively support constructing SQL queries with dynamically added columns. When you need to create a query where the columns are determined at runtime, you must use the queryRaw and executeRaw methods. These methods allow for the execution of raw SQL, which can include dynamic column selections.

Example of a Dynamic Column Query Using queryRaw:

const columns = 'name, email, age'; // Columns determined at runtime
const result = await prisma.$queryRaw(
  `SELECT ${columns} FROM Users WHERE active = true`
);

In this example, the columns to be selected are defined dynamically and included in the SQL query. While this approach provides flexibility, it requires careful attention to security, particularly to avoid SQL injection vulnerabilities. Additionally, using raw SQL queries means foregoing the type safety and benefits of TypeSQL's query builder.

@SevInf
Copy link
Contributor

SevInf commented Aug 2, 2024

@ankur-arch, your example does not actually work with $queryRaw for this case you need queryRawUnsafe

Co-authored-by: Ankur Datta <64993082 [email protected]>
Co-authored-by: Ankur Datta <64993082 [email protected]>
Copy link
Contributor

@mhessdev mhessdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont mention that you need to regenerate with the --sql flag after running a migration anywhere.

@jharrell jharrell merged commit 133e99a into main Aug 27, 2024
10 checks passed
@jharrell jharrell deleted the feat/typedsql branch August 27, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants