Skip to content

Releases: RobertCraigie/prisma-client-py

v0.15.0

16 Aug 02:54
b579e0d
Compare
Choose a tag to compare

What's Changed

Fixed regression with optional raw query fields

The last release, v0.14.0, included a regression with the handling of optional values for BigInt, Decimal & Json fields where an error would be raised if the value was None.

Massive thank you to @AstreaTSS for a very detailed bug report and contributing a fix!

Support for .create_many() for SQLite

The create_many() method is now supported in SQLite!

total = await client.user.create_many([{'name': 'Robert'}, {'name': 'Tegan'}])
# 2

However the skip_duplicates argument is unfortunately not supported yet.

Massive thank you to @AdeelK93 for contributing this feature!

Support for connect_or_create

You can now connect or create a relational record through the .create() method, for example:

post = await client.post.create(
     data={
         'title': 'Post 1',
         'published': True,
         'author': {
             'connect_or_create': {
                 'where': {
                     'id': user.id,
                 },
                 'create': {
                     'name': 'Robert',
                 },
             },
         },
     },
     include={
         'author': True,
     },
 )

Thanks to @AdeelK93 for contributing this feature!

Preview support for full text search

A new search parameter has been added for string field filters in PostgreSQL and MySQL. The syntax within the string is entirely dependent on the underlying database.

For example, in PostgreSQL, a filter for all posts where the title contains "cat" or "dog" would look like this:

posts = await client.post.find_many(
     where={
         'title': {
             'search': 'cats | dogs',
         },
     }
 )

To use full text search you'll need to add it as a preview feature

generator client {
  provider        = "prisma-client-py"
  previewFeatures = ["fullTextSearch"]
}

See these docs for more details on full text search.

Massive thank you again(!) to @AdeelK93 for contirbuting this feature.

v0.14.0

04 Aug 17:56
0cafaa7
Compare
Choose a tag to compare

What's Changed

Support for Prisma Schema Folder

Prisma now has preview support for splitting your schema.prisma file into multiple separate files!

For more information see their docs.

Dropped support for Python 3.7

Python 3.7 has been EOL for a while now and accounts for less than 1% of the downloads of Prisma Client Python, as such, support was dropped in this release.

Prisma Upgrades

The internal Prisma version has been updated from v5.11.0 to v5.17.0 which includes a lot of improvements, see the Prisma release notes for more information.

v0.13.1

24 Mar 22:11
b624a94
Compare
Choose a tag to compare

This is a patch release to fix a minor regression with datasource env vars and datasource overriding.

v0.13.0

22 Mar 10:20
ce76a92
Compare
Choose a tag to compare

What's changed

Customisation of client model instance names

Up until now, if you had a schema like this defined:

model OrgMember {
  // ...
}

You would have to access it like this:

from prisma import Prisma

client = Prisma()
member = client.orgmember.find_unique(...)

With this release you can customise the instance name on the client, e.g. orgmember, to whatever you would like! For example:

/// @Python(instance_name: "org_member")
model OrgMember {
  // ...
}

The OrgMember model can now be accessed through the client like so:

client = Prisma()
client.org_member.find_unique(...)

A future release will also add support for changing the default casing implementation used in the client!

Prisma upgrades

The internal Prisma version has been bumped from 5.8.0 to 5.11.0, you can find the release notes for each version below:

Official support for Python 3.12

Up until now Prisma Client Python didn't declare support for Python 3.12 but it will have worked at runtime. The only user facing changes in this release are to the python -m prisma_cleanup script to avoid a deprecation warning.

Minor internal breaking changes

Some minor changes were made to modules that were intended to be private but were not marked with a preceding _.

  • prisma.builder has been moved to prisma._builder
  • The main export from the prisma.builder module, QueryBuilder, has new required constructor arguments

Misc changes

I've also started laying the ground work for usage of both the async client and the sync client at the same time and hope to support this in the next release!

New Contributors

Sponsors

sponsors

v0.12.0

14 Jan 18:40
8a5695c
Compare
Choose a tag to compare

What's Changed

This release bumps the internal Prisma version from 5.4.2 to 5.8.0 bringing major preview improvements to distinct & joins.

This release also ensures we use a consistent enum format on Python 3.11 upwards, see this issue for more details.

Misc changes

Sponsors

sponsors

v0.11.0

22 Oct 23:01
bc79aee
Compare
Choose a tag to compare

What's Changed

This release bumps the internal Prisma version from 4.15.2 to 5.4.2 bringing major performance improvements.

This release also adds support for retrieving metrics, e.g.

from prisma import Prisma

client = Prisma()

metrics = client.get_metrics()
print(metrics.counters[0])

See the docs for more information.

Misc changes

Sponsors

sponsors

v0.10.0

28 Aug 10:13
823bad9
Compare
Choose a tag to compare

What's Changed

This release adds support for Pydantic v2 while maintaining backwards compatibility with Pydantic v1.

This should be a completely transparent change for the majority of users with one exception regarding prisma.validate.

Due to this bug we can't use the new TypeAdapter concept in v2 and instead rely on the v1 re-exports, this has the implication that any errors raised by the validator will need to be caught using the v1 ValidationError type instead, e.g.

from pydantic.v1 import ValidationError
import prisma

try:
    prisma.validate(...)
except ValidationError:
    ...

Improved timeouts inputs

All timeout arguments now accept a datetime.timedelta instance as well as the previously accepted int / float types, however support for int / float has been deprecated and will be removed in a future release.

The previous values were used inconsistently, sometimes it meant seconds and sometimes it meant milliseconds. This new structure is more flexible and allows you to specify the time in whatever format you'd like. Thanks @jonathanblade!

from datetime import timedelta
from prisma import Prisma

db = Prisma(
  connect_timeout=timedelta(seconds=20),
)

Misc Changes

Thanks @zspine and @jonathanblade for contributing!

sponsors

v0.9.1

01 Jul 10:01
f94ba3f
Compare
Choose a tag to compare

This release pins pydantic to < 2 as v2.0.0 is not yet compatible with Prisma.

Misc Changes

Thanks to @izeye and @Leon0824 for contributing!

Sponsors

sponsors

v0.9.0

12 Jun 02:16
208233f
Compare
Choose a tag to compare

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:

For the full release notes, see the v4.12.0, v4.13.0, v4.14.0 and v4.15.0 release notes.

Miscellaneous Changes

Sponsors

Huge thank you to @isometric & @techied for their continued support!

sponsors

v0.8.2

05 Mar 18:54
55c3ca2
Compare
Choose a tag to compare

Prisma updates

This release bumps the internal Prisma version from v4.10.1 to v4.11.0, although there aren't any major changes here for Prisma Client Python users.

The full release notes can be found here.

Bug fIxes