-
Notifications
You must be signed in to change notification settings - Fork 995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(deps): update prisma monorepo to v4 (major) #5849
Conversation
✅ Deploy Preview for redwoodjs-docs canceled.
|
This requires us to bump the version of Node.js we target to v14 (#4257). From the release notes:
|
a7f6a51
to
907d7c2
Compare
178fdc5
to
72f944d
Compare
a3e1321
to
4e28aaf
Compare
6e066bf
to
1fab34c
Compare
@jtoar I read the related thread(s) and I'm curious if you're planning to merge this soon, before I attempt to do it myself. Thx |
09342d2
to
ac92be4
Compare
ac92be4
to
ab2145c
Compare
Superseded by #5924. |
Renovate Ignore NotificationAs this PR has been closed unmerged, Renovate will ignore this upgrade and you will not receive PRs for any future 4.x releases. However, if you upgrade to 4.x manually then Renovate will reenable minor and patch updates automatically. If this PR was closed by mistake or you changed your mind, you can simply rename this PR and you will soon get a fresh replacement PR opened. |
@jonschlinkert we most likely won't upgrade Prisma till the end of the month or the start of the next, so if it's urgent for you and you're maintaining a fork feel free to go ahead. This PR's superseded by #5924. Joël from Prisma gave us some input on how to upgrade. Assuming checks pass, it should be a simple one. Note that we are talking about getting another major out soon since many of our dependencies 1) released a new major version and 2) are dropping Node.js 12 support. But that's in the not-too-distant future still. |
This PR contains the following updates:
3.15.2
->4.0.0
3.15.2
->4.0.0
Release Notes
prisma/prisma
v4.0.0
Compare Source
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.
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Major improvements
Here's a TL;DR:
extendedIndexes
filterJson
improvedQueryRaw
references
on implicit m:n relationsreferences
argument in 1:1 and 1:m relations for MySQLtype
aliassqlite
protocol for SQLite URLsfindUniqueOrThrow
findFirstOrThrow
rejectOnNotFound
DbNull
,JsonNull
, andAnyNull
are now objects@prisma/sdk
npm package to@prisma/internals
schema
property from the generated Prisma ClientextendedIndexes
is now Generally AvailableStarting 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
in3.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 onString
with aTEXT
native type andBytes
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
.Hash indexes for PostgreSQL
GIN
,GiST
,SP-GiST
andBRIN
indexes for PostgreSQLSQL Server index clustering
Refer to our docs to learn how you can configure indexes in your Prisma schema and the supported indexes for the different databases.
filterJson
is now Generally AvailableThis 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: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 AvailablePrisma 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.
Here's an example query and response:
Below is a table that recaps the serialization type-mapping for raw results:
2. PostgreSQL type-casts
Previously, PostgreSQL type-casts were broken. Here's an example query that used to fail:
You can now perform some type-casts in your queries as follows:
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:
The
LENGTH
PostgreSQL function only accepttext
as input. Prisma used to silently coerce42
totext
but won’t anymore. As suggested by the hint, cast42
totext
as follows:Refer to our docs to learn more on raw query type mappings in Prisma.
4.0.0
, refer to our upgrade guide: Raw query type mapping: scalar values are now deserialized as their correct JavaScript types and Raw query mapping: PostgreSQL type-casts.Defaults values for scalar lists (arrays)
Prisma 4 now introduces support for defining default values for scalar lists (arrays) in the Prisma schema.
You can define default scalar lists as follows:
To learn more about default values for scalar lists, refer to our docs.
Improved default support for embedded documents in MongoDB
From version
4.0.0
, you can now set default values on embedded documents using the@default
attribute. Prisma will provide the specified default value on reads if a field is not defined in the database.You can define default values for embedded documents in your Prisma schema as follows:
Refer to our docs to learn more on default values for required fields on composite types.
4.0.0
.Explicit unique constraints for 1:1 relations
From version
4.0.0
, 1:1 relations are now required to be marked with the@unique
attribute on the side of the relationship that contains the foreign key.Previously, the relation fields were implicitly treated as unique under the hood. The field was also added explicitly when
npx prisma format
was run.Removed support for usage of
references
on implicit m:n relationsThis release removes the usage of the
references
argument, which was previously optional when using m:n relations.This is because the only valid value for
references
wasid
, so removing this argument clarifies what can and cannot be changed.Refer to our docs to learn more about implicit m:n relations.
Enforcing uniqueness of referenced fields in the
references
argument in 1:1 and 1:m relations for MySQLFrom version
4.0.0
, Prisma will now enforce that the field on thereferences
side of a@relation
is unique when working with MySQL.To fix this, add the
@unique
or@id
attributes to foreign key fields in your Prisma schema.4.0.0
, refer to our upgrade guide.Removal of undocumented support for the
type
aliasWith
4.0.0
, we're deprecating thetype
keyword for string aliasing. Thetype
keyword will now be exclusively used for defining embedded documents in MongoDB.We encourage you to remove any usage of the
type
keyword from your Prisma schema for type aliasing.Removal of the
sqlite
protocol for SQLite URLsStarting from
4.0.0
, we are dropping support of thesqlite://
URL prefix for SQLite. We encourage you to use thefile://
prefix when working with SQLite.Better grammar for string literals
String literals in the Prisma schema now need to follow the same rules as strings in JSON. That changes mostly the escaping of some special characters.
You can find more details on the specification here:
To fix this, resolve the validation errors in your Prisma schema or run
npx prisma db pull
to get the current values from the database.New Prisma Client APIs:
findUniqueOrThrow
andfindFirstOrThrow
In this release, we're introducing two new APIs to Prisma Client:
findUniqueOrThrow
– retrieves a single record asfindUnique
but throws aRecordNotFound
exception when no record is not foundfindFirstOrThrow
– retrieves the first record in a list asfindFirst
but throws aRecordNotFound
exception when no record is foundHere's an example of usage of the APIs:
The APIs will be convenient for scripts API routes where you're already handling exceptions and want to fail fast.
Refer to the API reference in our docs to learn how
findUniqueOrThrow
andfindFirstOrThrow
differ fromfindUnique
andfindFirst
respectively.Deprecating
rejectOnNotFound
We're deprecating the
rejectOnNotFound
parameter in favor of the newfindUniqueOrThrow
andfindFirstOrThrow
Prisma Client APIs.We expect the new APIs to be easier to understand and more type-safe.
Refer to the
findUniqueOrThrow
andfindFirstOrThrow
docs to learn how you can upgrade.Fix rounding errors on big numbers in SQLite
SQLite is a loosely-typed database. While Prisma will prevent you from inserting values larger than integers, nothing prevents SQLite from accepting big numbers. These manually inserted big numbers cause rounding errors when queried.
Prisma will now check numbers in the query's response to verify they fit within the boundaries of an integer. If a number does not fit, Prisma will throw a
P2023
error:To learn more on rounding errors with big numbers on SQLite, refer to our docs.
DbNull
,JsonNull
, andAnyNull
are now objectsPreviously,
Prisma.DbNull
,Prisma.JsonNull
, andPrisma.AnyNull
used to be implemented using string constants. This meant their types overlapped with regular string data that could be stored in JSON fields.We've now made them special objects instead that don't overlap with string types.
Before
4.0.0
DbNull
was checked as a string so you could accidentally check for a null as follows:Expand to view the underlying Prisma schema
Prisma 4 resolves this using constants guaranteed to be unique to prevent this kind of inconsistent queries.
You can now read, write, and filter JSON fields as follows:
We recommend you double-check queries that use
Json
after upgrading to Prisma 4. Ensure that you use thePrisma.DbNull
,Prisma.JsonNull
, andPrisma.AnyNull
constants from Prisma Client, not string literals.Refer to the Prisma 4 upgrade guide in case you run into any type errors.
Prisma Studio updates
We've refined the experience when working with Prisma Studio with the following changes:
Dropped support for Node 12
The minimum version of Node.js Prisma will support is
14.17.x
. If you're using an earlier version of Node.js, you will need to update your Node.js version.Refer to our system requirements for the minimum versions Prisma requires
New default sizes for statement cache
We had inconsistent and large default values (500 for PostgreSQL and 1000 for MySQL) for the
statement_cache_size
. The new shared default value is 100.If the new default doesn't work for you, please create an issue and use the
statement_cache_size=x
parameter in your connection string to override the default value.Renaming of
@prisma/sdk
npm package to@prisma/internals
The internal package
@prisma/sdk
is now available under the new, more explicit name@prisma/internals
.We do not provide any API guarantees for
@prisma/internals
as it might need to introduce breaking changes from time to time, and it does not follow semantic versioning.This is technically not a breaking change as usage of the
@prisma/sdk
package is neither documented nor supported.If you're using
@prisma/sdk
(now@prisma/internals
), it would be helpful if you could help us understand where, how, and why you are using it by giving us feedback in this GitHub discussion. Your feedback will be valuable to us in defining a better API.Removal of the internal
schema
property from the generated Prisma ClientWe've removed the internal
Prisma.dmmf.schema
to reduce the size of Prisma Client generated and improve boot times.To access the
schema
property, you can use thegetDmmf()
method from@prisma/internals
.Fixes and improvements
Prisma
statement_cache_size
type
alias with Prisma 4.0.0@unique
is added during Re-Introspectionreferences
arg on Many2Many relations on SQLextendedIndexes
GAextendedIndexes
Option::unwrap()
on aNone
value in query-engine/core/src/interpreter/query_interpreters/nested_read.rs:232:50db pull
/db push
flowdb push
with MongoDBlength
prefix onUnsupported
fields on MySQLundici 5.1.1
packagePrisma Client
PrismaClientInitializationError
is missing expected error codeResult::unwrap()
on anErr
value: FieldNotFound { name: "upsert", model: "CcStructureUnit" } in query-engine/core/src/query_graph_builder/write/write_args_parser.rs:24:62@prisma/sdk
package to reduce confusionsqlite:
for defining a sqlite urlOption::unwrap()
on aNone
value in query-engine/core/src/interpreter/query_interpreters/nested_read.rs:232:50Option::unwrap()
on aNone
value in query-engine\core\src\interpreter\query_interpreters\nested_read.rs:232:50thread 'tokio-runtime-worker' panicked at 'called
Option::unwrap()on a
Nonevalue', /Users/runner/.cargo/git/checkouts/quaint-9f01e008b9a89c14/479e08a/src/connector/postgres/conversion/decimal.rs:81:39
default(now())
on the same table sometimes yield different timesLanguage tools (e.g. VS Code)
Prisma Engines
Huge thanks to @shian15810, @zifeo, @ever0de, @givensuman, @peter-gy, @rushabhhere, @flatplate, @njmaeff, @tnzk, @DePasqualeOrg, @roboncode, @jacobhq for helping!
📺 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, June 30 at 5 pm Berlin | 8 am San Francisco.
📺 Learn how to upgrade in our webinar on July 12th
We're going to host a dedicated webinar with Prisma engineers to talk about the upgrade process. If you're unsure whether the breaking changes of this release affect you, be sure to not miss this livestream.
The stream takes place on YouTube on Tuesday, July 12 at 5 pm Berlin | 8 am San Francisco.
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), 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.