v0.6.5 #393
RobertCraigie
started this conversation in
General
v0.6.5
#393
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What's Changed
Raw queries are now typed with LiteralString
PEP 675 introduces a new string type,
LiteralString
, this type is a supertype of literal string types that allows functions to accept any arbitrary literal string type such as'foo'
or'bar'
for example.All raw query methods, namely
execute_raw
,query_raw
andquery_first
now take theLiteralString
type as the query argument instead ofstr
. This change means that any static type checker thats supports PEP 675 will report an error if you try and pass a string that cannot be defined statically, for example:This change has been made to help prevent SQL injection attacks.
Thank you to @leejayhsu for contributing this feature!
Basic support for filtering by
None
valuesYou can now filter records to remove or include occurrences where a field is
None
or not. For example, the following query will return all User records with an email that is not None:It should be noted that nested None checks are not supported yet, for example this is not valid:
It should also be noted that this does not change the return type and you will still have to perform not None checks to appease type checkers. e.g.
New exception classes
There are two new exception classes,
ForeignKeyViolationError
andFieldNotFoundError
.The
ForeignKeyViolationError
is raised when a foreign key field has been provided but is not valid, for example, trying to create a post and connecting it to a non existent user:The
FieldNotFoundError
is raised when a field has been provided but is not valid in that context, for example, creating a record and setting a field that does not exist on that record:Added scalar relational fields in create input
The type definitions for creating records now contain the scalar relational fields as well as an alternative to the longer form for connecting relational fields, for example:
With the above schema and an already existent
User
record. You can now create a newPost
record and connect it to the user by directly setting theauthor_id
field:This is provided as an alternative to this query:
Although the above query should be preferred as it also exposes other methods, such as creating the relational record inline or connecting based on other unique fields.
Prisma Upgrade
The internal Prisma binaries that Prisma Python makes use of have been upgraded from v3.11.1 to v3.13.0. For a full changelog see the v3.12.0 release notes and v3.13.0 release notes.
Minor Changes
New Contributors
Many thanks to @q0w and @leejayhsu for their first contributions!
Sponsors
This discussion was created from the release v0.6.5.
Beta Was this translation helpful? Give feedback.
All reactions