From a8d361454b1c5cac699f234c997f007822407960 Mon Sep 17 00:00:00 2001 From: SnoozeFreddo Date: Thu, 15 Feb 2024 04:19:14 +0100 Subject: [PATCH] chore: Timestampmixin remove eventlistener for onupdate --- sqlalchemy_utils/models.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sqlalchemy_utils/models.py b/sqlalchemy_utils/models.py index ca272d6a..58d4b5ad 100644 --- a/sqlalchemy_utils/models.py +++ b/sqlalchemy_utils/models.py @@ -23,14 +23,7 @@ class SomeModel(Base, Timestamp): """ created = sa.Column(sa.DateTime, default=datetime.utcnow, nullable=False) - updated = sa.Column(sa.DateTime, default=datetime.utcnow, nullable=False) - - -@sa.event.listens_for(Timestamp, 'before_update', propagate=True) -def timestamp_before_update(mapper, connection, target): - # When a model with a timestamp is updated; force update the updated - # timestamp. - target.updated = datetime.utcnow() + updated = sa.Column(sa.DateTime, default=datetime.utcnow, nullable=False, onupdate=datetime.utcnow) NOT_LOADED_REPR = ''