v0.8.1
Support for selecting fields
This release adds support for selecting fields at the database level!
This currently only works for queries using model based access either by defining your own model classes or generating them using partial types.
Quick example:
from prisma.bases import BaseUser
class UserWithName(BaseUser):
name: str
# this query will only select the `name` field at the database level!
user = await UserWithName.prisma().find_first(
where={
'country': 'Scotland',
},
)
print(user.name)
For a more detailed guide see the docs.
Support for distinct filters
You can now pass in a distinct
filter to find_first()
and find_many()
queries.
For example, the following query will find all Profile
records that have a distinct, or unique, city
field.
profiles = await db.profiles.find_many(
distinct=['city'],
)
# [
# { city: 'Paris' },
# { city: 'Lyon' },
# ]
You can also filter by distinct combinations, for example the following query will return all records that have a distinct city
and country
combination.
profiles = await db.profiles.find_many(
distinct=['city', 'country'],
)
# [
# { city: 'Paris', country: 'France' },
# { city: 'Paris', country: 'Denmark' },
# { city: 'Lyon', country: 'France' },
# ]
CLI support for specifying the generator to use
Thanks to @yukukotani's great work on the CLI you can now ergonomically share the same schema between multiple languages, for example with the following schema:
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
generator node {
provider = "prisma-client-js"
}
generator python {
provider = "prisma-client-py"
}
model User {
id Int @id
name String
}
You can now skip the generation of the Node client with the --generator
argument:
prisma generate --generator=python
See the generate
documentation for more details.
Bug fixes
Prisma updates
This release bumps the internal Prisma version from v4.8.0
to v4.10.1
- Multi-schema support for SQL Server (Preview)
- Improved CLI support for connection proxies
- Improved introspection support for unsupported features
- Smaller engine size in the CLI
For the full release notes, see the v4.9.0 release notes and the v4.10.0 release notes.
Minimum required type checker version
Before this release there were no explicit compatibility requirements for type checkers. From now on we will only support the latest versions of Mypy and Pyright.
In the next release the mypy plugin will be deprecated and later removed entirely. There is a bug in the plugin API in the latest versions of mypy that completely breaks the plugin and seems impossible to fix. See #683 for more information.
Sponsors
Massive thank you to @prisma, @techied, @exponential-hq and @danburonline for their continued support! Thank you to @paudrow for becoming a sponsor!