comparison 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
comparison
equal deleted inserted replaced
6802:044dcf3608a2 6803:db437dd13ed5
58 column in the database. 58 column in the database.
59 """ 59 """
60 c = self.cursor 60 c = self.cursor
61 n = self.name 61 n = self.name
62 a = self.db.arg 62 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),
64 (infoid,)) 65 (infoid,))
65 res = c.fetchone() 66 res = c.fetchone()
66 if res: 67 if res:
67 values = eval(res[0]) 68 values = eval(res[0])
69 timestamp = res[1]
68 else: 70 else:
69 values = {} 71 values = {}
70 values.update(newvalues) 72 values.update(newvalues)
73 if res:
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
71 80
72 if res: 81 sql = ('update %ss set %s_value=%s, %s_time=%s '
73 sql = 'update %ss set %s_value=%s where %s_key=%s'%(n, n, 82 'where %s_key=%s'%(n, n, a, n, a, n, a))
74 a, n, a) 83 args = (repr(values), timestamp, infoid)
75 args = (repr(values), infoid)
76 else: 84 else:
77 if '__timestamp' in newvalues: 85 if '__timestamp' in newvalues:
78 try: 86 try:
79 # __timestamp must be represntable as a float. Check it. 87 # __timestamp must be represntable as a float. Check it.
80 timestamp = float(newvalues['__timestamp']) 88 timestamp = float(newvalues['__timestamp'])

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