]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
MAINT: cleanup the lasts of datetime.utcnow()
authorBrigitta Sipőcz <bsipocz@gmail.com>
Tue, 13 Aug 2024 23:06:10 +0000 (16:06 -0700)
committerBrigitta Sipőcz <bsipocz@gmail.com>
Tue, 13 Aug 2024 23:14:37 +0000 (16:14 -0700)
examples/extending_query/temporal_range.py
lib/sqlalchemy/orm/events.py
test/orm/test_relationship_criteria.py

index 50cbb6645919f53c7855526ee2efa65662f1b7d8..e7bde15af29647e74d78eb5e671d3c12046b3f10 100644 (file)
@@ -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
     )
 
 
index e4126f41054781c5f4b6906c8103da4c4e733c3a..515194474981cd7c7fc47bdbe30b419ff9e502a0 100644 (file)
@@ -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
index 96c178e5e22ec05aedcbbd3902c646f77b407e3f..a603997e3c6e99b740528f9e4651c2b76e968580 100644 (file)
@@ -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