Prisma: 5.10.0 Release

Release date:
February 20, 2024
Previous version:
5.9.1 (released February 1, 2024)
Magnitude:
4,197 Diff Delta
Contributors:
12 total committers
Data confidence:
Commits:

124 Commits in this Release

Ordered by the degree to which they evolved the repo in this version.

Authored February 14, 2024
Authored February 7, 2024
Authored January 31, 2024
Authored February 8, 2024
Authored February 6, 2024

Top Contributors in 5.10.0

millsp
Jolg42
Druue
SevInf
prisma-bot
jkomyno
tockn
renovate-bot
jasonkuhrt
Kuhave

Directory Browser for 5.10.0

All files are compared to previous version, 5.9.1. Click here to browse diffs between other versions.

Loading File Browser...

Release Notes Published

Today, we are excited to share the 5.10.0 stable release 🎉

🌟 Help us spread the word about Prisma by starring the repo ☝️ or posting on X about the release.

Highlights

Optimized relation queries in MySQL (Preview)

This release brings the optimizations for relation queries from the previous releases to MySQL as well! This means that by enabling the relationJoins Preview feature with the mysql database provider, you now also get access to the relationLoadStrategy option in relation queries that let you choose whether you want to merged relations on the application- or database-level.

If you enable the relationJoins Preview feature, you can choose between the join and query options:

  • join (default): Sends a single query to the database and joins the data on the database-level.
  • query: Sends multiple queries to the database and joins the data on the application-level.

To get started, enable the Preview feature in your Prisma schema:

// schema.prisma
generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["relationJoins"]
}

Be sure to re-generate Prisma Client afterwards:

npx prisma generate

And finally, specify the relation loading strategy for your relation query via the relationLoadStrategy option as follows:

await prisma.user.findMany({
  relationLoadStrategy: 'join', // or 'query' 
  include: {
    posts: true,
  },
})

Note that in the example above, the relationLoadStrategy could be omitted altogether because join is used as the default value.

A few notes about relationLoadStrategy support on MySQL:

  • relationLoadStrategy is supported for MySQL v8.0.14 and higher. MariaDB is not supported.
  • Prisma ORM uses correlated sub-queries for MySQL (as opposed to LATERAL JOINs which are used on PostgreSQL).

Configure transaction options in the PrismaClient constructor

This feature enables you to configure the following transaction options on a global level via the PrismaClient constructor:

  • isolationLevel: Sets the transaction isolation level. By default, this is set to the value currently configured in your database.
  • timeout: The maximum amount of time the interactive transaction can run before being canceled and rolled back. The default value is 5 seconds.
  • maxWait: The maximum amount of time Prisma Client will wait to acquire a transaction from the database. The default value is 2 seconds.

Here is an example of how you can set this value globally for all transactions:

const prisma = new PrismaClient({
  transactionOptions: {
    isolationLevel: 'ReadCommitted',
    timeout: 1_000, // 1 sec
    maxWait: 2_000  // 2 sec
  }
})

Thanks a lot to our fantastic community member @tockn, who took the initiative to implement this feature in Prisma ORM 🎉

Note that you can still override the global values by setting them on a particular transaction.

New P2037 code for “Too many database connections opened” errors

We introduced a new error code for “Too many database connections opened” errors: P2037. You can find all error codes in our documentation.

Access the Prisma Data Platform via Prisma CLI

Now available in Early Access, you can manage your workspace and configure Prisma Accelerate and Prisma Pulse directly from the terminal.

Visit our docs to learn more about the integration and try it out for yourself!

Fixes and improvements

Prisma Client