From: Brigitta Sipőcz Date: Tue, 13 Aug 2024 23:06:10 +0000 (-0700) Subject: MAINT: cleanup the lasts of datetime.utcnow() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92fd1395a140f4a5155b18029a39ad6091022606;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git MAINT: cleanup the lasts of datetime.utcnow() --- diff --git a/examples/extending_query/temporal_range.py b/examples/extending_query/temporal_range.py index 50cbb66459..e7bde15af2 100644 --- a/examples/extending_query/temporal_range.py +++ b/examples/extending_query/temporal_range.py @@ -23,7 +23,7 @@ class HasTemporal: """Mixin that identifies a class as having a timestamp column""" timestamp = Column( - DateTime, default=datetime.datetime.utcnow, nullable=False + DateTime, default=datetime.datetime.now(datetime.UTC), nullable=False ) diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py index e4126f4105..5151944749 100644 --- a/lib/sqlalchemy/orm/events.py +++ b/lib/sqlalchemy/orm/events.py @@ -3135,7 +3135,7 @@ class QueryEvents(event.Events[Query[Any]]): entity = desc['entity'] query = query.filter(entity.deleted == False) - update_context.values['timestamp'] = datetime.utcnow() + update_context.values['timestamp'] = datetime.datetime.now(datetime.UTC) return query The ``.values`` dictionary of the "update context" object can also diff --git a/test/orm/test_relationship_criteria.py b/test/orm/test_relationship_criteria.py index 96c178e5e2..a603997e3c 100644 --- a/test/orm/test_relationship_criteria.py +++ b/test/orm/test_relationship_criteria.py @@ -1661,7 +1661,7 @@ class TemporalFixtureTest(testing.fixtures.DeclarativeMappedTest): """Mixin that identifies a class as having a timestamp column""" timestamp = Column( - DateTime, default=datetime.datetime.utcnow, nullable=False + DateTime, default=datetime.datetime.now(datetime.UTC), nullable=False ) cls.HasTemporal = HasTemporal