Description
Hello.
Sorry if my question seems naive or if I missed something from the book. But I have difficulty understanding how the allocation is really committed to the db level. It is the only thing I have difficulty to understand in your book that is very interesting.
If I used the last version of the code (on master):
- When the
Allocate
command is raise, the allocate handler is called and theproduct.allocate
method is called. - The
product.allocate
method from the domain select a batch and call the corresponding batch method is called. - In the batch model, we only add the
OrderLine
to the_allocations
set.
This code should persist the added OrderLine
so, in order to commit this change, I guess that it is SQLAlchemy mapping magic that ensures the persistence of this change? Is it correct?
If so, I have another question. This behavior rely on some SQLAlchemy black magic. If I want to avoid them and did not use the mapper, to have an explicit committing line, I am not sure how I should implement it. Where update generated by the domain model should be added? Domain model does not have any direct link to the underlying repository used.
Basically, if I used raw SQL or basic sqlalchemy core api (without mapper), where model update sql statement should be added in the code base?
Thank you!