diff roundup/backends/sessions_rdbms.py @ 6803:db437dd13ed5

set method doesn't include user set timestamp if update set() is supposed to update the record with the key if it already exists. It does update the value marshalled data blob. However it doesn't update the timestamp column for rdbms tables if provided. This change updates the x_time column with the provided __timestamp or preserves the original timestamp.
author John Rouillard <rouilj@ieee.org>
date Mon, 25 Jul 2022 15:07:32 -0400
parents 883c9e90b403
children 375d40a9e730
line wrap: on
line diff
--- a/roundup/backends/sessions_rdbms.py	Mon Jul 25 15:02:30 2022 -0400
+++ b/roundup/backends/sessions_rdbms.py	Mon Jul 25 15:07:32 2022 -0400
@@ -60,19 +60,27 @@
         c = self.cursor
         n = self.name
         a = self.db.arg
-        c.execute('select %s_value from %ss where %s_key=%s'%(n, n, n, a),
+        c.execute('select %s_value, %s_time from %ss where %s_key=%s'% \
+                  (n, n, n, n, a),
             (infoid,))
         res = c.fetchone()
         if res:
             values = eval(res[0])
+            timestamp = res[1]
         else:
             values = {}
         values.update(newvalues)
+        if res:
+            if '__timestamp' in newvalues:
+                try:
+                    # __timestamp must be representable as a float. Check it.
+                    timestamp = float(newvalues['__timestamp'])
+                except ValueError:
+                    pass
 
-        if res:
-            sql = 'update %ss set %s_value=%s where %s_key=%s'%(n, n,
-                a, n, a)
-            args = (repr(values), infoid)
+            sql = ('update %ss set %s_value=%s, %s_time=%s '
+                       'where %s_key=%s'%(n, n, a, n, a, n, a))
+            args = (repr(values), timestamp, infoid)
         else:
             if '__timestamp' in newvalues:
                 try:

Roundup Issue Tracker: http://roundup-tracker.org/