Skip to content

Commit cb72b8a

Browse files
authored
F() supports referencing JSONField attributes & Release 0.25.1 (#1960)
* F() supports referencing JSONField attributes * Add support_json_attributes capability to Capabilities * Release 0.25.1
1 parent 58a2321 commit cb72b8a

File tree

14 files changed

+184
-168
lines changed

14 files changed

+184
-168
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Changelog
1010
0.25
1111
====
1212

13-
0.25.1 (unreleased)
13+
0.25.1
1414
------------------
1515
Changed
1616
^^^^^
@@ -19,6 +19,7 @@ Changed
1919
Added
2020
^^^^^
2121
- Add `no_key` parameter to `queryset.select_for_update`.
22+
- `F()` supports referencing JSONField attributes, e.g. `F("json_field__custom_field__nested_id")` (#1960)
2223

2324
0.25.0
2425
------

docs/expressions.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The NOT operation can be achieved using the negation operator (``~``):
5555
F Expression
5656
============
5757

58-
The ``F`` Expression represents a model field value and enables database operations on field values without loading them into Python memory. This is particularly useful for atomic operations.
58+
The ``F`` Expression represents a model field value and enables database operations on field values without loading them into Python memory.
5959

6060
Example of using F expressions for balance updates (this is just an example and such updates are not recommended for use in financial applications):
6161

@@ -89,6 +89,14 @@ F expressions can also be used in annotations:
8989
9090
data = await User.annotate(idp=F("id") + 1).values_list("id", "idp")
9191
92+
F expressions can also be used to reference JSON properties and array elements:
93+
94+
.. code-block:: python3
95+
96+
await User.annotate(attr=F("json_field__property")).values_list("id", "attr")
97+
await User.annotate(attr=F("json_field__arrayproperty__0")).values_list("id", "attr")
98+
99+
92100
Subquery
93101
========
94102

poetry.lock

Lines changed: 12 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "tortoise-orm"
3-
version = "0.25.0"
3+
version = "0.25.1"
44
description = "Easy async ORM for python, built with relations in mind"
55
authors = [{name="Andrey Bondar", email="[email protected]"}, {name="Nickolas Grigoriadis", email="[email protected]"}, {name="long2ice", email="[email protected]"}]
66
license = {text="Apache-2.0"}
@@ -11,7 +11,7 @@ include = ["CHANGELOG.rst", "LICENSE", "README.rst"]
1111
dynamic = [ "classifiers" ]
1212
requires-python = ">=3.9"
1313
dependencies = [
14-
"pypika-tortoise (>=0.6.0,<1.0.0); python_version < '4.0'",
14+
"pypika-tortoise (>=0.6.1,<1.0.0); python_version < '4.0'",
1515
"iso8601 (>=2.1.0,<3.0.0); python_version < '4.0'",
1616
"aiosqlite (>=0.16.0,<1.0.0)",
1717
"pytz",

0 commit comments

Comments
 (0)