Releases: prisma/prisma
5.13.0
Today, we are excited to share the 5.13.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release.
Highlights
omit
fields from Prisma Client queries (Preview)
We’re excited to announce Preview support for the omit
option within the Prisma Client query options. The highly-requested omit
feature now allows you to exclude fields that you don’t want to retrieve from the database on a per-query basis.
By default, when a query returns records, the result includes all scalar fields of the models defined in the Prisma schema. select
can be used to return specific fields, while omit
can now be used to exclude specific fields. omit
lives at the same API level and works on all of the same Prisma Client model queries as select
. Note, however, that omit
and select
are mutually exclusive. In other words, you can’t use both in the same query.
To get started using omit
, enable the omitApi
Preview feature in your Prisma schema:
// schema.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["omitApi"]
}
Be sure to re-generate Prisma Client afterwards:
npx prisma generate
Here is an example of using omit
:
// Includes all fields except password
await prisma.user.findMany({
omit: {
password: true
},
})
Here is an example of using omit
with include
:
// Includes all user fields except user's password and title of user's posts
await prisma.user.findMany({
omit: {
password: true
},
include: {
posts: {
omit: {
title: true
},
},
},
})
Expand to view the example Prisma schema
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
password String
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
author User @relation(fields: [authorId], references: [id])
authorId Int
}
Many users have requested a global implementation of omit
. This request will be accommodated in the future. In the meantime, you can follow the issue here.
📣 Share your feedback: omitApi
Preview feature
📚 Documentation: omit
- Prisma Client API Reference
Fixes and improvements
Prisma Migrate
Prisma Client
- MySQL
upsert()
:Internal error: Attempted to serialize empty result.
- Mysql
upsert()
fails with "Attempted to serialize empty result." - Interactive Transaction API timing out after upgrading from 4.7.0 and above
- MySQL and SQLite
upsert()
:Internal error: Attempted to serialize empty result.
- MySQL
upsert()
:Internal error: Attempted to serialize empty result.
- MongoDB
upsert()
:Internal error: Attempted to serialize empty result.
- MongoDB
upsert()
:Internal error: Attempted to serialize empty result
- Relation mode +
upsert()
:Internal error: Attempted to serialize empty result.
Internal error: Attempted to serialize empty result.
onupsert()
forupdate
case in different databases (when usingrelationMode=prisma
explicitly or implicitly [MongoDB])- Postgres
upsert(): Internal error: Attempted to serialize empty result
whenrelationMode = "prisma"
is used ✘ [ERROR] near "��": syntax error at offset 0
when runningwrangler d1 migrations apply
with Prisma generated migration (on Windows, using Powershell)
Credits
Huge thanks to @ospfranco, @pranayat, @yubrot, @skyzh, @anuraaga, @yehonatanz, @arthurfiorette, @elithrar, @tockn, @Kuhave, @obiwac for helping!
5.12.1
Today, we are issuing the 5.12.1
patch release to fix two small problems with our new Cloudflare D1 support.
Fixes in Prisma CLI
Windows-only fix for new D1 specific flags for migrate diff
and db pull
The flags --from-local-d1
and --to-local-d1
for migrate diff
and --local-d1
to db pull
we added in 5.12.0 were not working as expected when running on Windows only. This is now fixed.
📚 Documentation: Deploying a Cloudflare worker with D1 and Prisma ORM
New option for migrate diff
: -o
or --output
We added a new parameter --output
to migrate diff
that can be used to provide a filename into which the output of the command will be written. This is particularly useful for Windows users, using PowerShell, as using >
to write into a file creates a UTF-16 LE file that can not be read by wrangler d1 migrations apply
. Using this new option, this problem can be avoided:
npx prisma migrate diff --script --from-empty --to-schema-datamodel ./prisma/schema.prisma --output ./schema.sql
Related issues:
5.12.0
Today, we are excited to share the 5.12.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or posting on X about the release.
Highlights
Cloudflare D1 (Preview)
This release brings Preview support for Cloudflare D1 with Prisma ORM 🥳
D1 is Cloudflare’s SQLite database that can be used when deploying applications with Cloudflare.
When using Prisma ORM with D1, you can continue to: model your database with Prisma schema language, specify sqlite
as your database provider in your Prisma schema, and interact with your database using Prisma Client.
To use Prisma ORM and D1 on Cloudflare Workers or Cloudflare Pages, you need to set sqlite
as your database provider and use the @prisma/adapter-d1
database adapter via the driverAdapters
Preview feature, released back in version 5.4.0.
Here is an example of sending a query to your D1 database using Prisma Client in your Worker:
// src/index.ts file
import { PrismaClient } from '@prisma/client'
import { PrismaD1 } from '@prisma/adapter-d1'
// Add the D1Database to the Env interface
export interface Env {
// This must match the binding name defined in your wrangler.toml configuration
DB: D1Database
}
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Promise<Response> {
// Make sure the database name matches the binding name in wrangler.toml and Env interface
const adapter = new PrismaD1(env.DB)
// Instantiate PrismaClient using the PrismaD1 driver adapter
const prisma = new PrismaClient({ adapter })
const users = await prisma.user.findMany()
const result = JSON.stringify(users)
return new Response(result)
},
}
📚 Documentation: D1 Documentation
✍️ Blog post: Build Applications at the Edge with Prisma ORM & Cloudflare D1 (Preview)
📣 Share your feedback: D1 Driver Adapter
🚀 Example project: Deploy a Cloudflare Worker with D1
createMany()
for SQLite
Bringing support for createMany()
in SQLite has been a long-awaited feature ⭐
createMany()
is a method on Prisma Client, released back in version 2.16.0, that lets you insert multiple records into your database at once. This can be really useful when seeding your database or inserting bulk data.
Here is an example of using createMany()
to create new users:
const users = await prisma.user.createMany({
data: [
{ name: 'Sonali', email: 'sonali@prisma.io' },
{ name: 'Alex', email: 'alex@prisma.io' },
{ name: 'Yewande', email: 'yewande@prisma.io' },
{ name: 'Angelina', email: 'angelina@prisma.io' },
],
})
Before this release, if you wanted to perform bulk inserts with SQLite, you would have most likely used $queryRawUnsafe
to execute raw SQL queries. But now you don’t have to go through all that trouble 🙂
With SQLite, createMany()
works exactly the same way from an API standpoint as it does with other databases except it does not support the skipDuplicates
option. At the behavior level, SQLite will split createMany()
entries into multiple INSERT
queries when the model in your schema contains fields with attributes like @default(dbgenerated())
or @default(autoincrement())
and when the fields are not consistently provided with values across the entries.
📚Documentation: createMany()
- Prisma Client API Reference
Fixes and Improvements
Prisma Client
- N+1 Issue with
Decimal
data type and combining queries (batching) - Batched
findUnique()
error out when the field is ofBoolean
type relationJoins
MySQL converts nested Decimal to float- Unexpected query leading to querying full table when using batched
findUnique()
node-postgres
(pg) errors with misleadingP2010 PrismaClientKnownRequestError
when using@prisma/adapter-pg
with SSL (?sslmode=require
)- D1 DateTime type does not work
Credits
Huge thanks to @yubrot, @skyzh, @anuraaga, @onichandame, @LucianBuzzo, @RobertCraigie, @arthurfiorette, @elithrar for helping!
5.11.0
Today, we are excited to share the 5.11.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo ☝️ or posting on X about the release.
Highlights
Edge function support for Cloudflare and Vercel (Preview)
We’re thrilled to announce that support for edge function deployments with Prisma ORM is now in Preview 🥳 As of this release, you can deploy your apps that are using Prisma ORM to:
- Vercel Edge Functions and Vercel Edge Middleware
- Cloudflare Workers and Cloudflare Pages
In order to deploy to an edge function, you’ll need to use a compatible database driver (along with its Prisma driver adapter):
- Neon Serverless Driver (for PostgreSQL databases hosted via Neon)
- PlanetScale Serverless Driver (for MySQL databases hosted via PlanetScale)
pg
driver (for traditional PostgreSQL databases)@libsql/client
driver (for SQLite databases hosted via Turso)
Check out our documentation to learn how you can deploy an edge function using any combination of supported edge function provider and database.
You can also read more about it in the announcement blog post!
Performance improvements in nested create
operations
With Prisma ORM, you can create multiple new records in nested queries, for example:
const user = await prisma.user.update({
where: { id: 9 },
data: {
name: 'Elliott',
posts: {
create: {
data: [{ title: 'My first post' }, { title: 'My second post' }],
},
},
},
})
In previous versions, Prisma ORM would translate this into multiple SQL INSERT
queries, each requiring its own roundtrip to the database. As of this release, these nested create
queries are optimized and the INSERT
queries are sent to the database in bulk in a single roundtrip. These optimizations apply to one-to-many as well as many-to-many relations.
With this change, using the nested create
option to create multiple records effectively becomes equivalent to using a nested createMany
operation (except that createMany
only works with one-to-many relations, whereas create
works both with one-to-many and many-to-many).
Note: Only the deepest nested operation is optimized. If a user specified
create (1) -> create (2) -> create (3)
in their query, onlycreate (3)
will be optimized.
Fixes and improvements
Prisma Client
- Prisma errors when not using the major.minor.patch versioning system
- mongodb where condition resulted in combined $ne but should not be $eq
- Node hangs when
console.log(new PrismaClient())
- Add wolfy linux to supported OS
- Support Linux Gentoo
- Know engines to download for Void Linux
- Engine does not support Linux distro "openeuler"
- Prisma Doesn't Recognize Crystal Linux distro
- Regression: Mapped
enum
throws error (collationcp1250_czech_cs
or similar) NOT
condition leaks out of its desired bounds- The column does not exist in the current database.
- Logging
PrismaClient
object is slow - Running
prisma generate
on Litespeed Web Server cPanel with ssh - Prisma doesn't know which engines to download for the Linux distro "guttaos"
- Error in driver-adapter-utils with
tsc
:Cannot find namespace 'debug'.
- VS Code debugger freeze from time to time, when Prisma Client is involved
push
method still unimplemented for scalar lists in CockroachDBInvalid character
error persists on 5.10.1 in Prisma Studio- Add "Peppermint OS" to list of supported distros
runtimeDescription
is not defined error
Prisma Migrate
- Prisma with UOS or Deepin
- Warning: Linux distro "slackware"
- Error when run
npx prisma db pull
with DeepinOS 20.9GNU/LInux - Add solus to list of known supported distros
- NixOS not recognised as a Linux distribution
- Prisma Warning on Ubuntu 20.04
- Let Prisma detect Artix Linux distro
- couldn't identify clear-linux-os
- Prisma doesn't know which engines to download with
Linux Mint
Error: Invalid character
whenschema.prisma
includes Chinese/Non-ASCII characters in a comment
Prisma Engines
- [DA] Planetscale engine tests: aggregations
- [DA] Planetscale engine tests: json filtering
- [DA] Planetscale engine tests: order and pagination
- [DA] Planetscale engine tests: oids
- [DA] Planetscale engine tests: nested_createmany_fail_dups
- [DA] Planetscale engine tests: create_many_error_dups
- [DA] Planetscale engine tests: upsert_fails_if_filter_dont_match
5.10.2
Today, we are issuing the 5.10.2
patch release.
Fix in Prisma CLI
5.10.1
Today, we are issuing the 5.10.1
patch release.
Fix in Prisma Client / Prisma CLI
5.10.0
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
- called
Option::unwrap()
on aNone
value when using the relationJoins preview feature with driver adapters - [5.9.0 Bug]
Prisma.TransactionClient
appears to be missing types - Error after Upgrading from 5.8.1 to 5.9.0
- [5.9.0]
@prisma/client
in Next.js middleware - [v5.9.0]
$extends
always returnany
- Prisma edge runtime error
- [5.9.0] All queries result in any type
Error: Prisma Client is unable to run in an edge runtime. As an alternative, try Accelerate: https://pris.ly/d/accelerate.
- [5.9.0] Error: Prisma Client is unable to run in an edge runtime. As an alternative, try Accelerate: https://pris.ly/d/accelerate.
- v5.9.0 / Don't generate type. And the error from the previous version is still there
- [5.9.0] Getting strange types after generating
- relationJoins: "The column
t3.bookGenreTitle
does not exist in the current database" - Missing export @prisma/client/generator-build
relationJoins
preview feature: calledOption::unwrap()
on aNone
value
5.9.1
Today, we are issuing the 5.9.1
patch release.
Fixes in Prisma Client
In 5.9.0
we have changed our conditional exports in @prisma/client
. This resulted in broken types for TypesScript users using certain combinations of module
/moduleResolution
settings. Additionally, it also caused a regression for Next.js users which have encountered invalid error messages from our side.
You can now try out 5.9.1
and let us know if you find a bug at https://pris.ly/prisma-prisma-bug-report
- [5.9.0] Getting strange types after generating #22903
- v5.9.0 / Don't generate type. And the error from the previous version is still there #22896
- [5.9.0] Error: Prisma Client is unable to run in an edge runtime. As an alternative, try Accelerate: https://pris.ly/d/accelerate. #22893
Error: Prisma Client is unable to run in an edge runtime. As an alternative, try Accelerate: https://pris.ly/d/accelerate.
#22889- [5.9.0] All queries result in any type #22888
- Prisma edge runtime error #22886
- please how i cant fix this message issues #22885
- [v5.9.0] $extends always return any #22884
- [5.9.0] @prisma/client in Next.js middleware #22877
- Error after Upgrading from 5.8.1 to 5.9.0 #22875
- [5.9.0 Bug] Prisma.TransactionClient appears to be missing types #22870
Note: many issues are duplicates.
5.9.0
Today, we are excited to share the 5.9.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo ☝️ or posting on X about the release.
This release brings a number of small improvements as we continue our work on larger features which you will hear more about in the coming weeks:
- Improve the performance of relation queries by introducing JOINs (see last release).
- Support deployment to edge functions (already available in Early Access, you can apply for trying it out by taking our survey).
Highlights
Optimized result sets for more efficient queries
We continue our efforts of the performance of Prisma Client queries. In 5.1.0
, we introduced the RETURNING
keyword for several queries on PostrgeSQL and CockroachDB. We now expanded the use of RETURNING
to SQLite and a broader range of queries for existing databases (e.g. delete
on PostgreSQL and MongoDB). You can learn more about the optimizations of the result sets in these PRs:
SQL Server: Return proper error for unreachable database
When trying migrate/introspect a SQL server instance that’s unreachable, Prisma ORM now returns the correct P1001
error instead of failing without an error. Learn more in this PR: SQL Server: Migrate/Introspection engine doesn't return P1001 error for unreachable url.
Fixes and improvements
Prisma Client
- Skip unnecessary
select
queries on create/update/delete - .prisma/client: Name can't start with a dot
- Nested json is transformed to string when used “$type” key in object
- Parallel execution with Promise.all causes P2024 error in version 5.8.0 due to connection limit
Prisma Migrate
- SQL Server: Migrate/Introspection engine doesn't return P1001 error for unreachable url
- Prisma errors fetching table 'CHECK_CONSTRAINTS' (which only exists in MySQL 8.0.16+) in MySQL 8.0.14
ERROR: column "..." being dropped, try again later
when applying migrations with CRDB 23.1
Language tools (e.g. VS Code)
Company news
Test edge functions support in Early Access
Today, the only way how to use Prisma ORM in edge functions (e.g. Cloudflare Workers or Vercel Edge Functions) is by using Prisma Accelerate. However, we are actively working on making Prisma ORM compatible with edge functions natively as well. If you want to become an early tester, you can apply for the private Early Accessing program by taking this survey.
We Transitioned Prisma Accelerate to IPv6 Without Anyone Noticing
Last year, AWS announced the decision to begin charging for IPv4 addresses beginning in February 2024. This move had a major impact on Prisma Accelerate, prompting us to go all-in on IPv6. Learn more in this technical deep dive into how we approached our IPv6 migration, lessons learned, and the outcome for users of Prisma Accelerate.
Credits
Huge thanks to @laplab, @Druue, @anuraaga, @onichandame, @LucianBuzzo, @RobertCraigie, @almeidx, @victorgdb, @tinola, @sampolahtinen, @AikoRamalho, @petradonka for helping!
5.8.1
Today, we are issuing the 5.8.1
patch release.