v0.9.0
What's Changed
Support for Interactive Transactions
This release adds support for interactive transactions! This means you can safely group sets of queries into a single atomic transaction that will be rolled back if any step fails.
Quick example:
from prisma import Prisma
prisma = Prisma()
await prisma.connect()
async with prisma.tx() as transaction:
user = await transaction.user.update(
where={'id': from_user_id},
data={'balance': {'decrement': 50}}
)
if user.balance < 0:
raise ValueError(f'{user.name} does not have enough balance')
await transaction.user.update(
where={'id': to_user_id},
data={'balance': {'increment': 50}}
)
For more information see the docs.
Support for find_unique_or_raise
& find_first_or_raise
This release adds two new client methods, find_unique_or_raise
& find_first_or_raise
which are the exact same as the respective find_unique
& find_first
methods but will raise an error if a record could not be found.
This is useful when you know that you should always find a given record as you won't have to explicitly handle the case where it isn't found anymore:
user = await db.user.find_unique_or_raise(
where={
'id': '...',
},
include={
'posts': True,
},
)
Prisma updates
This release bumps the internal Prisma version from v4.11.0
to v4.15.0
.
Some of the highlights:
- Introspection warnings for unsupported database features
- Support for passing custom arguments to
prisma db seed
For the full release notes, see the v4.12.0, v4.13.0, v4.14.0 and v4.15.0 release notes.
Miscellaneous Changes
- Bumped minimum required
typing-extensions
version from3.7
to4.0.1
- Added support for the
--generator
option toprisma py generate
as well - Improved internal testing for the synchronous client
- Improved error message for missing engine binary
- Improved error message for usage of unsupported composite types
Sponsors
Huge thank you to @isometric & @techied for their continued support!