Replies: 1 comment 3 replies
-
|
Hi! Here's an example of how this could be implemented. This library allows you to manage sessions and transactions without using DI. You might want to consider using it in conjunction with litestar. Now you can write your own middleware, following the example of the ready-made one for FastApi. Or you can wait a little while until I finish it and publish it: krylosov-aa/context-async-sqlalchemy#7 If you still want to stick with di, litestar should definitely provide the ability to replace dependencies. Fastapi has similar dependencies, and I replaced the dependency in conftest in fixture with one that always rolls back. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm using
SQLAlchemyInitPluginin my app but struggle to implement a "rollback recipe" like this one for SQLAlchemy.Is there an example somewhere on how to do this or does someone have some tips?
From what I understand: to implement the recipe a connection must be started before the specific app test runs so that the next database session injected can be bound to that connection. After validating the return statement the transaction can be rolled back to the save point. However, since the plugin is quite complex/nested to an outsider I find it difficult to identify the spot where I'd have to insert an override. And I'm not sure if it's so difficult because I'm overlooking something or because it's just not possible.
Beta Was this translation helpful? Give feedback.
All reactions