Alex Ruheni
3.14.0
prisma rainbow
๐ฆฆ CockroachDB connector is now Generally Available!
We are proud to announce that the CockroachDB connector is now stable and Generally Available.
If youโre upgrading from Prisma version `3.9.0`+ or the PostgreSQL connector, you can now run npx prisma db pull
and review the changes to your schema. To learn more about CockroachDB-specific native types we support, refer to our docs.
To learn more about the connector and how it differs from PostgreSQL, head to our documentation.
โก*๏ธ PostgreSQL GIN
, GiST
, SP-GiST
, and BRIN
indexes support (Preview)*
This release has expanded index type support with the GIN, GiST, SP-GiST, and BRIN indexes.
To make use of an index type, you can update your Prisma schema by providing the type
argument to the @@index
attribute:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["extendedIndexes"]
}
model Post {
id Int @id
title String
content String?
tags Json?
@@index([tags], type: Gin)
}
The following SQL will be generated in your migration when you run `prisma migrate dev`:
CREATE TABLE "Post" (
"id" INTEGER NOT NULL,
"title" TEXT NOT NULL,
"content" TEXT,
"tags" JSONB,
CONSTRAINT "Post_pkey" PRIMARY KEY ("id")
);
CREATE INDEX "Post_tags_idx" ON "Post" USING GIN ("tags");
To learn more about configuring index types in your schema, refer to our documentation.
๐ช Improved queryRaw
API
In this release, we made improvements to the SQL raw API. Some improvements are breaking and will be available behind the new improvedQueryRaw
Preview feature flag.
generator client {
provider = "prisma-client-js"
previewFeatures = ["improvedQueryRaw"]
}
The improvedQueryRaw
Preview feature solves most of the issues faced when working with the raw API. We would encourage you to turn on the Preview feature flag, try out the new API, and let us know how we can make it even better. Here are some of the improvements we made to `queryRaw`:
1. Raw scalar values are deserialized as their correct JavaScript types
Prisma Client queries such as findMany
deserialize database scalar values to their corresponding JavaScript types. For example, a DateTime
value is deserialized as a JavaScript Date,
and a Bytes
would be deserialized as a JavaScript Buffer
.
Raw queries now implement the same behavior when the improvedQueryRaw
Preview feature flag is enabled. The types of values from the database will be used instead of the types in the Prisma schema.
2. PostgreSQL type-casts
Weโve also fixed a lot of PostgreSQL type-casts that were broken by enabling the improvedQueryRaw
Preview feature flag. A consequence of this fix is that some subtle implicit casts are now handled more strictly and would fail.
3. Query parameters are correctly sent to the database
Before this release, query parameters of type BigInt
, Bytes
, and Decimal
were incorrectly sent to the database leading to instances of unexpected inserts. Passing the types as query parameters now works:
await prisma.$executeRaw`INSERT INTO "Table" ("bigint", "bytes", "decimal") VALUES (${BigInt("123")}, ${Buffer.from([1, 2, 3])}, ${Decimal("12.23")});`
This improvement is available without the๐ Learn more in the release notes For more info and links to documentation, you can read the release notes. ๐ Help us spread the word about Prisma ๐ To help spread the word about Prisma, weโd very much appreciate it if you would star the repo ๐ And if youโre excited about the features in this weekโs release, then help us and share your excitement on Twitter. ๐ฐ Join us on Thursday for the โWhatโs new in Prismaโ livestream This week, @nikolasburk and @Sabin Adams will discuss the latest release and other news from the Prisma ecosystem in a this Thursday at 5 pm Berlin | 8 am San Francisco.Preview feature flag.improvedQueryRaw