Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
APACHE-2.0 License
Bot releases are hidden (Show)
Published by jharrell 25 days ago
š Help us spread the word about Prisma by starring the repo or posting on X about the release. š
strictUndefinedChecks
in PreviewWith Prisma ORM 5.20.0, the Preview feature strictUndefinedChecks
will disallow any value that is explicitly undefined
and will be a runtime error. This change is direct feedback from this GitHub issue and follows our latest proposal on the same issue.
To demonstrate the change, take the following code snippet:
prisma.table.deleteMany({
where: {
// If `nullableThing` is nullish, this query will remove all data.
email: nullableThing?.property,
}
})
In Prisma ORM 5.19.0 and below, this could result in unintended behavior. In Prisma ORM 5.20.0, if the strictUndefinedChecks
Preview feature is enabled, you will get a runtime error instead:
Invalid \`prisma.user.findMany()\` invocation in
/client/tests/functional/strictUndefinedChecks/test.ts:0:0
XX })
XX
XX test('throws on undefined input field', async () => {
ā XX const result = prisma.user.deleteMany({
where: {
email: undefined
~~~~~~~~~
}
})
Invalid value for argument \`where\`: explicitly \`undefined\` values are not allowed."
We have also introduced the Prisma.skip
symbol, which will allow you to get the previous behavior if desired.
prisma.table.findMany({
where: {
// Use Prisma.skip to skip parts of the query
email: nullableEmail ?? Prisma.skip
}
})
From Prisma ORM 5.20.0 onward, we recommend enabling strictUndefinedChecks
, along with the TypeScript compiler option exactOptionalPropertyTypes
, which will help catch cases of undefined values at compile time. Together, these two changes will help protect your Prisma queries from potentially destructive behavior.
strictUndefinedChecks
will be a valid Preview feature for the remainder of Prisma ORM 5. With our next major version, this behavior will become the default and the Preview feature will be āgraduatedā to Generally Available.
If you have any questions or feedback about strictUndefinedChecks
, please ask/comment in our dedicated Preview feature GitHub discussion.
typedSql
bug fixThank you to everyone who has tried out our typedSql
Preview feature and provided feedback! This release has a quick fix for typescript files generated when Prisma Schema enums had hyphens.
not available
.generate
when typedSql is enabled and enum contains hyphens.@prisma/internals
didn't list ts-toolbelt
in dependencies.$extends
prevents model comments from being passed to TypeScriptHuge thanks to @mcuelenaere, @pagewang0, @key-moon, @pranayat, @yubrot, @thijmenjk, @mydea, @HRM, @haaawk, @baileywickham, @brian-dlee, @nickcarnival, @eruditmorina, @nzakas, and @gutyerrez for helping!
Published by jkomyno about 2 months ago
Today, we are issuing the 5.19.1
patch release.
We've fixed the following issues:
Full Changelog: https://github.com/prisma/prisma/compare/5.19.0...5.19.x, https://github.com/prisma/prisma-engines/compare/5.19.0...5.19.x
Today, we are excited to share theĀ 5.19.0
Ā stable releaseĀ š
š Help us spread the word about Prisma by starring the repo or posting on X about the release. š
TypedSQL is a brand new way to interact with your database from Prisma Client. After enabling the typedSql
Preview feature, youāre able to write SQL queries in a new sql
subdirectory of your prisma
directory. These queries are then checked by Prisma during using the new --sql
flag of prisma generate
and added to your client for use in your code.
To get started with TypedSQL:
Make sure that you have the latest version of prisma
and @prisma/client
installed:
npm install -D prisma@latest
npm install @prisma/client@latest
Enable the typedSql
Preview feature in your Prisma Schema.
generator client {
provider = "prisma-client-js"
previewFeatures = ["typedSql"]
}
Create a sql
subdirectory of your prisma
directory.
mkdir -p prisma/sql
You can now add .sql
files to the sql
directory! Each file can contain one sql query and the name must be a valid JS identifier. For this example, say you had the file getUsersWithPosts.sql
with the following contents:
SELECT u.id, u.name, COUNT(p.id) as "postCount"
FROM "User" u
LEFT JOIN "Post" p ON u.id = p."authorId"
GROUP BY u.id, u.name
Import your SQL query into your code with the @prisma/client/sql
import:
import { PrismaClient } from '@prisma/client'
import { getUsersWithPosts } from '@prisma/client/sql'
const prisma = new PrismaClient()
const usersWithPostCounts = await prisma.$queryRawTyped(getUsersWithPosts)
console.log(usersWithPostCounts)
Thereās a lot more to talk about with TypedSQL. We think that the combination of the high-level Prisma Client API and the low-level TypedSQL will make for a great developer experience for all of our users.
To learn more about behind the āwhyā of TypedSQL be sure to check out our announcement blog post.
For docs, check out our new TypedSQL section.
A few issues with our driverAdapters
Preview feature and Cloudflare D1 support were resolved via https://github.com/prisma/prisma-engines/pull/4970 and https://github.com/prisma/prisma/pull/24922
max
, min
, eq
, etc in queries when using Cloudflare D1.BigInt
IDs when relationMode="prisma"
was enabled and Cloudflare D1 was being used.some
clauses when the relationJoins
Preview feature was enabled.Looking to make an impact on Prisma in a big way? We're now hiring engineers for the ORM team!
prisma-engines
Rust codebase. TypeScript knowledge (or, again, a desire to learn) is a plus.Huge thanks to @mcuelenaere, @pagewang0, @Druue, @key-moon, @Jolg42, @pranayat, @ospfranco, @yubrot, @skyzh for helping!
Published by jharrell 2 months ago
š Help us spread the word about Prisma by starring the repo or tweeting about the release. š
Previous to this release, the Prisma Schema function uuid()
did not accept any arguments and created a UUIDv4 ID. While sufficient in many cases, UUIDv4 has a few drawbacks, namely that it is not temporally sortable.
UUIDv7 attempts to resolve this issue, making it easy to temporally sort your database rows by ID!
To support this, weāve updated the uuid()
function in Prisma Schema to accept an optional, integer argument. Right now, the only valid values are 4
and 7
, with 4
being the default.
model User {
id String @id @default(uuid()) // defaults to 4
name String
}
model User {
id String @id @default(uuid(4)) // same as above, but explicit
name String
}
model User {
id String @id @default(uuid(7)) // will use UUIDv7 instead of UUIDv4
name String
}
Weāve squashed a number of bugs this release, special thanks to everyone who helped us! A few select highlights are:
prismaSchemaFolder
.Json[]
fields will now return []
instead of null
when accessed through a join using the relationJoins
Preview feature.We want to know how you like working with Prisma ORM in your projects! Please take our 2min survey and let us know what you like or where we can improve š
Huge thanks to @mcuelenaere, @pagewang0, @Druue, @key-moon, @Jolg42, @pranayat, @ospfranco, @yubrot, @skyzh, @haaawk for helping!
Published by jharrell 3 months ago
š Help us spread the word about Prisma by starring the repo or tweeting about the release. š
Weāre happy to introduce some cool new features that will make your experience with the Prisma VSCode extension even better!
Find references across schema files
The ability to hop between references of a given symbol is really useful in application code and now with the introduction of multi-file schema, we think itās the perfect time to bring this feature to the VSCode extension!
With the 5.17.0 release, youāll now have the ability to use the native āfind referencesā feature to find any usage of a given symbol
Added context on hover
When hovering over a symbol that references a view, type, enum, or any other block with multiple values, youāll now see a handy pop out that shows what is in that block at a glance.
Additional quick fixes
Weāve taken some fixes made by the prisma format
cli command and made them quick fixes available to the VSCode Extension. Now, when you have forget a back relation or relation scalar field, youāll now see in real time what is wrong and have the option to fix it via the extension.
Weāve changed the response format of queryRaw
to decrease its average size which reduces serialization CPU overhead.
When querying large data sets, we expect you to see improved memory usage and up to 2x performance improvements.
Huge thanks to @key-moon, @pranayat, @yubrot, @skyzh for helping!
Published by SevInf 3 months ago
Today, we are issuing the 5.16.2 patch release to fix an issue in Prisma client.
Published by apolanc 4 months ago
Today, we are issuing the 5.16.1 patch release to fix an issue in Prisma client.
Published by jharrell 4 months ago
š Help us spread the word about Prisma by starring the repo or tweeting about the release. š
With Prisma ORM 5.16.0 weāre more than happy to announce that weāre expanding the omitApi
Preview feature to also include the ability to omit fields globally.
When the Preview feature is enabled, youāre able to define fields to omit when instantiating Prisma Client.
const prisma = new PrismaClient({
omit: {
user: {
// make sure that password is never queried.
password: true,
},
},
});
Youāre also able to omit fields from multiple models and multiple fields from the same model
const prisma = new PrismaClient({
omit: {
user: {
// make sure that password and internalId are never queried.
password: true,
internalId: true,
},
post: {
secretkey: true,
},
},
});
With both local and global omit
, you now have the flexibility to completely remove sensitive fields while also tailoring individual queries. If you need the ability to generally omit a field except in a specific query, you can also overwrite a global omit locally
const prisma = new PrismaClient({
omit: {
user: {
// password is omitted globally.
password: true,
},
},
});
const userWithPassword = await prisma.user.findUnique({
omit: { password: false }, // omit now false, so password is returned
where: { id: 1 },
});
prismaSchemaFolder
In 5.15.0
we released the prismaSchemaFolder
Preview feature, allowing you to create multiple Prisma Schema files in a prisma/schema
directory. Weāve gotten a lot of great feedback and are really excited with how the community has been using the feature.
To continue improving our multi-file schema support, we have a few breaking changes to the prismaSchemaFolder
feature:
prismaSchemaFolder
feature, a path is now relative to the file it is defined in rather than relative to the prisma/schema
folder. This means that if you have a generator block in /project/prisma/schema/config/generator.prisma
with an output
of ./foo
the output will be resolved to /project/prisma/schema/config/foo
rather than /project/prisma/foo
. The path to a SQLite file will be resolved in the same manner.prisma/schema
as well as prisma/schema.prisma
. Our initial implementation looked for a .prisma
file first and would ignore the schema
folder if it exists. This is now an error.fullTextSearch
In order to improve our full-text search implementation we have made a breaking change to the fullTextSearch
Preview feature.
Previously, when the feature was enabled we updated the <Model>OrderByWithRelationInput
TypeScript type with the <Model>OrderByWithRelationAndSearchRelevanceInput
type. However, we have noted that there are no cases where relational ordering is needed but search relevance is not. Thus, we have decided to remove the <Model>OrderByWithRelationAndSearchRelevanceInput
naming and only use the <Model>OrderByWithRelationInput
naming.
Prisma has no exported member named OrderByWithRelationInput. Did you mean OrderByWithAggregationInput?
prisma generate
@prisma/adapter-pg
modifies node-postgres global type parsersdb pull
fails with [libs\user-facing-errors\src\quaint.rs:136:18] internal error: entered unreachable code
on invalid credentialsHuge thanks to @key-moon, @pranayat, @yubrot, @skyzh, @brian-dlee, @mydea, @nickcarnival, @eruditmorina, @nzakas, @gutyerrez, @avallete, @ceddy4395, @Kayoshi-dev, @yehonatanz for helping!
Published by SevInf 4 months ago
Today, we are issuing the 5.15.1
patch release.
ConnectionError(Timed out during query execution.)
during seedingConnectionError(Timed out during query execution.)
error when using Promise.all
for SQLitePromise.all()
/ concurrentPublished by jharrell 5 months ago
Today, we are excited to share theĀ 5.15.0
Ā stable releaseĀ š
š Help us spread the word about Prisma by starring the repo or tweeting about the release. š
Prisma ORM 5.15.0 features support for multi-file Prisma Schema in Preview.
This closes a long standing issue and does so in a clean and easy to migrate way.
To get started:
prismaSchemaFolder
Preview feature by including it in the previewFeatures
field of your generator
.
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["prismaSchemaFolder"]
}
schema
subdirectory under your prisma
directory.schema.prisma
into this directory.You are now set up with a multi-file Prisma Schema! Add as many or as few .prisma
files to the new prisma/schema
directory.
When running commands where a Prisma Schema file is expected to be provided, you can now define a Prisma Schema directory. This includes Prisma CLI commands that use the --schema
option as well as defining schema via package.json
Our tooling has also been updated to handle multiple Prisma Schema files. This includes our Visual Studio Code extension and tools like database introspection, which will deposit new models in a introspected.prisma
file. Existing models will be updated in the file they are found.
To learn more, please refer to our official documentation and announcement blog post. If you try out prismaSchemaFolder
, please let us know!
This release fixes a nasty bug with the caching of prepared statements in raw Prisma Client queries that affected PostgreSQL when you ran the same SQL statement with differently typed paramters. This should not fail any more.
CREATE DEFAULT
Our Introspection logic crashed on encountering certain multi-line CREATE DEFAULT
, a deprecated way to define defaults in SQL Server. As many SQL Server users are working with established databases, this happened frequently enough that we now explicitly ignore these defaults instead of crashing.
Cloudflareās D1 has a lower parameter limit than local SQLite, which caused bigger queries to fail. We adapted that limit to the D1 default for @prisma/adapter-d1
, which will avoid such failures.
PRAGMA
supportOur generated migration SQL for SQLite did not always work for Cloudflare D1, because of differences in the supported pragmas. We adapted the SQL to work in both local SQLite and Cloudflare D1.
Result::unwrap()
on an Err
value: "Couldn't parse default value: create default [dbo].[member_notification_cancel_flags] as 0\r\n
" Result::unwrap()
on an Err
value: "Couldn't parse default value: create default d_password as 'D,73'
" DEFAULT
sResult::unwrap()
on an Err
value: "Couldn't parse default value: \r\ncreate default D_BIT_OFF\r\nas 0\r\n
" Result::unwrap()
on an Err
value: "Couldn't parse default value in SQL ServerError: [libs\sql-schema-describer\src\mssql.rs:336:30] called
Result::unwrap()on an
Err value: "Couldn't parse default value: [...]
Result::unwrap()
on an Err
value: "Couldn't parse default value: \r\ncreate default [va_nulla] as 0\r\n
" db pull
can't parse script setting default value22P03
. Message: db error: ERROR: incorrect binary data format in bind parameter 1
incorrect binary data format in bind parameter 1
incorrect binary data format in bind parameter x
)_count
leads to errorwarn(prisma-client) This is the 10th instance of Prisma Client being started.
warning in Edge (and potentially) other envs)incorrect binary data format in bind parameter 6
Inconsistent column data: Unexpected conversion failure from Number to BigInt
error when using @prisma/adapter-pg
Int
switched to being Int32
for MongoDBGenerate
codelens fails on WindowsHuge thanks to @pranayat, @yubrot, and @skyzh for helping!
Published by jharrell 5 months ago
Today, we are excited to share theĀ 5.14.0
Ā stable releaseĀ š
š Help us spread the word about Prisma by starring the repo āļø or posting on X about the release. š
We want to know how you like working with Prisma ORM in your projects! Please take our 2min survey and let us know what you like or where we can improve š
createManyAndReturn()
Weāre happy to announce the availability of a new, top-level Prisma Client query: createManyAndReturn()
. It works similarly to createMany()
but uses a RETURNING
clause in the SQL query to retrieve the records that were just created.
Hereās an example of creating multiple posts and then immediately returning those posts.
const postBodies = req.json()['posts']
const posts = prisma.post.createManyAndReturn({
data: postBodies
});
return posts
Additionally,createManyAndReturn()
supports the same options as findMany()
, such as the ability to return only specific fields.
const postBodies = req.json()['posts']
const postTitles = prisma.post.createManyAndReturn({
data: postBodies,
select: {
title: true,
},
});
return postTitles
Full documentation for this feature can be found in the Prisma Client API Reference.
Note: Because createManyAndReturn()
uses the RETURNING
clause, it is only supported by PostgreSQL, CockroachDB, and SQLite databases. At this time, relationLoadStrategy: join
is not supported in createManyAndReturn()
queries.
Previously, Prisma ORM suffered from performance issues when using the in
operator or when including related models in queries against a MongoDB database. These queries were translated by the Prisma query engine in such a way that indexes were skipped and collection scans were used, leading to slower queries especially on large datasets.
With 5.14.0, Prisma ORM now rewrites queries to use a combination of $or
and $eq
operators, leading to dramatic performance increases for queries that include in
operators or relation loading.
createMany()
should return the created recordstake
on many-to-one relationshipinclude
for relationsfindMany()
query execution with in
include
query slowonDelete: SetNull
prisma init --with-model
@opentelemetry/*
dependenciesThe required connected records were not found.
when using indicesdbgenerated()
still breaking for Unsupported()
typesshadowDatabaseUrl
is identical to url
(or directUrl
)PRAGMA foreign_key_check;
Curious about all things Prisma? Be sure to check out the Prisma Changelog for updates across Prisma's products, including ORM, Accelerate, and Pulse!
With this release, we are excited to introduce a new Prisma product. Weāre calling it āOptimizeā because thatās what it does! Let your favorite ORM also help you debug the performance of your application.
Check out our announcement blog post for more details, including a demo video.
Huge thanks to @pranayat, @yubrot, @skyzh, @anuraaga, @gutyerrez, @avallete, @ceddy4395, @Kayoshi-dev for helping!
Published by grpatel 6 months ago
Today, we are excited to share theĀ 5.13.0
Ā stable releaseĀ š
šĀ Help us spread the word about Prisma by starring the repoĀ orĀ posting on XĀ about the release.
omit
fields from Prisma Client queries (Preview)Weāre excited to announce Preview support for the omit
option within the Prisma Client query options. The highly-requested omit
feature now allows you to exclude fields that you donāt want to retrieve from the database on a per-query basis.
By default, when a query returns records, the result includes all scalar fields of the models defined in the Prisma schema. select
can be used to return specific fields, while omit
can now be used to exclude specific fields. omit
lives at the same API level and works on all of the same Prisma Client model queries as select
. Note, however, that omit
and select
are mutually exclusive. In other words, you canāt use both in the same query.
To get started using omit
, enable the omitApi
Preview feature in your Prisma schema:
// schema.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["omitApi"]
}
Be sure to re-generate Prisma Client afterwards:
npx prisma generate
Here is an example of using omit
:
// Includes all fields except password
await prisma.user.findMany({
omit: {
password: true
},
})
Here is an example of using omit
with include
:
// Includes all user fields except user's password and title of user's posts
await prisma.user.findMany({
omit: {
password: true
},
include: {
posts: {
omit: {
title: true
},
},
},
})
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
password String
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
author User @relation(fields: [authorId], references: [id])
authorId Int
}
Many users have requested a global implementation of omit
. This request will be accommodated in the future. In the meantime, you can follow the issue here.
š£Ā Share your feedback: omitApi
Preview feature
šĀ Documentation: omit
- Prisma Client API Reference
upsert()
: Internal error: Attempted to serialize empty result.
upsert()
fails with "Attempted to serialize empty result."upsert()
: Internal error: Attempted to serialize empty result.
upsert()
: Internal error: Attempted to serialize empty result.
upsert()
: Internal error: Attempted to serialize empty result.
upsert()
: Internal error: Attempted to serialize empty result
upsert()
: Internal error: Attempted to serialize empty result.
Internal error: Attempted to serialize empty result.
on upsert()
for update
case in different databases (when using relationMode=prisma
explicitly or implicitly [MongoDB])upsert(): Internal error: Attempted to serialize empty result
when relationMode = "prisma"
is usedā [ERROR] near "ļæ½ļæ½": syntax error at offset 0
when running wrangler d1 migrations apply
with Prisma generated migration (on Windows, using Powershell)Huge thanks to @ospfranco, @pranayat, @yubrot, @skyzh, @anuraaga, @yehonatanz, @arthurfiorette, @elithrar, @tockn, @Kuhave, @obiwac for helping!
Published by Jolg42 7 months ago
Today, we are issuing the 5.12.1
patch release to fix two small problems with our new Cloudflare D1 support.
migrate diff
and db pull
The flags --from-local-d1
and --to-local-d1
for migrate diff
and --local-d1
to db pull
we added in 5.12.0 were not working as expected when running on Windows only. This is now fixed.
šĀ Documentation: Deploying a Cloudflare worker with D1 and Prisma ORM
migrate diff
: -o
or --output
We added a new parameter --output
to migrate diff
that can be used to provide a filename into which the output of the command will be written. This is particularly useful for Windows users, using PowerShell, as using >
to write into a file creates a UTF-16 LE file that can not be read by wrangler d1 migrations apply
. Using this new option, this problem can be avoided:
npx prisma migrate diff --script --from-empty --to-schema-datamodel ./prisma/schema.prisma --output ./schema.sql
Related issues:
Published by grpatel 7 months ago
Today, we are excited to share theĀ 5.12.0
Ā stable releaseĀ š
šĀ Help us spread the word about Prisma by starring the repoĀ orĀ posting on XĀ about the release.
This release brings Preview support for Cloudflare D1 with Prisma ORM š„³
D1 is Cloudflareās SQLite database that can be used when deploying applications with Cloudflare.
When using Prisma ORM with D1, you can continue to: model your database with Prisma schema language, specify sqlite
as your database provider in your Prisma schema, and interact with your database using Prisma Client.
To use Prisma ORM and D1 on Cloudflare Workers or Cloudflare Pages, you need to set sqlite
as your database provider and use the @prisma/adapter-d1
Ā database adapter via theĀ driverAdapters
Ā Preview feature, released back in version 5.4.0.
Here is an example of sending a query to your D1 database using Prisma Client in your Worker:
// src/index.ts file
import { PrismaClient } from '@prisma/client'
import { PrismaD1 } from '@prisma/adapter-d1'
// Add the D1Database to the Env interface
export interface Env {
// This must match the binding name defined in your wrangler.toml configuration
DB: D1Database
}
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Promise<Response> {
// Make sure the database name matches the binding name in wrangler.toml and Env interface
const adapter = new PrismaD1(env.DB)
// Instantiate PrismaClient using the PrismaD1 driver adapter
const prisma = new PrismaClient({ adapter })
const users = await prisma.user.findMany()
const result = JSON.stringify(users)
return new Response(result)
},
}
šĀ Documentation: Deploying a Cloudflare worker with D1 and Prisma ORM
āļøĀ Blog post: Build Applications at the Edge with Prisma ORM & Cloudflare D1 (Preview)
š£Ā Share your feedback: D1 Driver Adapter
šĀ Example project: Deploy a Cloudflare Worker with D1
createMany()
for SQLiteBringing support for createMany()
in SQLite has been a long-awaited and highly requested feature ā
createMany()
is a method on Prisma Client, released back in version 2.16.0, that lets you insert multiple records into your database at once. This can be really useful when seeding your database or inserting bulk data.
Here is an example of using createMany()
to create new users:
const users = await prisma.user.createMany({
data: [
{ name: 'Sonali', email: '[email protected]' },
{ name: 'Alex', email: '[email protected]' },
{ name: 'Yewande', email: '[email protected]' },
{ name: 'Angelina', email: '[email protected]' },
],
})
Before this release, if you wanted to perform bulk inserts with SQLite, you would have most likely used $queryRawUnsafe
to execute raw SQL queries. But now you donāt have to go through all that trouble š
With SQLite, createMany()
works exactly the same way from an API standpoint as it does with other databases except it does not support the skipDuplicates
option. At the behavior level, SQLite will split createMany()
entries into multiple INSERT
queries when the model in your schema contains fields with attributes like @default(dbgenerated())
or @default(autoincrement())
and when the fields are not consistently provided with values across the entries.
šDocumentation: createMany()
- Prisma Client API Reference
Decimal
data type and combining queries (batching)findUnique()
error out when the field is of Boolean
typerelationJoins
MySQL converts nested Decimal to floatfindUnique()
node-postgres
(pg) errors with misleading P2010 PrismaClientKnownRequestError
when using @prisma/adapter-pg
with SSL (?sslmode=require
)Huge thanks to @yubrot, @skyzh, @anuraaga, @onichandame, @LucianBuzzo, @RobertCraigie, @arthurfiorette, @elithrar for helping!
Published by nikolasburk 7 months ago
Today, we are excited to share theĀ 5.11.0
Ā stable releaseĀ š
šĀ Help us spread the word about Prisma by starring the repoĀ āļøĀ orĀ posting on XĀ about the release.
Weāre thrilled to announce that support for edge function deployments with Prisma ORM is now in Preview š„³ As of this release, you can deploy your apps that are using Prisma ORM to:
In order to deploy to an edge function, youāll need to use a compatible database driver (along with its Prisma driver adapter):
pg
driver (for traditional PostgreSQL databases)@libsql/client
driver (for SQLite databases hosted via Turso)Check out our documentation to learn how you can deploy an edge function using any combination of supported edge function provider and database.
create
operationsWith Prisma ORM, you can create multiple new records in nested queries, for example:
const user = await prisma.user.update({
where: { id: 9 },
data: {
name: 'Elliott',
posts: {
create: {
data: [{ title: 'My first post' }, { title: 'My second post' }],
},
},
},
})
In previous versions, Prisma ORM would translate this into multiple SQL INSERT
queries, each requiring its own roundtrip to the database. As of this release, these nested create
queries are optimized and the INSERT
queries are sent to the database in bulk in a single roundtrip. These optimizations apply to one-to-many as well as many-to-many relations.
With this change, using the nested create
option to create multiple records effectively becomes equivalent to using a nested createMany
operation (except that createMany
only works with one-to-many relations, whereas create
works both with one-to-many and many-to-many).
Note: Only the deepest nested operation is optimized. If a user specified
create (1) -> create (2) -> create (3)
in their query, onlycreate (3)
will be optimized.
console.log(new PrismaClient())
enum
throws error (collation cp1250_czech_cs
or similar)NOT
condition leaks out of its desired boundsPrismaClient
object is slowprisma generate
on Litespeed Web Server cPanel with sshtsc
: Cannot find namespace 'debug'.
push
method still unimplemented for scalar lists in CockroachDBInvalid character
error persists on 5.10.1 in Prisma StudioruntimeDescription
is not defined errornpx prisma db pull
with DeepinOS 20.9GNU/LInuxLinux Mint
Error: Invalid character
when schema.prisma
includes Chinese/Non-ASCII characters in a commentPublished by millsp 8 months ago
Today, we are issuing the 5.10.2
patch release.
Published by millsp 8 months ago
Today, we are issuing the 5.10.1
patch release.
Published by nikolasburk 8 months ago
Today, we are excited to share theĀ 5.10.0
Ā stable releaseĀ š
šĀ Help us spread the word about Prisma by starring the repoĀ āļøĀ orĀ posting on XĀ about the release.
This release brings the optimizations for relation queries from the previous releases to MySQL as well! This means that by enabling the relationJoins
Preview feature with the mysql
database provider, you now also get access to the relationLoadStrategy
option in relation queries that let you choose whether you want to merged relations on the application- or database-level.
If you enable the relationJoins
Preview feature, you can choose between the join
and query
options:
join
(default): Sends a single query to the database and joins the data on the database-level.query
: Sends multiple queries to the database and joins the data on the application-level.To get started, enable the Preview feature in your Prisma schema:
// schema.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["relationJoins"]
}
Be sure to re-generate Prisma Client afterwards:
npx prisma generate
And finally, specify the relation loading strategy for your relation query via the relationLoadStrategy
option as follows:
await prisma.user.findMany({
relationLoadStrategy: 'join', // or 'query'
include: {
posts: true,
},
})
Note that in the example above, the relationLoadStrategy
could be omitted altogether because join
is used as the default value.
A few notes about relationLoadStrategy
support on MySQL:
relationLoadStrategy
is supported for MySQL v8.0.14 and higher. MariaDB is not supported.LATERAL
JOINs which are used on PostgreSQL).PrismaClient
constructorThis feature enables you to configure the following transaction options on a global level via the PrismaClient
constructor:
isolationLevel
: Sets theĀ transaction isolation level. By default, this is set to the value currently configured in your database.timeout
: The maximum amount of time the interactive transaction can run before being canceled and rolled back. The default value is 5 seconds.maxWait
: The maximum amount of time Prisma Client will wait to acquire a transaction from the database. The default value is 2 seconds.Here is an example of how you can set this value globally for all transactions:
const prisma = new PrismaClient({
transactionOptions: {
isolationLevel: 'ReadCommitted',
timeout: 1_000, // 1 sec
maxWait: 2_000 // 2 sec
}
})
Thanks a lot to our fantastic community member @tockn
, who took the initiative to implement this feature in Prisma ORM š
Note that you can still override the global values by setting them on a particular transaction.
P2037
code for āToo many database connections openedā errorsWe introduced a new error code for āToo many database connections openedā errors: P2037
. You can find all error codes in our documentation.
Now available in Early Access, you can manage your workspace and configure Prisma Accelerate and Prisma Pulse directly from the terminal.
Visit our docs to learn more about the integration and try it out for yourself!
Option::unwrap()
on a None
value when using the relationJoins preview feature with driver adaptersPrisma.TransactionClient
appears to be missing types@prisma/client
in Next.js middleware$extends
always return any
Error: Prisma Client is unable to run in an edge runtime. As an alternative, try Accelerate: https://pris.ly/d/accelerate.
t3.bookGenreTitle
does not exist in the current database"relationJoins
preview feature: called Option::unwrap()
on a None
valuePublished by Jolg42 9 months ago
Today, we are issuing the 5.9.1
patch release.
In 5.9.0
we have changed our conditional exports in @prisma/client
. This resulted in broken types for TypesScript users using certain combinations of module
/moduleResolution
settings. Additionally, it also caused a regression for Next.js users which have encountered invalid error messages from our side.
You can now try out 5.9.1
and let us know if you find a bug at https://pris.ly/prisma-prisma-bug-report
Error: Prisma Client is unable to run in an edge runtime. As an alternative, try Accelerate: https://pris.ly/d/accelerate.
#22889Note: many issues are duplicates.
Published by nikolasburk 9 months ago
Today, we are excited to share theĀ 5.9.0
Ā stable releaseĀ šĀ
šĀ Help us spread the word about Prisma by starring the repoĀ āļøĀ orĀ posting on XĀ about the release.
This release brings a number of small improvements as we continue our work on larger features which you will hear more about in the coming weeks:
We continue our efforts of the performance of Prisma Client queries. In 5.1.0
, we introduced the RETURNING
keyword for several queries on PostrgeSQL and CockroachDB. We now expanded the use of RETURNING
to SQLite and a broader range of queries for existing databases (e.g. delete
on PostgreSQL and MongoDB). You can learn more about the optimizations of the result sets in these PRs:
When trying migrate/introspect a SQL server instance thatās unreachable, Prisma ORM now returns the correct P1001
error instead of failing without an error. Learn more in this PR: SQL Server: Migrate/Introspection engine doesn't return P1001 error for unreachable url.
select
queries on create/update/deleteERROR: column "..." being dropped, try again later
when applying migrations with CRDB 23.1Today, the only way how to use Prisma ORM in edge functions (e.g. Cloudflare Workers or Vercel Edge Functions) is by using Prisma Accelerate. However, we are actively working on making Prisma ORM compatible with edge functions natively as well. If you want to become an early tester, you can apply for the private Early Accessing program by taking this survey.
Last year, AWS announcedĀ the decision to begin charging for IPv4 addresses beginning in February 2024. This move had a major impact on Prisma Accelerate, prompting us to go all-in on IPv6. Learn more in this technical deep dive into how we approached our IPv6 migration, lessons learned, and the outcome for users of Prisma Accelerate.
Huge thanks to @laplab, @Druue, @anuraaga, @onichandame, @LucianBuzzo, @RobertCraigie, @almeidx, @victorgdb, @tinola, @sampolahtinen, @AikoRamalho, @petradonka for helping!