prisma/prisma (@prisma/client)
### [`v5.1.1`](https://togithub.com/prisma/prisma/releases/tag/5.1.1)
[Compare Source](https://togithub.com/prisma/prisma/compare/5.1.0...5.1.1)
Today, we are issuing the `5.1.1` patch release.
#### Fixes in Prisma Client
- [Browser bundle: Unhandled Runtime Error when upgrading to 5.1.0 from 5.0.0 ](https://togithub.com/prisma/prisma/issues/20480)
- [Prisma Client: `disconnect: true` does not appear to delete the foreign key in the returned data](https://togithub.com/prisma/prisma/issues/20491)
- [Prisma Client errors with "TypeError: Cannot create proxy with a non-object as target or handler" when using result client extension with no `needs` and `count` method](https://togithub.com/prisma/prisma/issues/20499)
### [`v5.1.0`](https://togithub.com/prisma/prisma/releases/tag/5.1.0)
[Compare Source](https://togithub.com/prisma/prisma/compare/5.0.0...5.1.0)
Today, we are excited to share the `5.1.0` stable release 🎉
🌟 **Help us spread the word about Prisma by starring the repo ☝️ or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20@prisma%20release%20v5.1.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/5.1.0) about the release.**
### Highlights
After two big releases where we released Client extensions for production usage ([`4.16.0`](https://togithub.com/prisma/prisma/releases/tag/4.16.0)) and made Prisma faster by default ([`5.0.0`](https://togithub.com/prisma/prisma/releases/tag/5.0.0)), we have focused on some smaller issues to make the experience with these new features even better.
#### Community contributions
Our community has been on the roll! We appreciate everyone who helps us by opening a GitHub issue or proposing a fix via Pull Requests. In this release, we're excited to highlight multiple community contributions:
- Fix IPv6 not working for relational databases: [https://github.com/prisma/prisma-engines/pull/4051](https://togithub.com/prisma/prisma-engines/pull/4051) by [@alula](https://togithub.com/alula)
- Middlewares: Add to `PrismaAction` type, missing `findUniqueOrThrow` and `findFirstOrThrow` [https://github.com/prisma/prisma/pull/17471](https://togithub.com/prisma/prisma/pull/17471) by [@mejiaej](https://togithub.com/mejiaej) and missing `groupBy` [https://github.com/prisma/prisma/pull/19985](https://togithub.com/prisma/prisma/pull/19985) by [@iurylippo](https://togithub.com/iurylippo)
- Better error message in currently non-supported runtimes like Browser or Vercel Edge Runtime [https://github.com/prisma/prisma/pull/20163](https://togithub.com/prisma/prisma/pull/20163) by [@andyjy](https://togithub.com/andyjy)
- Remove error messages for valid NixOS setups [https://github.com/prisma/prisma/pull/20138](https://togithub.com/prisma/prisma/pull/20138) by [@Gerschtli](https://togithub.com/Gerschtli)
#### Better performance: Fewer SQL queries on PostgreSQL & CockroachDB
In our continued and ongoing work to make Prisma faster, we identified some Prisma Client queries that led to multiple SQL statements being executed — although in specific databases, that was not necessary.
Hence we optimized our internal SQL generation for PostgreSQL and CockroachDB to generate more efficient SQL queries:
##### Simple `create` query
In a simple `create` query, `RETURNING` makes the second query and the transaction statements obsolete:
##### Prisma Client query
```ts
prisma.user.create({
data: { name: "Original name" }
})
```
##### Before v5.1.0
```sql
BEGIN
INSERT INTO "User" ("name") VALUES ($1) RETURNING "User"."id"
SELECT "User"."id", "User"."name" FROM "User" WHERE "User"."id" = $1;
COMMIT
```
##### 5.1.0 and later
```sql
-- Sends 1 statement (instead of 2) and omits the transaction
INSERT INTO "User" ("name") VALUES ($1) RETURNING "User"."id", "User"."name"
```
##### Simple `update` query
For a simple `update` query, `RETURNING` makes both additional queries and the transaction statements obsolete:
##### Prisma Client query
```ts
prisma.user.update({
where: { id: 1 },
data: { name: "updated" }
})
```
##### Before v5.1.0
```sql
BEGIN
SELECT id FROM "User" WHERE "User".id = 1;
UPDATE "User" SET name = 'updated' WHERE "User".id = 1;
SELECT id, name FROM "User" WHERE "User".id = 1;
COMMIT
```
##### 5.1.0 and later
```sql
-- Sends 1 statement (instead of 3) and omits the transaction
UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id, "User".name;
```
##### Simple `update` query, return with relation value
One `SELECT` query could easily be dropped in a simple `update` query that should return a relation value as well:
##### Prisma Client query
```ts
prisma.user.update({
where: { id: 1 },
data: { name: "updated" },
includes: { posts: true }
})
```
##### Before v5.1.0
```sql
BEGIN
SELECT id FROM "User" WHERE "User".id = 1;
UPDATE "User" SET name = 'updated' WHERE "User".id = 1;
SELECT id, name FROM "User" WHERE "User".id = 1;
SELECT id, title FROM "Post" WHERE "Post"."userId" = 1;
COMMIT
```
##### 5.1.0 and later
```sql
-- Sends 3 statements (instead of 4)
BEGIN
UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id;
SELECT id, name FROM "User" WHERE "User".id = 1;
SELECT id, title FROM "Post" WHERE "Post"."userId" = 1;
COMMIT
```
##### Empty `update` query
An empty `update` query can be optimized to skip the transaction and the second identical query by creating specific handling for this edge case in our code:
##### Prisma Client query
```ts
prisma.user.update({
where: { id: 1 },
data: {},
})
```
##### Before v5.1.0
```sql
BEGIN
SELECT id, name FROM "User" WHERE "User".id = 1;
SELECT id, name FROM "User" WHERE "User".id = 1;
COMMIT
```
##### 5.1.0 and later
```sql
-- Sends 1 statement (instead of 2) and omits the transaction
SELECT id, name FROM "User" WHERE "User".id = 1;
```
##### Simple + relation `update` query (but do not return relation value)
An update of both the model and its relation, we could drop 2 `SELECT` queries that we did before without ever using their return values:
##### Prisma Client query
```ts
prisma.user.update({
where: { id: 1 },
data: {
name: "updated",
posts: {
update: {
where: { id: 1 },
data: {
title: "updated"
}
}
}
}
})
```
##### Before v5.1.0
```sql
BEGIN
SELECT id, name FROM "User" WHERE "User".id = 1;
UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id;
SELECT "id", "postId" FROM "Post" WHERE "Post".id = 1;
UPDATE "Post" SET title = 'updated' WHERE "Post"."userId" = 1 AND "Post".id = 1;
SELECT id, name FROM "User" WHERE "User".id = 1;
COMMIT
```
##### 5.1.0 and later
```sql
-- Sends 3 statements (instead of 5)
BEGIN
UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id, "User".name;
SELECT "id", "postId" FROM "Post" WHERE "Post".id = 1;
UPDATE "Post" SET title = 'updated' WHERE "Post"."userId" = 1 AND "Post".id = 1;
COMMIT
```
In the next releases, we will continue optimizing Prisma Client queries to only run the minimal amount of SQL queries necessary.
If you notice any Prisma Client queries that are affected right now, please check the issues under [our `performance/queries` label](https://togithub.com/prisma/prisma/labels/topic%3A%20performance%2Fqueries). If you didn’t find one for what you’re seeing, please [create a new issue](https://togithub.com/prisma/prisma/issues). This will be super useful for us to understand all (edge) cases. Thank you!
#### Prisma Studio now supports `directUrl`
Our CLI command `prisma studio` that opens Prisma Studio now also can use the [`directUrl`](https://www.prisma.io/docs/guides/performance-and-optimization/connection-management#external-connection-poolers) property of the `datasource` block so you can make it talk to a different database than defined in `url`. This makes it easier to use Studio alongside the Prisma Data Proxy and [Accelerate](https://www.prisma.io/accelerate).
#### Prisma Client: No more type clashes
We fixed (almost) all cases where using a specific term as a model name in your Prisma Schema would lead to a *type clash* due to Prisma’s generated typings. As a result of a type clash, it was not possible to use that model in your code (this was e.g. the case if you named a model `Model` or `ModelUpdate`).
We also deprecated the `Args` type as part of that fix. Going forward, `DefaultArgs` should be used instead.
#### Fixes and improvements
##### Prisma Client
- [Reduce the number of generated SQL statements for Updates/Inserts](https://togithub.com/prisma/prisma/issues/5043)
- [\[v2.17.0\] Missing client TS types Aggregate\*Args](https://togithub.com/prisma/prisma/issues/5749)
- [Reduce transactions for writes](https://togithub.com/prisma/prisma/issues/5919)
- [Incorrect Include typings when having models called `X` and `XUpdate`](https://togithub.com/prisma/prisma/issues/7518)
- [Model named "Check" is incorrectly typed](https://togithub.com/prisma/prisma/issues/7655)
- [Models named Query cause an internal GraphQL Parse Error](https://togithub.com/prisma/prisma/issues/8153)
- [Naming an entity "Query" leads to an error](https://togithub.com/prisma/prisma/issues/9307)
- [Type name clash when `Model` and `ModelUpdate` is defined in the schema ](https://togithub.com/prisma/prisma/issues/9568)
- [Duplicate identifier 'CheckSelect'](https://togithub.com/prisma/prisma/issues/9669)
- [`@prisma/internals` (previously @prisma/sdk) uses deprecated dependencies `uuid@3.4.0` via `temp-write 4.0.0`](https://togithub.com/prisma/prisma/issues/11960)
- [naming a model `Datasource` breaks generated return types](https://togithub.com/prisma/prisma/issues/12332)
- [Certain `model` names cause clashes in generated types](https://togithub.com/prisma/prisma/issues/12469)
- [Type error on query with select field (although query runs successfully)](https://togithub.com/prisma/prisma/issues/15615)
- [`$extends` TS error: "Inferred type of this node exceeds the maximum length the compiler will serialize" with `"declaration": true` in `tsconfig`](https://togithub.com/prisma/prisma/issues/16536)
- [Update operation includes multiple where statements for the same fields](https://togithub.com/prisma/prisma/issues/16864)
- [Type conflict when naming a table {something} and a second table {something}Result ](https://togithub.com/prisma/prisma/issues/16940)
- [`Type '"findUniqueOrThrow"' is not assignable to type 'PrismaAction'`](https://togithub.com/prisma/prisma/issues/17470)
- [Naming a model `Promise` breaks types for `PrismaPromise`](https://togithub.com/prisma/prisma/issues/17542)
- [Prisma can't connect with an IPv6 host (on e.g. Fly.io)](https://togithub.com/prisma/prisma/issues/18079)
- [`include` not working on models ending with `...Update` with unique compound index](https://togithub.com/prisma/prisma/issues/18902)
- [Prisma Client: fixing type name clashes from generated client](https://togithub.com/prisma/prisma/issues/19811)
- [Prisma Client: wrong type when using spread operator to set default values on query args](https://togithub.com/prisma/prisma/issues/19962)
- [The generated updateArgs have no update attribute](https://togithub.com/prisma/prisma/issues/19967)
- [4.16.1 breaks type check](https://togithub.com/prisma/prisma/issues/19999)
- [`LogLevel` enum conflicts with built-in Prisma type](https://togithub.com/prisma/prisma/issues/20031)
- [Using `Prisma.XyzFindManyArgs` breaks `findMany` typing in v4.16.0+](https://togithub.com/prisma/prisma/issues/20093)
- [`this.$on("beforeExit")` doesn't work anymore on 5.0.0](https://togithub.com/prisma/prisma/issues/20171)
- [Wrong nullable types with fluent API in Prisma 5.0](https://togithub.com/prisma/prisma/issues/20183)
- [`Error: Unknown value type` on nested create](https://togithub.com/prisma/prisma/issues/20192)
- [Prisma 5.0 Migration `findUnique` on `@unique` columns that are enums](https://togithub.com/prisma/prisma/issues/20227)
- [`UpsertArgs` select field does not match type for `db..upsert(item)`](https://togithub.com/prisma/prisma/issues/20243)
- [TypeScript Error TS2322 when assigning JavaScript Date object to Prisma DateTime field](https://togithub.com/prisma/prisma/issues/20253)
- [npm install of Prisma CLI fails on preinstall with no logs when Node.js version is lower than minimum](https://togithub.com/prisma/prisma/issues/20260)
- [Types wrongly accept non-array parameter `by` in `groupBy` in 5.0.0](https://togithub.com/prisma/prisma/issues/20261)
- [CLI errors with `TypeError [ERR_INVALID_URL]: Invalid URL` when `HTTP(S)_PROXY` en var has is set to a URL without a protocol](https://togithub.com/prisma/prisma/issues/20302)
- [`tsc --watch` fails with `JavaScript heap out of memory` error](https://togithub.com/prisma/prisma/issues/20308)
- [Hovering over types (intellisense) shows confusing `GetResult`](https://togithub.com/prisma/prisma/issues/20320)
- [Internal query batching fails when the table name is 'stores'](https://togithub.com/prisma/prisma/issues/20324)
- [Client extensions result extensions should be applied after query extensions](https://togithub.com/prisma/prisma/issues/20437)
##### Prisma Studio
- [Use `directUrl` in `prisma studio`](https://togithub.com/prisma/prisma/issues/17358)
##### Language tools (e.g. VS Code)
- [The extension for VS Code ignores the modern telemetry flag](https://togithub.com/prisma/language-tools/issues/1463)
- [Prisma VS Code extension with mongodb provider crashes when a relation field/type is not defined ](https://togithub.com/prisma/language-tools/issues/1466)
- [Editing schema.prisma results in wasm panics](https://togithub.com/prisma/language-tools/issues/1473)
#### Credits
Huge thanks to [@skyzh](https://togithub.com/skyzh), [@alula](https://togithub.com/alula), [@michaelpoellath](https://togithub.com/michaelpoellath), [@RobertCraigie](https://togithub.com/RobertCraigie), [@Gerschtli](https://togithub.com/Gerschtli), [@andyjy](https://togithub.com/andyjy), [@mejiaej](https://togithub.com/mejiaej), [@iurylippo](https://togithub.com/iurylippo), [@mrazauskas](https://togithub.com/mrazauskas) for helping!
### [`v5.0.0`](https://togithub.com/prisma/prisma/releases/tag/5.0.0)
[Compare Source](https://togithub.com/prisma/prisma/compare/4.16.2...5.0.0)
We’re excited to share the `5.0.0` release today 🎉
Prisma `5.0.0` contains a lot of changes that improve Prisma’s performance, especially in serverless environments. If you want to learn more about the performance improvements, we wrote a blog post that sums up all the changes we made: [Prisma 5: Faster by Default](https://www.prisma.io/blog/prisma-5-f66prwkjx72s).
As this is a major release, it includes a few breaking changes that might affect a small group of our users. Before upgrading, we recommend that you check out our [upgrade guide](https://www.prisma.io/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-5) to understand the impact on your application.
🌟 **Help us spread the word about Prisma by starring the repo or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20@prisma%20release%20v5.0.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/5.0.0) about the release.** 🌟
### Highlights
Here’s a summary of the changes:
- Preview features moved to General Availability
- `jsonProtocol`: improves communication between Prisma Client and the query engine, makes Prisma faster by default.
- `fieldReference`: adds support for comparing columns of the same table.
- `extendedWhereUnique`: adds support for non-unique columns inside `where` clauses for queries that operate on unique records.
- General improvements and breaking changes
- Dependency version changes
- Minimum Node.js version change to 16.13.0
- Minimum TypeScript version change to 4.7
- Minimum PostgreSQL version change to 9.6
- Prisma Client embedded SQLite version upgrade to 3.41.2
- Main Changes
- Removal of `rejectOnNotFound` property
- Removal of some array shortcuts
- `cockroachdb` provider is now required when connecting to a CockroachDB database
- Removed `runtime/index.js` from the generated Prisma Client
- Other Changes
- Removal of deprecated flags in the Prisma CLI
- Removal of the `beforeExit` hook from the library engine
- Removal of deprecated `prisma2` executable
- Removal of deprecated `experimentalFeatures` generator property in the Prisma schema
- Renamed `migration-engine` to `schema-engine`
#### A JSON-based protocol that improves Prisma’s performance
We’re thrilled to announce that the `jsonProtocol` Preview feature is now Generally Available. You can now remove the Preview feature flag from your schema after upgrading. We made the JSON-based wire protocol the **default protocol** used for communication between Prisma Client and the query engine.
We introduced this feature in version [4.11.0](https://togithub.com/prisma/prisma/releases/tag/4.11.0) to improve Prisma’s performance. Previously, Prisma used a GraphQL-like protocol to communicate between Prisma Client and the query engine. Applications with larger schemas had higher CPU and memory consumption compared to smaller schemas which created a performance bottleneck.
The JSON-based wire protocol improves efficiency when Prisma Client is communicating with the query engine.
##### Removal of array shortcuts
We took the opportunity to remove some array shortcuts to make our typings more consistent and logical. These shortcuts were a way to add a single element as a value to an array-based operator instead of wrapping a single element in an array. We will now require array values for the following:
- `OR` operator shortcuts
- `in` and `notIn` operator shortcuts
- PostgreSQL JSON `path` field shortcut
- Scalar list shortcuts
- MongoDB Composite types list shortcuts
Here’s an example query using the `OR` operator shortcut for a single element;
```diff
await prisma.user.findMany({
where: {
- OR: { email: 'alice@prisma.io' }
+ OR: [{ email: 'alice@prisma.io' }]
}
})
```
We recommend taking a look at the [upgrade guide](https://www.prisma.io/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-5#removal-of-array-shortcuts#removal-of-array-shortcuts) to learn how you can update your queries to work in Prisma 5.
#### Support for comparing multiple columns
We’re excited to announce that the `fieldReference` Preview feature is now stable and Generally Available. This means you can use this feature without the Preview feature flag in your Prisma schema.
We first introduced this feature in [4.5.0](https://togithub.com/prisma/prisma/releases/tag/4.5.0) to add the ability to compare columns on the same table. For example, the following query returns records where the `quantity` value is less than the `warnQuantity` of a product:
```tsx
await prisma.product.findMany({
where: {
quantity: { lte: prisma.product.fields.warnQuantity }
},
})
```
To learn more about this feature, refer to our [documentation](https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#compare-columns-in-the-same-table).
#### Support for filtering non-unique columns in queries for a unique record
We’re excited to announce the `extendedWhereUnique` Preview feature is now Generally Available. This means you can use the feature without the Preview feature flag in the Prisma schema.
We first introduced this feature in version 4.5.0 to add support for non-unique columns inside `where` clauses for queries that operate on unique records, such as `findUnique`, `update`, and `delete`, which was previously not possible.
For example, consider the following model:
```prisma
model Article {
id Int @id @default(autoincrement())
content String
version Int
}
```
You can filter on non-unique columns such as the `version` field as follows:
```tsx
await prisma.article.findUnique({
where: {
id: 5,
version: 1 // filter on the `version` field was not available before Prisma 4.5.0
},
});
```
To learn more about this feature, refer to our [documentation](https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#filter-on-non-unique-fields-with-userwhereuniqueinput).
#### Minimum Node.js version change to 16.13.0
The minimum version of Node.js Prisma supports is `16.13.0`. If you're using an earlier version of Node.js, you will need to upgrade your Node.js version.
Refer to our [system requirements](https://www.prisma.io/docs/reference/system-requirements) for the minimum versions Prisma requires.
#### Minimum TypeScript version change to 4.7
The minimum version of TypeScript Prisma supports is 4.7. If your project is using an earlier version of TypeScript, you will need to upgrade your TypeScript version.
Refer to our [system requirements](https://www.prisma.io/docs/reference/system-requirements) for the minimum versions Prisma requires.
#### Minimum PostgreSQL version change to 9.6
The minimum version of PostgreSQL Prisma supports is version 9.6. If you’re either using 9.4 or 9.5, you will need to update your PostgreSQL version to at least 9.6.
Refer to our [system requirements](https://www.prisma.io/docs/reference/database-reference/supported-databases) for the minimum database versions Prisma requires.
#### Prisma Client embedded SQLite version upgrade
We upgraded the embedded version of SQLite from 3.35.4 to 3.41.2. We do not anticipate any breaking changes or changes needed in projects using SQLite. However, if you’re using SQLite, especially with raw queries that might go beyond Prisma's functionality, make sure to check [the SQLite changelog](https://www.sqlite.org/changes.html).
#### Removal of `rejectOnNotFound` property
In version 5.0.0, we removed the `rejectOnNotFound` parameter from Prisma Client that was deprecated in version 4.0.0. We removed this feature to provide better type-safety using the `findUniqueOrThrow` and `findFirstOrThrow` methods as well have a consistent API.
If you are using the `rejectOnNotFound` parameter we recommend either:
- Replacing your queries with the `findFirstOrThrow` or `findUniqueOrThrow` methods if enabled at a *query-level*
- Using a [Prisma Client extension](https://www.prisma.io/docs/concepts/components/prisma-client/client-extensions) to overload the `findFirstOrThrow` and `findUniqueOrThrow` model methods with your custom error handling if enabled at the *client-level*
We recommend taking a look at the [upgrade guide](https://www.prisma.io/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-5#removal-of-array-shortcuts#removal-of-rejectonnotfound-parameter) for more information on how to adapt your application if you’re using `rejectOnNotFound`.
#### `cockroachdb` provider is now required when connecting to a CockroachDB database
Prior to adding explicit support for CockroachDB with the `cockroachdb` provider in [3.9.0](https://togithub.com/prisma/prisma/releases/tag/3.9.0), it was possible to use the PostgreSQL provider when working with CockroachDB databases.
We’re now making it mandatory to use the CockroachDB connector when working with CockroachDB databases. CockroachDB and PostgreSQL have a few differences such as the available native types which impact the generated migrations.
If you were using the PostgreSQL connector to work with CockroachDB, take a look at the [upgrade guide](https://www.prisma.io/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-5#cockroachdb-provider-is-now-required-when-connecting-to-a-cockroachdb-database) to learn how you can update your connector.
#### Removal of the generated `runtime/index.js` file from Prisma Client
With Prisma 5, we removed the `runtime/index.js` file from Prisma Client. If you were using APIs from `runtime/index.js`, such as `Decimal` , `PrismaClientKnownRequestError`, `NotFoundError`, `PrismaClientUnknownRequestError`, we recommend updating your imports:
```diff
- import { Decimal } from '@prisma/client/runtime'
+ import { Prisma } from '@prisma/client'
// Usage update of Prisma Client's utilities
- Decimal
+ Prisma.Decimal
```
We recommend taking a look at the [upgrade guide](https://www.prisma.io/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-5#removal-of-array-shortcuts#removal-of-runtimeindexjs-from-generated-client) to learn how you can migrate to Prisma 5
#### Removal of the `beforeExit` hook from the `library` query engine
We removed the `beforeExit` hook from the default `library` Query Engine. We recommend using the built-in Node.js exit events.
```diff
-prisma.$on('beforeExit', () => { /* your code */ })
// Replacements
process.on('beforeExit', () => { /* your code */ })
process.on('exit', exitHandler)
process.on('SIGINT', exitHandler)
process.on('SIGTERM', exitHandler)
process.on('SIGUSR2', exitHandler)
```
We recommend taking a look at the [upgrade guide](https://www.prisma.io/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-5#removal-of-the-beforeexit-hook-from-the-library-engine) to learn how you can migrate to Prisma 5.
#### Removal of deprecated `prisma2` executable
When we released Prisma 2, the `prisma2` executable was used to differentiate it from Prisma 1. In a later release, the `prisma2` CLI took over the `prisma` executable name.
The `prisma2` executable has been deprecated for a while and will now be removed. If you’re using `prisma2` in your scripts, replace it with `prisma`.
#### Removal of deprecated flags in the Prisma CLI
We removed the following deprecated flags in the Prisma CLI:
- **`--preview-feature`**: used in the `prisma db execute`, `prisma db seed`, and `prisma migrate diff` commands
- **`--experimental`** and **`--early-access-feature`**: used in the `prisma migrate` commands such as `prisma migrate dev`
- **`--force`**: for `prisma db push`. The `--force` flag was replaced by `--accept-data-loss` in version 2.17.0
- **`--experimental-reintrospection`** and **`--clean`**: for `prisma db pull`
In the event you’re using one of these flags, we recommend removing the flags.
#### Removal of deprecated `experimentalFeatures` generator property
In this release, we removed the `experimentalFeatures` property that used to be in the generator property in the Prisma schema but has been renamed to `previewFeatures` for a long time now. If you’re still using this property, you can either manually rename it to `previewFeatures` or use the VS Code action to rename it if you’re using the latest version of the Prisma VS Code extension.
#### Renamed `migration-engine` to `schema-engine`
In this release, we renamed the `migration-engine`, responsible for running introspection and migration commands, to `schema-engine` . For the majority of our users, no changes will be required. However, if you explicitly include or exclude the engine files you will need to update your code references. Refer to the [upgrade guide](https://www.prisma.io/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-5#migration-engine-renamed-to-schema-engine) for more information.
#### Fixes and improvements
##### Prisma Client
- [Getting a string '(array)' in the generator config instead of the expected value when array is used](https://togithub.com/prisma/prisma/issues/9511)
- [Misleading error message from `create` call](https://togithub.com/prisma/prisma/issues/11425)
- [Client extensions incorrect typings when defined both specific model and all models methods](https://togithub.com/prisma/prisma/issues/17458)
- [UncheckedUpdateManyInput types lead to conflicting names](https://togithub.com/prisma/prisma/issues/18534)
- [`RelationFilterInput` does not take nullability into account](https://togithub.com/prisma/prisma/issues/18585)
- [Full text search query with `OR` broke after opting in to `jsonProtocol` feature.](https://togithub.com/prisma/prisma/issues/18885)
- [Prisma Client: remove list shorthands (for `jsonProtocol`)](https://togithub.com/prisma/prisma/issues/19303)
- [Remove outdated preview feature aliases (transactionApi, aggregateApi)](https://togithub.com/prisma/prisma/issues/19305)
- [Prisma Client generator: remove creation of a package.json](https://togithub.com/prisma/prisma/issues/19306)
- [Prisma Client: make `jsonProtocol` GA ](https://togithub.com/prisma/prisma/issues/19310)
- [Only upload engines files to `binaries.prisma.sh/all_commits/`](https://togithub.com/prisma/prisma/issues/19311)
- [Prisma Client: remove "beforeExit" hook from LibraryEngine/DataProxyEngine](https://togithub.com/prisma/prisma/issues/19312)
- [Prisma Client: remove `rejectOnNotFound`](https://togithub.com/prisma/prisma/issues/19315)
- [Prisma Client: remove `runtime/index.js` bundle from client](https://togithub.com/prisma/prisma/issues/19316)
- [Prisma CLI: remove non-existing `prisma dev` command](https://togithub.com/prisma/prisma/issues/19318)
- [Prisma Client: remove legacy `photonResolver` and `provider=photonjs` handling](https://togithub.com/prisma/prisma/issues/19319)
- [Prisma Client: make `fieldReference` GA](https://togithub.com/prisma/prisma/issues/19379)
- [Prisma Client: make `extendedWhereUnique` GA](https://togithub.com/prisma/prisma/issues/19380)
- [Remove backward compatibility for Prisma Client < 2.20 and Prisma CLI >= 2.20](https://togithub.com/prisma/prisma/issues/19417)
- [Prisma CLI: remove `prisma2` "executable"](https://togithub.com/prisma/prisma/issues/19438)
- [Query in findMany in prisma extends returns a wrong type](https://togithub.com/prisma/prisma/issues/19854)
- [Can't specify $queryRawUnsafe return type after extending prisma client](https://togithub.com/prisma/prisma/issues/19862)
- [FindMany returns wrong type after extending prisma client](https://togithub.com/prisma/prisma/issues/19864)
- [4.16.x cannot wrap `$extend` in factory function when `compilerOptions.composite` is `true`](https://togithub.com/prisma/prisma/issues/19866)
- [4.16: (MongoDB) Generated types for list composites are incorrect](https://togithub.com/prisma/prisma/issues/19880)
- [Prisma Client Extensions: $allModels: { $allOperations } sets `query` type to `never`](https://togithub.com/prisma/prisma/issues/19888)
- [Prisma Schema Type inside a Type not generating a right Payload](https://togithub.com/prisma/prisma/issues/19890)
- [Field references are not available on extended clients](https://togithub.com/prisma/prisma/issues/19892)
- [Prisma Client fluent API does not work with extends anymore on 4.16.1](https://togithub.com/prisma/prisma/issues/19921)
- [Prisma not generating correct payload for types in models for MongoDB for 4.16.1 ](https://togithub.com/prisma/prisma/issues/19933)
- [Prisma requires to install bun when generating client library ](https://togithub.com/prisma/prisma/issues/19945)
- [Getting wrong types with prisma client extensions](https://togithub.com/prisma/prisma/issues/19958)
- [Prisma Client: updating to 4.16.0 or 4.16.1 breaks Cloudflare worker, it errors with `The package "path" wasn't found on the file system but is built into node`](https://togithub.com/prisma/prisma/issues/19972)
- [Result types are incorrectly inferred when `undefined` explicitly passed to `select`/`include`](https://togithub.com/prisma/prisma/issues/19997)
- [Migrating to release: 4.16.2 throws typescript error: "TS1005: '?' expected".](https://togithub.com/prisma/prisma/issues/20024)
##### Prisma Migrate
- [Make connecting to a cockroachdb database with `provider = "postgresql"` an error](https://togithub.com/prisma/prisma/issues/13222)
- [Remove the deprecated `experimentalFeatures` generator property](https://togithub.com/prisma/prisma/issues/16294)
- [Remove support for PostgreSQL 9.4 and 9.5](https://togithub.com/prisma/prisma/issues/19300)
- [Upgrade embedded SQLite version](https://togithub.com/prisma/prisma/issues/19301)
- [Drop support for Node.js v14](https://togithub.com/prisma/prisma/issues/19304)
- [`db pull`: Remove the version checker from introspection](https://togithub.com/prisma/prisma/issues/19314)
- [Prisma CLI: remove undocumented `doctor` command](https://togithub.com/prisma/prisma/issues/19317)
- [Rename migration-engine to schema-engine](https://togithub.com/prisma/prisma/issues/19321)
- [Prisma CLI: remove deprecated flags, arguments and "old migrate" logic](https://togithub.com/prisma/prisma/issues/19448)
- [Remove obsolete `experimentalFeatures` generator property](https://togithub.com/prisma/prisma/issues/19540)
- [Remove usage / mention of `experimentalFeatures`](https://togithub.com/prisma/prisma/issues/19541)
##### Language tools (e.g. VS Code)
- [Mark `experimentalFeatures` as obsolete](https://togithub.com/prisma/language-tools/issues/1435)
#### Credits
Huge thanks to [@michaelpoellath](https://togithub.com/michaelpoellath), [@RobertCraigie](https://togithub.com/RobertCraigie), [@Coder246](https://togithub.com/Coder246), [@RDIL](https://togithub.com/RDIL), [@oohwooh](https://togithub.com/oohwooh), [@rqres](https://togithub.com/rqres), [@zhiyan114](https://togithub.com/zhiyan114), [@spudly](https://togithub.com/spudly), [@hayes](https://togithub.com/hayes), [@boennemann](https://togithub.com/boennemann), [@DongGunYoon](https://togithub.com/DongGunYoon) for helping!
#### 📺 Join us for another "What's new in Prisma" live stream
Learn about the latest release and other news from the Prisma community by joining us for another ["What's new in Prisma"](https://youtube.com/playlist?list=PLn2e1F9Rfr6l1B9RP0A9NdX7i7QIWfBa7) live stream.
The stream takes place [on YouTube](https://youtu.be/6rlKp_eBdZA) on **Thursday, July 13** at **5 pm Berlin | 8 am San Francisco**.
Configuration
📅 Schedule: Branch creation - "every 1st day of the month at 12am" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
[ ] If you want to rebase/retry this PR, check this box
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
^4.14.1
->^5.0.0
^4.14.1
->^5.0.0
Release Notes
prisma/prisma (@prisma/client)
### [`v5.1.1`](https://togithub.com/prisma/prisma/releases/tag/5.1.1) [Compare Source](https://togithub.com/prisma/prisma/compare/5.1.0...5.1.1) Today, we are issuing the `5.1.1` patch release. #### Fixes in Prisma Client - [Browser bundle: Unhandled Runtime Error when upgrading to 5.1.0 from 5.0.0 ](https://togithub.com/prisma/prisma/issues/20480) - [Prisma Client: `disconnect: true` does not appear to delete the foreign key in the returned data](https://togithub.com/prisma/prisma/issues/20491) - [Prisma Client errors with "TypeError: Cannot create proxy with a non-object as target or handler" when using result client extension with no `needs` and `count` method](https://togithub.com/prisma/prisma/issues/20499) ### [`v5.1.0`](https://togithub.com/prisma/prisma/releases/tag/5.1.0) [Compare Source](https://togithub.com/prisma/prisma/compare/5.0.0...5.1.0) Today, we are excited to share the `5.1.0` stable release 🎉 🌟 **Help us spread the word about Prisma by starring the repo ☝️ or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20@prisma%20release%20v5.1.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/5.1.0) about the release.** ### Highlights After two big releases where we released Client extensions for production usage ([`4.16.0`](https://togithub.com/prisma/prisma/releases/tag/4.16.0)) and made Prisma faster by default ([`5.0.0`](https://togithub.com/prisma/prisma/releases/tag/5.0.0)), we have focused on some smaller issues to make the experience with these new features even better. #### Community contributions Our community has been on the roll! We appreciate everyone who helps us by opening a GitHub issue or proposing a fix via Pull Requests. In this release, we're excited to highlight multiple community contributions: - Fix IPv6 not working for relational databases: [https://github.com/prisma/prisma-engines/pull/4051](https://togithub.com/prisma/prisma-engines/pull/4051) by [@alula](https://togithub.com/alula) - Middlewares: Add to `PrismaAction` type, missing `findUniqueOrThrow` and `findFirstOrThrow` [https://github.com/prisma/prisma/pull/17471](https://togithub.com/prisma/prisma/pull/17471) by [@mejiaej](https://togithub.com/mejiaej) and missing `groupBy` [https://github.com/prisma/prisma/pull/19985](https://togithub.com/prisma/prisma/pull/19985) by [@iurylippo](https://togithub.com/iurylippo) - Better error message in currently non-supported runtimes like Browser or Vercel Edge Runtime [https://github.com/prisma/prisma/pull/20163](https://togithub.com/prisma/prisma/pull/20163) by [@andyjy](https://togithub.com/andyjy) - Remove error messages for valid NixOS setups [https://github.com/prisma/prisma/pull/20138](https://togithub.com/prisma/prisma/pull/20138) by [@Gerschtli](https://togithub.com/Gerschtli) #### Better performance: Fewer SQL queries on PostgreSQL & CockroachDB In our continued and ongoing work to make Prisma faster, we identified some Prisma Client queries that led to multiple SQL statements being executed — although in specific databases, that was not necessary. Hence we optimized our internal SQL generation for PostgreSQL and CockroachDB to generate more efficient SQL queries: ##### Simple `create` query In a simple `create` query, `RETURNING` makes the second query and the transaction statements obsolete: ##### Prisma Client query ```ts prisma.user.create({ data: { name: "Original name" } }) ``` ##### Before v5.1.0 ```sql BEGIN INSERT INTO "User" ("name") VALUES ($1) RETURNING "User"."id" SELECT "User"."id", "User"."name" FROM "User" WHERE "User"."id" = $1; COMMIT ``` ##### 5.1.0 and later ```sql -- Sends 1 statement (instead of 2) and omits the transaction INSERT INTO "User" ("name") VALUES ($1) RETURNING "User"."id", "User"."name" ``` ##### Simple `update` query For a simple `update` query, `RETURNING` makes both additional queries and the transaction statements obsolete: ##### Prisma Client query ```ts prisma.user.update({ where: { id: 1 }, data: { name: "updated" } }) ``` ##### Before v5.1.0 ```sql BEGIN SELECT id FROM "User" WHERE "User".id = 1; UPDATE "User" SET name = 'updated' WHERE "User".id = 1; SELECT id, name FROM "User" WHERE "User".id = 1; COMMIT ``` ##### 5.1.0 and later ```sql -- Sends 1 statement (instead of 3) and omits the transaction UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id, "User".name; ``` ##### Simple `update` query, return with relation value One `SELECT` query could easily be dropped in a simple `update` query that should return a relation value as well: ##### Prisma Client query ```ts prisma.user.update({ where: { id: 1 }, data: { name: "updated" }, includes: { posts: true } }) ``` ##### Before v5.1.0 ```sql BEGIN SELECT id FROM "User" WHERE "User".id = 1; UPDATE "User" SET name = 'updated' WHERE "User".id = 1; SELECT id, name FROM "User" WHERE "User".id = 1; SELECT id, title FROM "Post" WHERE "Post"."userId" = 1; COMMIT ``` ##### 5.1.0 and later ```sql -- Sends 3 statements (instead of 4) BEGIN UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id; SELECT id, name FROM "User" WHERE "User".id = 1; SELECT id, title FROM "Post" WHERE "Post"."userId" = 1; COMMIT ``` ##### Empty `update` query An empty `update` query can be optimized to skip the transaction and the second identical query by creating specific handling for this edge case in our code: ##### Prisma Client query ```ts prisma.user.update({ where: { id: 1 }, data: {}, }) ``` ##### Before v5.1.0 ```sql BEGIN SELECT id, name FROM "User" WHERE "User".id = 1; SELECT id, name FROM "User" WHERE "User".id = 1; COMMIT ``` ##### 5.1.0 and later ```sql -- Sends 1 statement (instead of 2) and omits the transaction SELECT id, name FROM "User" WHERE "User".id = 1; ``` ##### Simple + relation `update` query (but do not return relation value) An update of both the model and its relation, we could drop 2 `SELECT` queries that we did before without ever using their return values: ##### Prisma Client query ```ts prisma.user.update({ where: { id: 1 }, data: { name: "updated", posts: { update: { where: { id: 1 }, data: { title: "updated" } } } } }) ``` ##### Before v5.1.0 ```sql BEGIN SELECT id, name FROM "User" WHERE "User".id = 1; UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id; SELECT "id", "postId" FROM "Post" WHERE "Post".id = 1; UPDATE "Post" SET title = 'updated' WHERE "Post"."userId" = 1 AND "Post".id = 1; SELECT id, name FROM "User" WHERE "User".id = 1; COMMIT ``` ##### 5.1.0 and later ```sql -- Sends 3 statements (instead of 5) BEGIN UPDATE "User" SET name = 'updated' WHERE "User".id = 1 RETURNING "User".id, "User".name; SELECT "id", "postId" FROM "Post" WHERE "Post".id = 1; UPDATE "Post" SET title = 'updated' WHERE "Post"."userId" = 1 AND "Post".id = 1; COMMIT ``` In the next releases, we will continue optimizing Prisma Client queries to only run the minimal amount of SQL queries necessary. If you notice any Prisma Client queries that are affected right now, please check the issues under [our `performance/queries` label](https://togithub.com/prisma/prisma/labels/topic%3A%20performance%2Fqueries). If you didn’t find one for what you’re seeing, please [create a new issue](https://togithub.com/prisma/prisma/issues). This will be super useful for us to understand all (edge) cases. Thank you! #### Prisma Studio now supports `directUrl` Our CLI command `prisma studio` that opens Prisma Studio now also can use the [`directUrl`](https://www.prisma.io/docs/guides/performance-and-optimization/connection-management#external-connection-poolers) property of the `datasource` block so you can make it talk to a different database than defined in `url`. This makes it easier to use Studio alongside the Prisma Data Proxy and [Accelerate](https://www.prisma.io/accelerate). #### Prisma Client: No more type clashes We fixed (almost) all cases where using a specific term as a model name in your Prisma Schema would lead to a *type clash* due to Prisma’s generated typings. As a result of a type clash, it was not possible to use that model in your code (this was e.g. the case if you named a model `Model` or `ModelUpdate`). We also deprecated the `Configuration
📅 Schedule: Branch creation - "every 1st day of the month at 12am" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR has been generated by Mend Renovate. View repository job log here.