5.19.0
版本发布时间: 2024-08-27 23:11:57
prisma/prisma最新发布版本:5.19.1(2024-09-02 22:57:37)
Today, we are excited to share the 5.19.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release. 🌟
Highlights
Introducing TypedSQL
TypedSQL is a brand new way to interact with your database from Prisma Client. After enabling the typedSql
Preview feature, you’re able to write SQL queries in a new sql
subdirectory of your prisma
directory. These queries are then checked by Prisma during using the new --sql
flag of prisma generate
and added to your client for use in your code.
To get started with TypedSQL:
-
Make sure that you have the latest version of
prisma
and@prisma/client
installed:npm install -D prisma@latest npm install @prisma/client@latest
-
Enable the
typedSql
Preview feature in your Prisma Schema.generator client { provider = "prisma-client-js" previewFeatures = ["typedSql"] }
-
Create a
sql
subdirectory of yourprisma
directory.mkdir -p prisma/sql
-
You can now add
.sql
files to thesql
directory! Each file can contain one sql query and the name must be a valid JS identifier. For this example, say you had the filegetUsersWithPosts.sql
with the following contents:SELECT u.id, u.name, COUNT(p.id) as "postCount" FROM "User" u LEFT JOIN "Post" p ON u.id = p."authorId" GROUP BY u.id, u.name
-
Import your SQL query into your code with the
@prisma/client/sql
import:import { PrismaClient } from '@prisma/client' import { getUsersWithPosts } from '@prisma/client/sql' const prisma = new PrismaClient() const usersWithPostCounts = await prisma.$queryRawTyped(getUsersWithPosts) console.log(usersWithPostCounts)
There’s a lot more to talk about with TypedSQL. We think that the combination of the high-level Prisma Client API and the low-level TypedSQL will make for a great developer experience for all of our users.
To learn more about behind the “why” of TypedSQL be sure to check out our announcement blog post.
For docs, check out our new TypedSQL section.
Bug fixes
Driver adapters and D1
A few issues with our driverAdapters
Preview feature and Cloudflare D1 support were resolved via https://github.com/prisma/prisma-engines/pull/4970 and https://github.com/prisma/prisma/pull/24922
- Mathematic operations such as
max
,min
,eq
, etc in queries when using Cloudflare D1. - Resolved issues when comparing
BigInt
IDs whenrelationMode="prisma"
was enabled and Cloudflare D1 was being used.
Joins
-
https://github.com/prisma/prisma/issues/23742 fixes Prisma Client not supporting deeply nested
some
clauses when therelationJoins
Preview feature was enabled.
MongoDB
The MongoDB driver for Rust (that our query engine users under the hood) had behavior that prioritized IPv4 connections over IPv6 connections. In IPv6-only environments, this could lead to significant "cold starts" where the query engine had to wait for IPv4 to fail before the driver would try IPv6.
With help from the MongoDB team, this has been resolved. The driver will now try IPv4 and IPv6 connections in parallel and then move forward with the first response. This should prevent cold start issues that have been seen with MongoDB in Prisma Accelerate.
Thank you to the MongoDB team!
Join us
Looking to make an impact on Prisma in a big way? We're now hiring engineers for the ORM team!
- Senior Engineer (TypeScript): This person will be primarily working on the TypeScript side and evolving our Prisma client. Rust knowledge (or desire to learn Rust) is a plus.
-
Senior Engineer (Rust): This person will be focused on the
prisma-engines
Rust codebase. TypeScript knowledge (or, again, a desire to learn) is a plus.
Credits
Huge thanks to @mcuelenaere, @pagewang0, @Druue, @key-moon, @Jolg42, @pranayat, @ospfranco, @yubrot, @skyzh for helping!