Skip to content

Commit ff9d67f

Browse files
committed
a little hack in the orm so that events work
1 parent 7706833 commit ff9d67f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/allocation/adapters/orm.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from sqlalchemy import (
2-
Table, MetaData, Column, Integer, String, Date,
3-
ForeignKey
2+
Table, MetaData, Column, Integer, String, Date, ForeignKey,
3+
event,
44
)
55
from sqlalchemy.orm import mapper, relationship
66

@@ -52,3 +52,8 @@ def start_mappers():
5252
mapper(model.Product, products, properties={
5353
'batches': relationship(batches_mapper)
5454
})
55+
56+
@event.listens_for(model.Product, 'load')
57+
def receive_load(product, _):
58+
product.events = []
59+

0 commit comments

Comments
 (0)