BeanieODM / beanie

Asynchronous Python ODM for MongoDB
http://beanie-odm.dev/
Apache License 2.0
1.9k stars 201 forks source link

[BUG]before_event bug #902

Closed CAPITAINMARVEL closed 1 month ago

CAPITAINMARVEL commented 3 months ago

class Sample(Document): num: int name: str version: int = 0

@before_event(Update)
def increase_version(self):
    self.version += 1

doc = await Sample.find_one() await doc.inc({Sample.num: 1})

i looked in database num increase so its clearly updated but the versioning is never changing

CAPITAINMARVEL commented 3 months ago

its because in update it only update with args from the query itself but the action event doesnt it it

roman-right commented 2 months ago

Hi @CAPITAINMARVEL , Unfortunately it would be tricky and not explicit enough to add an addition set step to the update query for this case

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity.

github-actions[bot] commented 1 month ago

This issue was closed because it has been stalled for 14 days with no activity.