teamhide / fastapi-boilerplate

FastAPI boilerplate for real world production
987 stars 156 forks source link

What does Propagation for Transactional do? #15

Closed mastercoms closed 1 year ago

mastercoms commented 1 year ago

I wasn't able to find usages of it, what is its intended purpose?

teamhide commented 1 year ago

@Transactional() decorator is used to group multiple database operations into one. It acts like Django's @transaction.atomic. If you look at the source of the decorator, you can see that it executes commit or rollback depending on the situation. Therefore, users do not have to use explicit commit and rollback.

mastercoms commented 1 year ago

I get that, but I also see that it has a propagation parameter which I did not understand, it's an enum of REQUIRED and REQUIRED_NEW. What does this do, when should I use one or the other?

teamhide commented 1 year ago

I'm sorry for confusing. That parameter has been removed in the latest commit.