Skip to content

Commit dea7074

Browse files
committed
README.md review
1 parent ec589d5 commit dea7074

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ The classes provide some common use methods:
195195

196196
* `get`: Retrieve a model by identifier
197197
* `save`: Persist a model
198-
* `save_many`: Persist multiple models in a single get_session
198+
* `save_many`: Persist multiple models in a single transaction
199199
* `delete`: Delete a model
200200
* `find`: Search for a list of models (basically an adapter for SELECT queries)
201201

@@ -215,11 +215,16 @@ using SQLAlchemy. It makes sense that the lifecycle of a `Session` follows the o
215215
This ensures the `Session` we use is isolated, and the same for all the operations we do with the
216216
same repository.
217217

218-
The consequence of these choices is we can't use SQLAlchemy lazy loading, so we need to make sure
219-
relationship are loaded eagerly. You can do this by:
218+
The session is automatically closed and reopen with each Repository operation, this make sure these
219+
operation are independent from each other.
220220

221-
* Setup your model/table relationships to always use always eager loading
222-
* Implement ad-hoc methods to deal with relationships as necessary
221+
These choices cause some consequences:
222+
* The operations that modify the database will reload the models from the DB, causing an additional
223+
SELECT query to be issued.
224+
* We can't use SQLAlchemy lazy loading, so we'll need to make sure relationship are always loaded eagerly,
225+
using either:
226+
* Setup your model/table relationships to always use always eager loading
227+
* Implement ad-hoc methods to deal with relationships as necessary
223228

224229
Also `AsyncSession` has [the same limitation on lazy loading](https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html#asyncio-orm-avoid-lazyloads)
225230
so it makes sense that the two repository implementations behave consistently.

0 commit comments

Comments
 (0)