Skip to content

Commit 3574031

Browse files
authored
prepare 0.25 release (#1662)
1 parent 853caad commit 3574031

2 files changed

Lines changed: 91 additions & 1 deletion

File tree

docs/releases.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,95 @@
11
# Release notes
22

3+
## 0.25.0
4+
5+
### ⚡ Performance
6+
7+
A broad performance pass across model construction, row hydration, relation
8+
resolution, alias lookups, and result merging — combining per-class caching,
9+
lazy initialization of relation machinery, and porting the hottest helpers to
10+
Rust via the new required [`ormar-utils`](https://pypi.org/project/ormar-utils/)
11+
dependency. End-to-end speedups vs 0.24.0 range from ~12 % on `select_related`,
12+
through ~30 % on `iterate` and `first`, to ~60 - 80 % on initialization of models, and up to x2.5 speedup in getting `all`.
13+
14+
### ✨ Features
15+
16+
* Add `flatten_fields()` queryset method and `model_dump(flatten_fields=...)` /
17+
`model_dump(flatten_all=True)` arguments to render related models as their
18+
primary key value instead of nested dicts — see
19+
[docs](./queries/select-columns.md#flatten_fields)
20+
[#1641](https://github.com/collerek/ormar/pull/1641)
21+
22+
```python
23+
cars = await Car.objects.flatten_fields("manufacturer").all()
24+
assert cars[0].model_dump() == {"id": 1, "name": "Corolla", "manufacturer": 1} # Note the id 1 and not the nested model
25+
26+
car.model_dump(flatten_all=True)
27+
car.model_dump(flatten_fields={"manufacturer": ...})
28+
```
29+
30+
* Add **proxy model inheritance** (`OrmarConfig(proxy=True)`) — child class
31+
shares the parent's table and only adds methods / computed fields / a custom
32+
`queryset_class` — thanks @SepehrBazyar — see
33+
[docs](./models/inheritance.md#proxy-models)
34+
[#760](https://github.com/collerek/ormar/pull/760)
35+
36+
```python
37+
class User(Human):
38+
ormar_config = base_ormar_config.copy(proxy=True)
39+
40+
def full_name(self) -> str:
41+
return f"{self.first_name} {self.last_name}"
42+
```
43+
44+
* Add per-table `schema=` support on `OrmarConfig` so models can live in
45+
non-default database schemas (PostgreSQL full, MySQL with caveats, SQLite
46+
not supported for cross-schema FKs) — thanks @hk3dva — see
47+
[docs](./models/index.md#schemas)
48+
[#1493](https://github.com/collerek/ormar/pull/1493)
49+
* Add Python-style indexing and slicing on `QuerySet` — `Track.objects[:10]`,
50+
`Track.objects[-5:]`, `Track.objects[5]` — thanks @SepehrBazyar — see
51+
[docs](./queries/pagination-and-rows-number.md#slicing-with-__getitem__)
52+
[#765](https://github.com/collerek/ormar/pull/765)
53+
* Add `nulls_ordering` argument to `.asc()` / `.desc()` (`ormar.NullsOrdering.FIRST`
54+
/ `LAST`) with MySQL emulation — thanks @SepehrBazyar — see
55+
[docs](./queries/filter-and-sort.md#controlling-null-placement-with-nulls_ordering)
56+
[#769](https://github.com/collerek/ormar/pull/769)
57+
* Allow filtering by a foreign-key column directly (`Book.objects.filter(Book.author == 5)`
58+
or with a model instance) without adding a JOIN — thanks @djalouehz — see
59+
[docs](./queries/filter-and-sort.md#filtering-by-foreign-key-columns)
60+
[#854](https://github.com/collerek/ormar/pull/854)
61+
* Add `through_relation_nullable` and `through_reverse_relation_nullable` to
62+
`ormar.ManyToMany` to enforce `NOT NULL` on the through table's FK columns —
63+
thanks @evadev-eva — see
64+
[docs](./relations/many-to-many.md#making-through-relation-columns-non-nullable)
65+
[#852](https://github.com/collerek/ormar/pull/852)
66+
* Add `last()` / `last_or_none()` on `QuerySet` and expose `first_or_none()` /
67+
`last()` / `last_or_none()` on `QuerysetProxy` — see
68+
[docs](./queries/pagination-and-rows-number.md)
69+
[#765](https://github.com/collerek/ormar/pull/765)
70+
* Forward unrecognized `**kwargs` from `ormar.ForeignKey` / `ormar.ManyToMany`
71+
to `BaseField` — fixes `comment=` (and other `BaseField` kwargs) being
72+
silently dropped on relation fields — thanks @booqoffsky
73+
[#1239](https://github.com/collerek/ormar/pull/1239)
74+
75+
### 🐛 Fixes
76+
77+
* Clearing a nullable `ForeignKey` with `instance.fk = None` now also clears the
78+
in-memory relation, so subsequent reads return `None` without a reload —
79+
originally @amit12297, rebased — see
80+
[docs](./relations/foreign-key.md)
81+
[#1230](https://github.com/collerek/ormar/pull/1230)
82+
* Drop the unnecessary post-`INSERT` pk reload in `save()`, and raise
83+
`ModelPersistenceError` on backends that cannot return a generated pk
84+
(Oracle MySQL with non-`AUTO_INCREMENT` server-default pk) instead of
85+
silently assigning the row count to `Model.pk` — thanks @vnicolaichuk
86+
[#919](https://github.com/collerek/ormar/pull/919)
87+
* `SelectAction` aggregate identifiers now go through `sqlalchemy.column()`
88+
instead of string concatenation
89+
[#1637](https://github.com/collerek/ormar/pull/1637)
90+
* Fix the `mkdocs` deployment workflow
91+
[#1638](https://github.com/collerek/ormar/pull/1638)
92+
393
## 0.24.0
494

595
### ✨ Features

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "ormar"
33

44
[tool.poetry]
55
name = "ormar"
6-
version = "0.24.0"
6+
version = "0.25.0"
77
description = "An async ORM with fastapi in mind and pydantic validation."
88
authors = ["Radosław Drążkiewicz <collerek@gmail.com>"]
99
license = "MIT"

0 commit comments

Comments
 (0)