Skip to content

Commit 98b92e9

Browse files
committed
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.
1 parent 2bf2f52 commit 98b92e9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

roundup/backends/sessions_rdbms.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,27 @@ def set(self, infoid, **newvalues):
6060
c = self.cursor
6161
n = self.name
6262
a = self.db.arg
63-
c.execute('select %s_value from %ss where %s_key=%s'%(n, n, n, a),
63+
c.execute('select %s_value, %s_time from %ss where %s_key=%s'% \
64+
(n, n, n, n, a),
6465
(infoid,))
6566
res = c.fetchone()
6667
if res:
6768
values = eval(res[0])
69+
timestamp = res[1]
6870
else:
6971
values = {}
7072
values.update(newvalues)
71-
7273
if res:
73-
sql = 'update %ss set %s_value=%s where %s_key=%s'%(n, n,
74-
a, n, a)
75-
args = (repr(values), infoid)
74+
if '__timestamp' in newvalues:
75+
try:
76+
# __timestamp must be representable as a float. Check it.
77+
timestamp = float(newvalues['__timestamp'])
78+
except ValueError:
79+
pass
80+
81+
sql = ('update %ss set %s_value=%s, %s_time=%s '
82+
'where %s_key=%s'%(n, n, a, n, a, n, a))
83+
args = (repr(values), timestamp, infoid)
7684
else:
7785
if '__timestamp' in newvalues:
7886
try:

0 commit comments

Comments
 (0)