Skip to content

Commit dfaa46a

Browse files
committed
alternative: isolation=SERIALIZABLE [chapter_07_aggregate_ends]
1 parent bdd3d90 commit dfaa46a

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/allocation/adapters/repository.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,4 @@ def add(self, product):
2020
self.session.add(product)
2121

2222
def get(self, sku):
23-
return (
24-
self.session.query(model.Product)
25-
.filter_by(sku=sku)
26-
.with_for_update()
27-
.first()
28-
)
23+
return self.session.query(model.Product).filter_by(sku=sku).first()

src/allocation/service_layer/unit_of_work.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def rollback(self):
3030
DEFAULT_SESSION_FACTORY = sessionmaker(
3131
bind=create_engine(
3232
config.get_postgres_uri(),
33+
isolation_level="REPEATABLE READ",
3334
)
3435
)
3536

0 commit comments

Comments
 (0)