Skip to content

Commit 79fe2da

Browse files
committed
select for update is one approach [with_for_update]
1 parent 49e8757 commit 79fe2da

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/allocation/repository.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@ def add(self, product):
2222
self.session.add(product)
2323

2424
def get(self, sku):
25-
print(sku, type(sku))
26-
return self.session.query(model.Product).filter_by(sku=sku).first()
25+
return self.session.query(model.Product) \
26+
.filter_by(sku=sku) \
27+
.with_for_update() \
28+
.first()

0 commit comments

Comments
 (0)