Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release. 🌟
Happy New Year from your friends at Prisma! 🎊
In the last 4 weeks, we resolved some bugs on the ORM and made some progress on some exciting features that we’re not yet ready to announce. Stay tuned for the upcoming releases, in which we’ll be announcing new features. 😉
relationJoins
improvements: Relation loading strategy per query (Preview)In version 5.7.0, we released relationJoins
into Preview. The relationJoins
feature enables support for JOIN
s for relation queries.
This release adds support for the ability to specify the strategy used to fetch relational data per query when the Preview feature is enabled. This will enable you to choose the most efficient strategy for fetching relation data depending on your use case.
You can now load relation data using either of the following strategies:
join
— uses JOIN
s to fetch relation dataquery
— uses separate queries to fetch relation dataWhen the relationJoins
Preview feature is enabled, by default, the relation fetching strategy used is join
. You can override the default behavior by using the relationLoadStrategy
query option.
To get started, enable the Preview feature:
// schema.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["relationJoins"]
}
… and specify the relation loading strategy for your query as follows:
await prisma.user.findMany({
relationLoadStrategy: 'query',
include: {
posts: true,
},
})
Try it out and share your feedback and create a bug report if you encounter any issues.
We’re working on bringing Edge function support to Prisma ORM and we would appreciate your input by submitting a response to our survey. By filling out the survey, you will be considered for our Early Access cohort as soon as we have something for you to try out.
target
and timestamp
are undefined in info
events in Data Proxy client
timestamp
and duration
in query events with Data Proxy
citext
fields with neon database driver causes conversion error
Error validating field 'id' in model 'Post': MongoDB '@default(auto())' fields must have 'ObjectId' native type.
Huge thanks to @anuraaga, @onichandame, @LucianBuzzo, @RobertCraigie, @fqazi, @KhooHaoYit, @alencardc, @Oreilles, @tinola, @AikoRamalho, @luxaritas for helping!
Prisma Accelerate, our global database cache has served over 1 billion queries since its General Availability launch.
We’d like to give a shoutout to our team and everyone who’s been with us on this journey. Stay tuned for some exciting products and features in the pipeline for 2024!
Are you building a cool tool, extension, generator, CLI tool or anything else, for Prisma ORM? Let us know.
We would like to learn about it and feature it on our Ecosystem page.
If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you. Check out our Careers page for open positions.
Today, we are issuing the 5.7.1
patch release.
This patch fixes multiple small problems in our relationJoins
preview feature. If you ran into problems when testing relationJoins
before, please give it another go with 5.7.1 and share your feedback or create a bug report if you encounter any issues.
relationJoins
: Int[] return as null
relationJoins
: fails when filtering includes by isNot: null
relationJoins
: "The table (not available) does not exist in the current database."
relationJoins
: PostgresError { code: "54023", message: "cannot pass more than 100 arguments to a function", severity: "ERROR", detail: None, column: None, hint: None }
relationJoins
: Inconsistent column data: Unexpected conversion failure from String to datetime. Reason: $trailing input
🌟 Help us spread the word about Prisma by starring the repo or posting on X (formerly Twitter) about the release.
✨ In this release, we improved the SQL queries Prisma Client generates for you with two new Preview features, the driver adapters, and support for the database drivers we currently support. 5.7.0 will be the last release of the year. Stay tuned for the next one in January! ✨
JOIN
s for relation queries for PostgreSQL and CockroachDBWe’re excited to announce Preview support for JOIN
s in Prisma Client when querying relations. Support for JOIN
s has been a long-standing feature request, and this release adds support for PostgreSQL and CockroachDB. The upcoming releases will expand support for other databases Prisma supports.
To get started using JOIN
s, enable the Preview feature in your Prisma schema:
// schema.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["relationJoins"]
}
Run prisma generate
to regenerate Prisma Client and enable the Preview feature.
Prisma Client will use a JOIN
in your query to fetch relation data for a majority of the cases.
Example queries
Prisma Client query
await prisma.user.findUnique({
where: {
id: 1
},
include: {
profile: true
}
})
SQL
SELECT
"t1"."id",
"t1"."name",
"User_profile"."__prisma_data__" AS "profile"
FROM
"public"."User" AS "t1"
LEFT JOIN LATERAL (
SELECT
COALESCE(JSON_AGG("__prisma_data__"), '[]') AS "__prisma_data__"
FROM
(
SELECT
"t4"."__prisma_data__"
FROM
(
SELECT
JSON_BUILD_OBJECT(
'id',
"t3"."id",
'bio',
"t3"."bio",
'userId',
"t3"."userId"
) AS "__prisma_data__"
FROM
(
SELECT
"t2".*
FROM
"public"."Profile" AS "t2"
WHERE
"t1"."id" = "t2"."userId"
) AS "t3"
) AS "t4"
) AS "t5"
) AS "User_profile" ON TRUE
WHERE "t1"."id" = $1
LIMIT $2
Prisma Client query
await prisma.user.findUnique({
where: {
id: 1
},
include: {
posts: true
}
})
SQL
SELECT
"t1"."id",
"t1"."name",
"User_posts"."__prisma_data__" AS "posts"
FROM
"public"."User" AS "t1"
LEFT JOIN LATERAL (
SELECT
COALESCE(JSON_AGG("__prisma_data__"), '[]') AS "__prisma_data__"
FROM
(
SELECT
"t4"."__prisma_data__"
FROM
(
SELECT
JSON_BUILD_OBJECT(
'id',
"t3"."id",
'title',
"t3"."title",
'content',
"t3"."content",
'published',
"t3"."published",
'authorId',
"t3"."authorId"
) AS "__prisma_data__"
FROM
(
SELECT
"t2".*
FROM
"public"."Post" AS "t2"
WHERE
"t1"."id" = "t2"."authorId"
/* root select */
) AS "t3"
/* inner select */
) AS "t4"
/* middle select */
) AS "t5"
/* outer select */
) AS "User_posts" ON TRUE
WHERE "t1"."id" = $1
LIMIT $2
Prisma Client query
await prisma.post.findUnique({
where: {
id: 1
},
include: {
tags: true
}
})
SQL
SELECT
"t1"."id",
"t1"."title",
"t1"."content",
"t1"."published",
"t1"."authorId",
"Post_tags_m2m"."__prisma_data__" AS "tags"
FROM
"public"."Post" AS "t1"
LEFT JOIN LATERAL (
SELECT
COALESCE(JSON_AGG("__prisma_data__"), '[]') AS "__prisma_data__"
FROM
(
SELECT
"Post_tags"."__prisma_data__"
FROM
"public"."_PostToTag" AS "t2"
LEFT JOIN LATERAL (
SELECT
JSON_BUILD_OBJECT('id', "t4"."id", 'name', "t4"."name") AS "__prisma_data__",
"t4"."id"
FROM
(
SELECT
"t3".*
FROM
"public"."Tag" AS "t3"
WHERE
"t2"."B" = "t3"."id"
/* root select */
) AS "t4"
) AS "Post_tags" ON TRUE
WHERE
"t2"."A" = "t1"."id"
) AS "Post_tags_m2m_1"
) AS "Post_tags_m2m" ON TRUE
WHERE "t1"."id" = $1
LIMIT $2
Share your feedback and create a bug report if you encounter any issues.
distinct
option now uses SQL queries (Preview)From this release, Prisma Client’s distinct
option now uses the native SQL DISTINCT ON
for unordered queries with PostgreSQL and CockroachDB. The upcoming releases will expand support for the other databases that Prisma supports.
Prisma Client already supports querying for distinct records. However, Prisma Client took care of the post-processing for distinct records in memory.
To get started, enable the Preview feature in your Prisma schema:
// schema.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["nativeDistinct"]
}
Regenerate your Prisma Client to get started using the Preview feature.
Given the following Prisma Client query:
await prisma.user.findMany({
distinct: ['role'],
select: {
role: true,
},
})
Before 5.7.0
Previously, Prisma Client handled the post-processing to select distinct records in-memory. Therefore, the following query was generated and executed against your database:
SELECT
"public"."User"."id",
"public"."User"."role"::text
FROM
"public"."User"
WHERE
1 = 1 OFFSET $1
After 5.7.0
SELECT DISTINCT ON ("public"."User"."role")
"public"."User"."id",
"public"."User"."role"::text
FROM
"public"."User"
WHERE
1 = 1 OFFSET $1
Share your feedback and create a bug report if you encounter any issues.
In this release, we improved Prisma support when deploying to Netlify on Node.js v20. Previously, the Prisma Client could not resolve the location of the Query Engine after deploying to Netlify when using Node.js v20. If you run into this issue, we recommend updating to Prisma v5.7.0.
We recommend giving this comment on GitHub a read if you are not yet able to upgrade Prisma, to learn how to get around the error.
InterpretationError("Unable to convert expression result into a set of selection results", None)
(starting with 5.2.0)
TRUNCATE
ing the table on CockroachDB: placeholder $1 already has type string, cannot assign Color
Prisma Client could not locate the Query Engine for runtime "rhel-openssl-3.0.x"
)
Huge thanks to @anuraaga, @onichandame, @LucianBuzzo, @RobertCraigie, @fqazi, @KhooHaoYit, @alencardc, @Oreilles, @christianledgard, @skyzh, @alula, @AikoRamalho, @petradonka for helping!
If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.
We're hiring for the following roles:
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
🚀 Prisma Accelerate, our connection pool and global edge cache, is now Generally Available! Sign up to give it a try. 🚀
In version 5.4.0, we released driverAdapters
into Preview. The driverAdapters
feature enables Prisma Client to access your database using JavaScript or Serverless database drivers.
In this release, we fixed many bugs for the existing driver adapters. We appreciate all the community feedback that has helped us improve this feature!
This release also introduces a small breaking change to the @prisma/adapter-planetscale
package to improve its stability and performance. The serverless driver adapter will now use a connection pool instead of a single connection from PlanetScale’s serverless driver.
In case you’re using the @prisma/adapter-planetscale
, update your Prisma Client instance with the following:
-import { connect } from '@planetscale/database'
+import { Client } from '@planetscale/database'
import { PrismaPlanetScale } from '@prisma/adapter-planetscale'
import { PrismaClient } from '@prisma/client'
import { fetch as undiciFetch } from 'undici';
-const connection = connect({ url: connectionString, fetch: undiciFetch })
+const client = new Client({ url: connectionString, fetch: undiciFetch })
-const adapter = new PrismaPlanetScale(connection)
+const adapter = new PrismaPlanetScale(client)
const prisma = new PrismaClient({ adapter })
If you run into the following error: [TypeError]: PrismaPlanetScale must be initialized with an instance of Client.
, you can use the following snippet when defining your Prisma Client instance:
import { createRequire } from "node:module";
import { PrismaPlanetScale } from "@prisma/adapter-planetscale";
import { fetch as undiciFetch } from 'undici';
const require = createRequire(import.meta.url);
const { Client } = require("@planetscale/database");
const client = new Client({ url: process.env.DATABASE_URL , fetch: undiciFetch })
const adapter = new PrismaPlanetScale(client);
We encourage you to try out the driver adapters and share your feedback to help us move it to General Availability in either of the following GitHub discussions:
Refer to our docs to learn more about driver adapters.
prisma debug
commandThis release introduces a new command: prisma debug
. The command provides debugging information such as environment variables that Prisma Client, Prisma Migrate, Prisma CLI, and Prisma Studio use. The command is also useful when creating a bug report as the information complements the output of the prisma -v
command.
You can learn more about the command in our docs.
We also released version 0.3.0 of the @prisma/extension-read-replicas
package that contains the following improvements:
A new $replica()
method that explicitly enables you to use a replica for your query.
For example, by default, the queryRaw
and executeRaw
methods are forwarded to the primary database, as they could try to write to the database. You can use the $replica()
method with either of the *Raw
methods to explicitly execute your query against a replica instead of your primary database.
Validation for when there’s an empty list of replicas.
Webpack bundling fixes
We want to thank you, our community members, for your contributions! 🙏
You can find additional information on the changes in the extension’s release. You can learn more about the extension in the announcement blog post.
npm has introduced provenance statements to improve supply-chain security and transparency of packages. This allows developers to verify where and how packages are built.
Starting with the 5.6.0 release, all npm packages for Prisma ORM will be published with provenance statements. If you maintain a Prisma Client extension or generator, we encourage you to enable provenance statements when publishing to npm.
db push
with invalid connection string: Connection string redacted, weird grammar
db pull --url=...
logs full connection string on P4001 The introspected database was empty
prisma_pool_connections_idle
reports misleading number
@prisma/adapter-planetscale
PrismaPlanetScale
adapter to the constructor
Error: sha256 checksum of https://binaries.prisma.sh/all_commits/475c616176945d72f4330c92801f0c5e6398dc0f/windows/query_en gine.dll.node.gz (zipped) should be 748d039badd0919d022fff7d554b66b6937b79035861a6ae9a80c5a95eee76f5 but is b867ad335ee6f58c6a38f665dd641c95e6adff3061f92b7613c62cae1c3362bb
Huge thanks to @onichandame, @LucianBuzzo, @RobertCraigie, @fqazi, @KhooHaoYit, @alencardc, @Oreilles, @christianledgard, @skyzh, @alula, @luxaritas, @Nasfame, @lukahartwig, @steebchen, @icanipa for helping!
We're excited to share that Prisma Accelerate is now Generally Available. Prisma Accelerate is a global database cache that's available in over 280 locations and provides scalable connection pooling for serverless and edge applications.
Learn more in the announcement blog post. Sign up and try out Prisma Accelerate here.
If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.
We're hiring for an Engineering Manager: Prisma Data Platform.
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
In version 5.4.0, we released driverAdapters
into Preview. The driverAdapter
feature enables Prisma Client to access your database using other JavaScript or Serverless database drivers such as Neon, PlanetScale, and Turso.
The driver adapters allow Prisma Client to connect to your database using protocols besides TCP, such as HTTP (PlanetScale and Turso) and WebSockets (Neon). You can learn more about the Preview feature from the announcement blog post.
In this release, we focused our efforts on fixing bugs and improving the stability of the Preview feature.
We encourage you to try it out and share your feedback to help us move it to General Availability in either of the following GitHub discussions:
prisma init
commandThis release introduces 3 new flags you can provide when initializing Prisma in your project using the prisma init
command:
--generator-provider
: Defines the default generator to use--preview-features
: Specifies the default Preview features to use in your project--output
: Specifies the default output location for the generated clientprisma.model.count
does not type distinct
correctly
….findMany()
invocation: The column j1.id
does not exist in the current database.
Huge thanks to @onichandame, @fqazi, @KhooHaoYit, @alencardc, @Oreilles, @christianledgard, @skyzh, @alula, @michaelpoellath, @lukahartwig, @steebchen, @icanipa, @jiashengguo, @stephenwade for helping!
If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.
We're currently hiring for the following roles: