Skip to content

Commit 37e8abe

Browse files
committed
Add documentation about AsyncAttrs
1 parent 296465d commit 37e8abe

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/repository/repository.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,16 @@ using either approach:
9494

9595
Note that `AsyncSession` has [the same limitation on lazy loading](https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html#asyncio-orm-avoid-lazyloads),
9696
even when keeping the session opened, so it makes sense that the two Repository implementations behave consistently.
97+
98+
/// details | Lazy loading using `AsyncAttrs`
99+
100+
SQLAlchemy has recently added the `AsyncAttrs` model class mixin to allow lazy loading model attributes
101+
with `AsyncSession`, however having to `await` a model property introduce a coupling between the
102+
application logic and the storage layer.
103+
104+
This would mean the application logic has to know about the storage layer and make a distinction
105+
between sync and async models. This doesn't feel right, at least for now,
106+
therefore it's not enabled by default.
107+
108+
If you want to attempt lazy loading refer to [SQLAlchemy documentation](https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html#synopsis-orm)
109+
///

0 commit comments

Comments
 (0)