Browse Source

Merge "Resolve SAWarning in Query.soft_delete()"

Zuul 2 months ago
parent
commit
5895d04fd8
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      oslo_db/sqlalchemy/orm.py

+ 3
- 3
oslo_db/sqlalchemy/orm.py View File

@@ -18,7 +18,6 @@
18 18
 
19 19
 from oslo_utils import timeutils
20 20
 import sqlalchemy.orm
21
-from sqlalchemy.sql.expression import literal_column
22 21
 
23 22
 from oslo_db.sqlalchemy import update_match
24 23
 
@@ -26,8 +25,9 @@ from oslo_db.sqlalchemy import update_match
26 25
 class Query(sqlalchemy.orm.query.Query):
27 26
     """Subclass of sqlalchemy.query with soft_delete() method."""
28 27
     def soft_delete(self, synchronize_session='evaluate'):
29
-        return self.update({'deleted': literal_column('id'),
30
-                            'updated_at': literal_column('updated_at'),
28
+        entity = self.column_descriptions[0]['entity']
29
+        return self.update({'deleted': entity.id,
30
+                            'updated_at': entity.updated_at,
31 31
                             'deleted_at': timeutils.utcnow()},
32 32
                            synchronize_session=synchronize_session)
33 33
 

Loading…
Cancel
Save