fix(deps): update prisma monorepo to v4 (major)
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| @prisma/client (source) | 2.29.1 -> 4.4.0 |
||||
| prisma (source) | 2.29.1 -> 4.4.0 |
Release Notes
prisma/prisma
v4.4.0
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Major improvements
General improvements
In the last sprint, we focused our efforts on squashing as many bugs as we could. You can find the full list of improvements and bug fixes in the Fixes and improvements section below.
Some of the improvements we made include but are not limited to:
- Improved optimistic concurrency control (GitHub issue)
- Improved decimal precision
- Improved handling of big amounts of prepared statement placeholders:
Databases impose limits when they hit a specific number, and when a query (either generated by Prisma Client or provided by the user directly as a raw query) hits it some users ran into a misleading
Can't reach database servererror message (GitHub issue). The error message will now be more useful (P2035error code), and Prisma Client should not cause these errors anymore.
If you notice any regression, please make sure to create a GitHub issue. We touched a lot of code in this sprint, and even though we are confident in our tests, something might have slipped through the cracks. We'd like to fix the regressions as soon as possible.
isolationLevel for sequential transaction operations
In version 4.2.0, we added support for setting transaction isolation levels for interactive transactions (Preview). You can now define isolation levels for sequential transaction operations: prisma.$transaction([]).
Isolation levels describe different types of trade-offs between isolation and performance that databases can make when processing transactions. Isolation levels determine what types of data leaking can occur between transactions or what data anomalies can occur.
To set the transaction isolation level, use the isolationLevel option in the second parameter of the API. For example:
await prisma.$transaction(
[
// sequential operations
prisma.user.create({ data: {/** args */ } }),
prisma.post.create({ data: {/** args */ } })
],
{
isolationLevel: Prisma.TransactionIsolationLevel.Serializable
}
)
Prisma Client supports the following isolation levels if they're available in your database provider:
-
ReadCommitted -
ReadUncommitted -
RepeatableRead -
Serializable -
Snapshot
Learn more about it in our documentation.
New P2034 error code for transaction conflicts or deadlocks
When using certain isolation levels, it is expected that a transaction can fail due to a write conflict or a deadlock, throwing an error. One way to solve these cases is by retrying the transaction.
To make this easier, we're introducing a new PrismaClientKnownRequestError with the error code P2034: "Transaction failed due to a write conflict or a deadlock. Please retry your transaction". You can programmatically catch the error and retry the transaction. Here's an example showing how you can retry a transaction:
import { Prisma, PrismaClient } from '@​prisma/client'
const prisma = new PrismaClient()
async function main() {
const MAX_RETRIES = 5
let retries = 0;
let result;
while (retries < MAX_RETRIES) {
try {
result = await prisma.$transaction(
[
prisma.user.deleteMany({ where: { /** args */ } }),
prisma.post.createMany({ data: { /** args */ } })
],
{
isolationLevel: Prisma.TransactionIsolationLevel.Serializable
}
)
} catch (error) {
if (error.code === 'P2034') {
retries++
continue
}
throw error
}
}
}
Fixes and improvements
Prisma Client
-
Wrong types for fluent API when used along with
rejectOnNotFound - Precision issue when persisting Decimal.js objects
- Decimals lose precision (postgres)
- Weird behavior with "in:" clause on a findMany() with orderBy + take
- decimal lose precision digits to postgres
-
updateMany()causes lost-updates - Error: P1001: Can't reach database server when including large table
- Client shows contains filter on uuid data type despite not being a valid operation
- A model with relation to another model via non-null foreign key has nullable type
-
Validation error when inserting data of type
List<String | DateTime>into field of typeList<String> - Can't reach database server when doing a large findMany query
- Maximum call stack size exceeded when creating huge amount of related rows
-
Unique constraint failed during
$transaction([deleteMany, createMany]) - update will break atomicity
- Nested self referential orderby not working
- MySQL: Optimistic Concurrency Control doesn't work with UpdateMany
- Wrong type when retrieving multiple related records using fluent API
- Fluent API produces runtime error
- Column 'orderby_.....' in on clause is ambiguous
-
[PostgreSQL] Cannot create or update row with large Decimal value within
numericrange - Failed transactions trigger multipleResolves
-
The provided database string is invalid. Unable to parse URL. in database URL.on invalid (?) connection string - relation query fails when thousands of records
- Unable to query records with certain values
- orderBy using self-referential relation in a nested relation fails with "table name "TableName" specified more than once"
- @updatedAt does not work with @default
- Prisma silently misses nested elements on MariaDB when it triggers a huge IN clause
-
createdAt @​default(now())andupdatedAt @​updatedAtget different times on row creation - Interactive Transactions: fatal when throwing string instead of Error() since 3.10.0
-
Prisma MongoDB can not search for field with value
$foo - groupBy crashes when using enums
- MySQL DECIMAL(X, 5) returns incorrect precision.
- "Join" performance: (Not so) huge data set throws an error
-
Error: The provided database string is invalid. Unable to parse URL. in database URL. -
[mongoDB]
findRawdoes not work within aninteractiveTransaction - Filters max size is exceeded
- Prisma fails on Postgres query with findMany
- Update Restrict failed on prisma referentialIntegrity
- invalid character in $let in $lookup pipeline when using cursor and order by query
- Find many returns empty array or null
- Once instance has previously been poisoned
- Sanitize error snapshots in new test setup
- The findMany query fails silently when the array length passed through IN parameter exceeds 999
- mongodb cannot use $runCommand Raw in transaction
-
parent result: Some(ManyRecords { records: [Record { values: [Int(3), Int(1), DateTime(2022-08-08T12:27:55.310+00:00)], parent_id: None }], field_names: ["id", "userId", "createdAt"] }), relation: Relation { name: "post", model_a_name: "Comment", model_b_name: "Post", model_a: OnceCell((Weak)), model_b: OnceCell((Weak)), field_a: OnceCell((Weak)), field_b: OnceCell((Weak)), manifestation: Inline(InlineRelation { in_table_of_model_name: "Comment" }), internal_data_model: "#InternalDataModelWeakRef#" } - Given exponent overflowing the maximum accepted scale (255).: TryFromIntError(())
- Once instance has previously been poisoned
-
sqlite:cuid():called
Result::unwrap()on anErrvalue: FingerprintError("Could not retrieve hostname") -
Calling
findUniqueconcurrently with aDateTimecolumn causes it to returnnull - Maximum Call Stack Size Exceeded When Inserting large Array Object
- Prisma Client is incompatible with TypeScript 4.8
- This is a non-recoverable error: When creating Item with nested query
- Given exponent overflowing the maximum accepted scale (255).: TryFromIntError(())
- Prisma 4.3.0 takes 100x more time to generate types
-
Tracing:
prisma:enginespans always get sampled when using probability based samplers -
Datasource providers in
prisma initis listing wrong values - Disconnect with large queries
-
N/Aerror and message with large raw queries - only one @updatedAt is filled by the QE although multiple are accepted in the schema
- Insert fails if a table has a space in the name of the primary key
- Bug with throwing formatted errors
-
called
Option::unwrap()on aNonevalue -
Upsert error on MySQL:
Query ... is required to return data, but found no record(s) -
Add tests for mongodb's
findRaw,aggregateRawandrunCommandRawin sequential transactions
Prisma
- sqlite: show better error when a permission denied error occurs
-
Prisma v4 breaks support for empty
dbgenerated()- invalid migration created with no schema change -
Binary engine:
$disconnectnever returns if engine failed to start
Prisma Migrate
Prisma Studio
Credits
Huge thanks to @abenhamdine, @miguelgargallo, @Clansty, @panoplied, @MEnnabah, @drzamich, @AndrewSouthpaw, @kt3k for helping!
💼 We're hiring!
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 looking for a Developer Advocate (Frontend / Fullstack) and Back-end Engineer: Prisma Data Platform.
Feel free to read the job descriptions and apply using the links provided.
Prisma Data Platform
We're working on the Prisma Data Platform — a collaborative environment for connecting apps to databases. It includes the:
- Data Browser for navigating, editing, and querying data
- Data Proxy for your database's persistent, reliable, and scalable connection pooling.
- Query Console for experimenting with queries
Try it out and let us know what you think!
📺 Join us for another "What's new in Prisma" livestream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" livestream.
The stream takes place on YouTube on Thursday, September 29 at 5 pm Berlin | 8 am San Francisco.
v4.3.1
Today, we are issuing the 4.3.1 patch release.
Fixes in Prisma Client
Fixes in Prisma CLI
v4.3.0
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Major improvements
Field reference support on query filters (Preview)
We're excited to announce Preview support for field references. You can enable it with the fieldReference Preview feature flag.
Field references will allow you to compare columns against other columns. For example, given the following schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["fieldReference"]
}
model Invoice {
id Int @​id @​default(autoincrement)
paid Int
due Int
}
You can now compare one column with another after running prisma generate, for example:
// Filter all invoices that haven't been paid yet
await prisma.invoice.findMany({
where: {
paid: {
lt: prisma.invoice.fields.due // paid < due
}
}
})
Learn more about field references in our documentation. Try it out and let us know what you think in this GitHub issue.
Count by filtered relation (Preview)
In this release, we're adding support for the ability to count by a filtered relation. You can enable this feature by adding the filteredRelationCount Preview feature flag.
Given the following Prisma schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["filteredRelationCount"]
}
model User {
id Int @​id @​default(autoincrement())
email String @​unique
name String?
posts Post[]
}
model Post {
id Int @​id @​default(autoincrement())
title String
content String?
published Boolean @​default(false)
author User? @​relation(fields: [authorId], references: [id])
authorId Int?
}
You can now express the following query with the Preview feature after re-generating Prisma Client:
// Count all published user posts
await prisma.user.findMany({
select: {
_count: {
posts: { where: { published: true } },
},
},
})
Learn more in our documentation and let us know what you think in this issue
Multi-schema support (Preview)
In this release, we're adding very early Preview support of multi-schema support for PostgreSQL and SQL Server behind the multiSchema Preview feature flag. With it, you can write a Prisma schema that accesses models across multiple schemas.
Read further in this GitHub issue. Try it out and let us know what you think in this GitHub issue.
Prisma CLI exit code fixes
We've made several improvements to the Prisma CLI:
-
prisma migrate devpreviously returned a successful exit code (0) whenprisma db seedwas triggered but failed due to an error. We've fixed this andprisma migrate devwill now exit with an unsuccessful exit code (1) when seeding fails. -
prisma migrate statuspreviously returned a successful exit code (0) in unexpected cases. The command will now exit with an unsuccessful exit code (1) if:- An error occurs
- There's a failed or unapplied migration
- The migration history diverges from the local migration history (
/prisma/migrationsfolder) - Prisma Migrate does not manage the database' migration history
-
The previous behavior when canceling a prompt by pressing Ctrl + C was returning a successful exit code (0). It now returns a non-successful,
SIGINT, exit code (130). -
In the rare event of a Rust panic from the Prisma engine, the CLI now asks you to submit an error report and exit the process with a non-successful exit code (1). Prisma previously ended the process with a successful exit code (0).
Improved precision for the tracing Preview feature
Before this release, you may have occasionally seen some traces that took 0μs working with the tracing Preview feature. In this release, we've increased the precision to ensure you get accurate traces.
Let us know if you run into any issues in this GitHub issue.
prisma format now uses a Wasm module
Initially, the prisma format command relied on logic from the Prisma engines in form of a native binary. In an ongoing effort to make prisma more portable and easier to maintain, we decided to shift to a Wasm module.
prisma format now uses the same Wasm module as the one the Prisma language server uses, i.e. @prisma/prisma-fmt-wasm, which is now visible in prisma version command's output.
Let us know what you think. In case you run into any issues, let us know by creating a GitHub issue.
MongoDB query fixes
⚠️ This may affect your query results if you relied on this buggy behavior in your application.
While implementing field reference support, we noticed a few correctness bugs in our MongoDB connector that we fixed along the way:
-
mode: insensitivealphanumeric comparisons (e.g. “a” > “Z”) didn’t work (GitHub issue) -
mode: insensitivedidn’t exclude undefined (GitHub issue) -
isEmpty: falseon lists types (e.g. String[]) returned true when a list is empty (GitHub issue) -
hasEveryon list types wasn’t aligned with the SQL implementations (GitHub issue)
JSON filter query fixes
⚠️ This may affect your query results if you relied on this buggy behavior in your application. We also noticed a few correctness bugs in when filtering JSON values when used in combination with the
NOTcondition. For example:
await prisma.log.findMany({
where: {
NOT: {
meta: {
string_contains: "GET"
}
}
}
})
Prisma schema
model Log {
id Int @​id @​default(autoincrement())
level Level
message String
meta Json
}
enum Level {
Info
Warn
Error
}
If you used NOT with any of the following queries on a Json field, double-check your queries to ensure they're returning the correct data:
-
string_contains -
string_starts_with -
string_ends_with -
array_contains -
array_starts_with -
array_ends_with -
gt/gte/lt/lte
Prisma extension for VS Code improvements
The Prisma language server now provides Symbols in VS Code. This means you can now:
-
See the different blocks (
datasource,generator,model,enum, andtype) of your Prisma schema in the Outline view. This makes it easier to navigate to a block in 1 click A few things to note about the improvement are that:- CMD + hover on a field whose type is an enum will show the block in a popup
-
CMD + left click on a field whose type is a model or enum will take you to its definition.
-
Enable Editor sticky scroll from version
1.70of VS Code. This means you can have sticky blocks in your Prisma schema, improving your experience when working with big schema files
Make sure to update your VS Code application to 1.70, and the Prisma extension to 4.3.0.
We'd also like to give a big Thank you to @yume-chan for your contribution!
Prisma Studio improvements
We've made several improvements to the filter panel which includes:
-
Refined filter panel
- Reducing the contrast of the panel in dark mode
- Ability to toggle filters in the panel
-
Refined error handling for MongoDB m-n relations Prisma Studio prevents fatal errors when interacting with m-n relations by explicitly disabling creating, deleting, or editing records for m-n relations
-
Multi-row copying You can select multiple rows and copy them to your clipboard as JSON objects using CMD + C on MacOS or Ctrl + C on Windows/ Linux
Prisma Client Extensions: request for comments
For the last couple of months, we've been working on a specification for an upcoming feature — Prisma Client extensions. We're now ready to share our proposed design and we would appreciate your feedback.
Prisma Client Extensions aims to provide a type-safe way to extend your existing Prisma Client instance. With Prisma Client Extensions you can:
- Define computed fields
- Define methods for your models
- Extend your queries
- Exclude fields from a model ... and much more!
Here’s a glimpse at how that will look:
const prisma = new PrismaClient().$extend({
$result: {
User: {
fullName: (user) => {
return `${user.firstName} ${user.lastName}`
},
},
},
$model: {
User: {
signup: async ({ firstName, lastName, email, password }) => {
// validate and create the user here
return prisma.user.create({
data: { firstName, lastName, email, password }
})
},
},
},
})
const user = await prisma.user.signup({
firstName: "Alice",
lastName: "Lemon",
email: "[email protected]",
password: "pri$mar0ckz"
})
console.log(user.fullName) // Alice Lemon
For further details, refer to this GitHub issue. Have a read and let us know what you think!
Fixes and improvements
Prisma Client
- Allow WHERE conditions to compare columns in same table
- Dates serialized without quotation marks in query event parameters property
- Ability to filter count in "Count Relation Feature"
- Some traces show 0μs
- [MongoDB] Alphanumeric insensitive filters don't work
- [MongoDB] Insensitive filters don't exclude undefineds
- Schema size affects runtime speed
- Prisma Client always receive engine spans even when not tracing
- Environment variables not available when using Wrangler 2
Prisma
- Undo "skip flaky referentialActions sql server test"
-
Add
@prisma/prisma-fmt-wasmto CLI and output dependency version in-v, use instead of Formatter Engine binary -
Add jest snapshots for improved
db pushoutput in MongoDB - OpenSSL error message appearing while using query-engine has false positives
-
Calling
dmmfraises "Schema parsing - Error while interacting with query-engine-node-api library" misleading error message when there is a schema validation error. - Unique composite indexes do not clash with a matching name on schema validation (composite types)
-
CLI:
migrate statusshould return a non-successful exit code (1) when a failed migration is found or an error occurs -
CLI:
migrate devshould return a non-successful exit code (1) when there is an error during seeding
Prisma Migrate
Language tools (e.g. VS Code)
Credits
Huge thanks to @abenhamdine, @drzamich, @AndrewSouthpaw, @kt3k, @lodi-g, @Gnucki, @apriil15, @givensuman for helping!
Prisma Data Platform
We're working on the Prisma Data Platform — a collaborative environment for connecting apps to databases. It includes the:
- Data Browser for navigating, editing, and querying data
- Data Proxy for your database's persistent, reliable, and scalable connection pooling.
- Query Console for experimenting with queries
Try it out and let us know what you think!
💼 We're hiring!
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 looking for a Developer Advocate (Frontend / Fullstack) and Back-end Engineer: Prisma Data Platform.
Feel free to read the job descriptions and apply using the links provided.
📺 Join us for another "What's new in Prisma" livestream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" livestream.
The stream takes place on YouTube on Thursday, September 1 at 5 pm Berlin | 8 am San Francisco.
v4.2.1
Today, we are issuing the 4.2.1 patch release.
Fix in Prisma Client
v4.2.0
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Major improvements
Prisma Client tracing support (Preview)
We're excited to announce Preview support for tracing in Prisma Client! 🎉
Tracing allows you to track requests as they flow through your application. This is especially useful for debugging distributed systems where each request can span multiple services.
With tracing, you can now see how long Prisma takes and what queries are issued in each operation. You can visualize these traces as waterfall diagrams using tools such as Jaeger, Honeycomb, or DataDog.

Read more about tracing in our announcement post and learn more in our documentation on how to start working with tracing.
Try it out and let us know what you think.
Isolation levels for interactive transactions
We are improving the interactiveTransactions Preview feature with the support for defining the isolation level of an interactive transaction.
Isolation levels describe different types of trade-offs between isolation and performance that databases can make when processing transactions. Isolation levels determine what types of data leaking can occur between transactions or what data anomalies can occur.
To set the transaction isolation level, use the isolationLevel option in the second parameter of the API. For example:
await prisma.$transaction(
async (prisma) => {
// Your transaction...
},
{
isolationLevel: Prisma.TransactionIsolationLevel.Serializable,
maxWait: 5000,
timeout: 10000,
}
)
Prisma Client supports the following isolation levels if they're available in your database provider:
-
ReadCommitted -
ReadUncommitted -
RepeatableRead -
Serializable -
Snapshot
Learn more about in our documentation. Try it out, and let us know what you think in this GitHub issue.
Renaming of Prisma Client Metrics
In this release, we've renamed the metrics — counters, gauges, and histograms — returned from prisma.$metrics() to make it a little easier to understand at a glance.
| Previous | Updated |
|---|---|
query_total_operations |
prisma_client_queries_total |
query_total_queries |
prisma_datasource_queries_total |
query_active_transactions |
prisma_client_queries_active |
query_total_elapsed_time_ms |
prisma_client_queries_duration_histogram_ms |
pool_wait_duration_ms |
prisma_client_queries_wait_histogram_ms |
pool_active_connections |
prisma_pool_connections_open |
pool_idle_connections |
prisma_pool_connections_idle |
pool_wait_count |
prisma_client_queries_wait |
Give Prisma Client metrics a shot and let us know what you think in this GitHub issue
To learn more, check out our documentation.
Syntax highlighting for raw queries in Prisma Client
This release adds syntax highlighting support for raw SQL queries when using $queryRaw`` and $executeRaw`` . This is made possible using Prisma's VS Code extension.
Note: Syntax highlighting currently doesn't work with when using parentheses, (), $queryRaw(), $executeRaw(), $queryRawUnsafe(), and $executeRawUnsafe().
If you are interested in having this supported, let us know in this GitHub issue.
Experimental Cloudflare Module Worker Support
We fixed a bug in this release that prevented the Prisma Edge Client from working with Cloudflare Module Workers.
We now provide experimental support with a workaround for environment variables.
Try it out and let us know how what you think! In case you run into any errors, feel free to create a bug report.
Upgrade to Prisma 4
In case you missed it, we held a livestream a few weeks ago and walked through issues you may run into while upgrading to Prisma 4 and how to fix them!
Request for feedback
Our Product teams are currently running two surveys to help close the feature gaps and improve Prisma.
If you have a use-case for geographical data (GIS) or full-text search/ indexes (FTS), we would appreciate your feedback on your needs:
- Prisma GIS User Research Survey
- Prisma Full-Text Search User Research Survey
Many thanks! 🙌🏽
Fixes and improvements
Prisma Client
-
Allow
dataproxyto have datasource overrides - Warning during build: equals-negative-zero
- getGraphQLType throws error if object has no prototype
- Prisma Client: Log Data Proxy usage explicitly
- Cannot read property 'name' of undefined attempting to create row
- Edge client crashes when enabling debug logs in constructor
- TypeError: Cannot read properties of undefined (reading '_hasPreviewFlag')
- Large package.json log output in prisma:client:dataproxyEngine
Prisma
- Error: [libs/datamodel/connectors/dml/src/model.rs:338:29] Crash probably due to cyrillic table names
- Prisma doesn't validate composite attributes correctly
- Not letting me add Int as a type?
-
Introspection crash,
libs\datamodel\connectors\dml\src\model.rs:494:29(missing PK?) - SQL Server introspection panic
- Hi Prisma Team! Prisma Migrate just crashed.
- Primary key in model using a missing column
- Migrate just crashed sqlserver
-
Prisma is trying to find column that doesn't exists
prisma db pullonSQL Server -
Issue that occurred during
prisma db pull
Language tools (e.g. VS Code)
Prisma Studio
Credits
Huge thanks to @shian15810, @zifeo, @lodi-g, @Gnucki, @apriil15, @givensuman, @peter-gy for helping!
Prisma Data Platform
We're working on the Prisma Data Platform — a collaborative environment for connecting apps to databases. It includes the:
- Data Browser for navigating, editing, and querying data
- Data Proxy for persistent, reliable, and scalable connection pooling for your database.
- Query Console for experimenting with queries
Try it out and let us know what you think!
💼 We're hiring!
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 looking for a Developer Advocate (Frontend / Fullstack) and Back-end Engineer: Prisma Data Platform.
Feel free to read the job descriptions and apply using the links provided.
📺 Join us for another "What's new in Prisma" livestream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" livestream.
The stream takes place on YouTube on Thursday, August 11 at 5 pm Berlin | 8 am San Francisco.
v4.1.1
Today, we are issuing the 4.1.1 patch release.
Fix in Prisma Studio
v4.1.0
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Upgrading to Prisma 4
In case you missed it, we held a livestream last week and walked through issues you may run into while upgrading to Prisma 4 and how to fix them!
Major improvements
Ordering by nulls first and last support (Preview)
In this release, we're adding support for choosing how to sort null values in a query.
To get started, enable the orderByNulls Preview feature flag in your Prisma schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["orderByNulls"]
}
Next, run prisma generate to re-generate Prisma Client. You will now have new fields you can now use to order null values:
await prisma.post.findMany({
orderBy: {
updatedAt: {
sort: 'asc',
nulls: 'last'
},
},
})
Learn more in our documentation and don't hesitate to share your feedback in this issue.
Fixed memory leaks and CPU usage in Prisma Client
In this release, we've fixed the following issues experienced when setting up and tearing down Prisma Client while running tests:
- Prisma Client now correctly releases memory on Prisma Client instances that are no longer being used. Learn more in this GitHub issue
- Reduced CPU usage spikes when disconnecting Prisma Client instances while using Prisma Client. You can learn more in this GitHub issue
These fixes will allow you to run your tests a little faster!
Prisma Studio improvements
We're refining the experience when working with Prisma studio with the following changes:
- An always visible filter panel and functionality to clear all filters at once

- Improved relationship model view with more visible buttons

Let us know what you think, and in the event, you run into any issues, please create a GitHub issue
Fixes and improvements
Prisma
- Formatter doesn't allow comments on consecutive indices
- Internal: reformatter is not idempotent
-
prisma formatstrips comments on block level attributes - Reformatter crash in relation code
- Formatter crashes on arbitrary blocks
-
prisma --versioncrashes ifopensslisn't properly installed -
Rename 'getVersion' to 'getEngineVersion' in
@prisma/internals - BigInt with a default value cause duplicates in all migrations
- Formatter: thread 'main' panicked at 'not yet implemented'
-
Mongodb introspection fails with "called
Option::unwrap()on aNonevalue" -
PSL should support inline
//comments in the generator and datasource blocks - Unable to use native database types with Prisma and CockroachDB
Prisma Client
- High permanent CPU usage after calling $disconnect on a client that executed an interactive transaction before (v3.9.0+)
- Slow Tests
-
prisma generate: Non-functional debounce mechanism for watch mode - Unknown error in SQLite Connector migrating from Prisma 3.x to 4.0.0 on ARM/M1 machines
- macOS 12 sometimes kills Node.js process when loading the QE library
Prisma Migrate
- migrate-cli: do not override RUST_LOG from the environment
- Incorrect migration creates on sql server when index deleted
- Float cause duplicate alter table in all migrations
- db error: ERROR: cannot drop view geography_columns because extension postgis requires it
Language tools (e.g. VS Code)
-
Check when
@idis suggested and fix - Implement a code action adding a unique constraint to a relation
-
Potential pipeline 🔥 of language-tools with versioning change of
@prisma/engines - Cannot add comments to my @@unique constraints
@prisma/engines npm package
Credits
Huge thanks to @shian15810, @zifeo, @lodi-g, @Gnucki, @apriil15 for helping!
💼 We're hiring!
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 looking for a Technical Support Engineer and Back-end Engineer: Prisma Data Platform.
Feel free to read the job descriptions and apply using the links provided.
📺 Join us for another "What's new in Prisma" livestream
Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" livestream.
The stream takes place on YouTube on Thursday, July 19 at 5 pm Berlin | 8 am San Francisco.
v4.0.0
We're excited to share the 4.0.0 stable release today. 🎉
Prisma 4.0.0 features a variety of improvements across Prisma Migrate, Prisma schema, and Prisma Client. These changes will impact most Prisma users, particularly those who used some of our most popular Preview features around advanced index management, raw SQL queries, and filtering rows by properties of JSON.
As this is a major release, we included many breaking bug fixes and other enhancements, but we believe upgrading is worthwhile. You can learn about upgrading in our Prisma 4 Upgrade guide and the Prisma 4 Upgrade video.
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Major improvements
Here's a TL;DR:
-
Preview features moved to General Availability
-
extendedIndexes -
filterJson -
improvedQueryRaw
-
-
Improvements to the Prisma Schema
- Defaults values for scalar lists (arrays)
- Improved default support for embedded documents in MongoDB
- Explicit unique constraints for 1:1 relations
- Removed support for usage of
referenceson implicit m:n relations - Enforcing uniqueness of referenced fields in the
referencesargument in 1:1 and 1:m relations for MySQL - Removal of undocumented support for the
typealias - Removal of the
sqliteprotocol for SQLite URLs - Better grammar for string literals
-
New Prisma Client APIs
-
findUniqueOrThrow -
findFirstOrThrow
-
-
General improvements
- Deprecating
rejectOnNotFound - Fix rounding errors on big numbers in SQLite
-
DbNull,JsonNull, andAnyNullare now objects - Prisma Studio updates
- Dropped support for Node 12
- New default sizes for statement cache
- Renaming of
@prisma/sdknpm package to@prisma/internals - Removal of the internal
schemaproperty from the generated Prisma Client
- Deprecating
extendedIndexes is now Generally Available
Starting with this release, we're excited to announce that extendedIndexes is now Generally Available! 🚀
generator client {
provider = "prisma-client-js"
- previewFeatures = ["extendedIndexes"]
}
We introduced extendedIndexes in 3.5.0 and have constantly been shipping improvements in the subsequent releases to the configuration of indexes.
You can now configure indexes in your Prisma schema with the @@​index attribute to define the kind of index that should be created in your database. You can configure the following indexes in your Prisma Schema:
Sort, sort order, and length
The length argument is available on MySQL on the @id, @@​id, @unique, @@​unique, and @​@​index fields. It allows Prisma to support indexes and constraints on String with a TEXT native type and Bytes types.
The sort argument is available for all databases on the @unique, @@​unique, and @@​index fields. SQL Server also allows it on @id and @@​id.
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model Post {
title String @​db.VarChar(300)
abstract String @​db.VarChar(3000)
slug String @​unique(sort: Desc, length: 42) @​db.VarChar(3000)
author String
created_at DateTime
@​@​id([title(length: 100), abstract(length: 10)])
@​@​index([author, created_at(sort: Desc)])
}
Hash indexes for PostgreSQL
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model A {
id Int @​id
value Int
@​@​index([value], type: Hash)
}
GIN, GiST, SP-GiST and BRIN indexes for PostgreSQL
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Post {
id Int @​id
title String
content String?
tags Json?
@​@​index([tags], type: Gin)
}
SQL Server index clustering
datasource db {
provider = "sqlserver"
url = env("DATABASE_URL")
}
model Post {
id Int @​default(autoincrement()) @​id(clustered: false)
title String
content String?
}
Refer to our docs to learn how you can configure indexes in your Prisma schema and the supported indexes for the different databases.
⚠️ Breaking change: If you previously configured the index properties at the database level, refer to the upgrade guide for a detailed explanation and steps to follow.
filterJson is now Generally Available
This release moves the filterJson Preview feature into General Availability! 🪄
generator client {
provider = "prisma-client-js"
- previewFeatures = ["filterJson"]
}
JSON filtering allows you to filter rows by the data inside a Json type. For example:
const getUsers = await prisma.user.findMany({
where: {
petMeta: {
path: ['cats', 'fostering'],
array_contains: ['Fido'],
},
},
})
The filterJson Preview feature has been around since May 2021, and we're excited to mark it ready for production use! Learn more in our documentation.
improvedQueryRaw is now Generally Available
Prisma 4 now marks the improvedQueryRaw Preview feature as Generally Available! 🤩
generator client {
provider = "prisma-client-js"
- previewFeatures = ["improvedQueryRaw"]
}
This change introduces two major improvements (both breaking, refer to the upgrade guide for a smooth upgrade) when working with raw queries with Prisma:
1. Scalar values are de-serialized as their correct JavaScript types
Raw queries now deserialize scalar values to their corresponding JavaScript types.
Note: Types are inferred from the values and not from the Prisma Schema types.
Here's an example query and response:
const res = await prisma.$queryRaw`SELECT bigint, bytes, decimal, date FROM "Table";`
console.log(res)
// [{ bigint: BigInt("123"), bytes: Buffer.from([1, 2]), decimal: new Prisma.Decimal("12.34"), date: Date("<some_date>") }]
Below is a table that recaps the serialization type-mapping for raw results:
| Database Type | JavaScript Type |
|---|---|
| Text | String |
| Int32 | Number |
| Int64 | BigInt |
| Float | Number |
| Double | Number |
| Numeric | Decimal |
| Bytes | Buffer |
| Json | Object |
| DateTime | Date |
| Date | Date |
| Time | Date |
| Uuid | String |
| Xml | String |
2. PostgreSQL type-casts
Previously, PostgreSQL type-casts were broken. Here's an example query that used to fail:
await prisma.$queryRaw`SELECT ${1.5}::int as int`;
// Before: db error: ERROR: incorrect binary data format in bind parameter 1
// After: [{ int: 2 }]
You can now perform some type-casts in your queries as follows:
await prisma.$queryRaw`SELECT ${2020}::float4, (NOW() - ${"1 day"}::interval), ${"2022-01-01 00:00:00"}::timestamptz;`
A consequence of this fix is that some subtle implicit casts are now handled more strictly and would fail. Here's an example that used to work but won't work anymore:
await prisma.$queryRaw`SELECT LENGTH(${42}
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "before 8am on the first day of the month" (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.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.
---
This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/prisma/docs).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xMTcuMSIsInVwZGF0ZWRJblZlciI6IjMyLjIzNy4wIn0=-->
Deploy Preview for prisma2-docs ready!
| Name | Link |
|---|---|
| Latest commit | 21f6cfb23075ca7c4f7ce6f247c6f4acad114f96 |
| Latest deploy log | https://app.netlify.com/sites/prisma2-docs/deploys/62f3de137e0bf700094311f4 |
| Deploy Preview | https://deploy-preview-2676--prisma2-docs.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
This PR changes the following pages (Vercel Preview Deploy links):
Changed Vercel links
- This PR does not change any pages the GH Actions workflow could detect.
(Note that links will only be valid after Vercel preview deploy succeeded)
⚠ Artifact update problem
Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.
♻ Renovate will retry this branch, including artifacts, only when one of the following happens:
- any of the package files in this branch needs updating, or
- the branch becomes conflicted, or
- you click the rebase/retry checkbox if found above, or
- you rename this PR's title to start with "rebase!" to trigger it manually
The artifact failure details are included below:
File name: package-lock.json
npm notice
npm notice New major version of npm available! 8.19.3 -> 9.1.3
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.1.3>
npm notice Run `npm install -g [email protected]` to update!
npm notice
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @mdx-js/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"18.1.0" from the root project
npm ERR! peer react@">=16.8.0" from @emotion/[email protected]
npm ERR! node_modules/@emotion/react
npm ERR! @emotion/react@"^11.8.1" from [email protected]
npm ERR! node_modules/react-select
npm ERR! react-select@"5.4.0" from the root project
npm ERR! 25 more (@emotion/use-insertion-effect-with-fallbacks, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.13.1 || ^17.0.0" from @mdx-js/[email protected]
npm ERR! node_modules/@mdx-js/react
npm ERR! @mdx-js/react@"1.6.22" from the root project
npm ERR! @mdx-js/react@"1.6.22" from @mdx-js/[email protected]
npm ERR! node_modules/@mdx-js/loader
npm ERR! @mdx-js/loader@"1.6.22" from the root project
npm ERR! 1 more (gatsby-plugin-mdx)
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@"^16.13.1 || ^17.0.0" from @mdx-js/[email protected]
npm ERR! node_modules/@mdx-js/react
npm ERR! @mdx-js/react@"1.6.22" from the root project
npm ERR! @mdx-js/react@"1.6.22" from @mdx-js/[email protected]
npm ERR! node_modules/@mdx-js/loader
npm ERR! @mdx-js/loader@"1.6.22" from the root project
npm ERR! 1 more (gatsby-plugin-mdx)
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /tmp/renovate-cache/others/npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/renovate-cache/others/npm/_logs/2022-12-02T12_40_23_023Z-debug-0.log
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Updated |
|---|---|---|---|
| docs | ✅ Ready (Inspect) | Visit Preview | Jan 5, 2023 at 6:03PM (UTC) |