Make _timestamp numeric instead of datetime to work with XML-RPC and JSON-RPC
This commit is contained in:
1 parent
9922b401a7
commit
1503aa3112
2 files changed
+24
-14
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Make _timestamp numeric instead of datetime to work with XML-RPC and JSON-RPC
|
||||
* Add ir.trigger to trigger ModelStorage change
|
||||
* Add default value to Boolean fields at database level
|
||||
|
||||
|
||||
+23
-14
@@ -486,7 +486,10 @@ class ModelSQL(ModelStorage):
|
||||
if self._history and context.get('_datetime') and not table_query:
|
||||
in_max = 1
|
||||
table_query = '"' + self._table + '__history" AS '
|
||||
history_clause = ' AND (COALESCE(write_date, create_date) <= %s)'
|
||||
history_clause = (' AND (CAST(EXTRACT(EPOCH FROM '
|
||||
'COALESCE(write_date, create_date)) AS ' + \
|
||||
FIELDS['numeric'].sql_type(self.create_date)[1] + \
|
||||
') <= %s)')
|
||||
history_order = ' ORDER BY COALESCE(write_date, create_date) DESC'
|
||||
history_limit = cursor.limit_clause('', 1)
|
||||
history_args = [context['_datetime']]
|
||||
@@ -495,8 +498,10 @@ class ModelSQL(ModelStorage):
|
||||
if x != '_timestamp']
|
||||
if '_timestamp' in fields_pre:
|
||||
if not self.table_query(context):
|
||||
fields_pre2 += ['(COALESCE(write_date, create_date)) ' \
|
||||
'AS _timestamp']
|
||||
fields_pre2 += ['CAST(EXTRACT(EPOCH FROM '
|
||||
'(COALESCE(write_date, create_date))) AS ' + \
|
||||
FIELDS['numeric'].sql_type(self.create_date)[1] + \
|
||||
') AS _timestamp']
|
||||
|
||||
for i in range(0, len(ids), in_max):
|
||||
sub_ids = ids[i:i + in_max]
|
||||
@@ -755,10 +760,11 @@ class ModelSQL(ModelStorage):
|
||||
if context.get('_timestamp', False):
|
||||
for i in range(0, len(ids), cursor.IN_MAX):
|
||||
sub_ids = ids[i:i + cursor.IN_MAX]
|
||||
clause = '(id = %s AND ' \
|
||||
'(CASE WHEN write_date IS NOT NULL ' \
|
||||
'THEN write_date ELSE create_date END) ' \
|
||||
' > %s)'
|
||||
clause = ('(id = %s AND '
|
||||
'CAST(EXTRACT(EPOCH FROM '
|
||||
'COALESCE(write_date, create_date)) AS ' + \
|
||||
FIELDS['numeric'].sql_type(self.create_date)[1] + \
|
||||
') > %s)')
|
||||
args = []
|
||||
for i in sub_ids:
|
||||
if context['_timestamp'].get(self._name + ',' + str(i)):
|
||||
@@ -1000,10 +1006,11 @@ class ModelSQL(ModelStorage):
|
||||
if context.get('_timestamp', False):
|
||||
for i in range(0, len(ids), cursor.IN_MAX):
|
||||
sub_ids = ids[i:i + cursor.IN_MAX]
|
||||
clause = '(id = %s AND ' \
|
||||
'(CASE WHEN write_date IS NOT NULL ' \
|
||||
'THEN write_date ELSE create_date END) ' \
|
||||
' > %s)'
|
||||
clause = ('(id = %s AND '
|
||||
'CAST(EXTRACT(EPOCH FROM '
|
||||
'COALESCE(write_date, create_date)) AS ' + \
|
||||
FIELDS['numeric'].sql_type(self.create_date)[1] + \
|
||||
') > %s)')
|
||||
args = []
|
||||
for i in sub_ids:
|
||||
if context['_timestamp'].get(self._name + ',' + str(i)):
|
||||
@@ -1227,9 +1234,11 @@ class ModelSQL(ModelStorage):
|
||||
and (not getattr(x[1], 'translate', False) \
|
||||
and x[1]._type not in ('text', 'binary'))]
|
||||
if not self.table_query(context):
|
||||
select_fields += ['(COALESCE("' + self._table + '".write_date,'\
|
||||
'"' + self._table + '".create_date)) ' \
|
||||
'AS _timestamp']
|
||||
select_fields += ['CAST(EXTRACT(EPOCH FROM '
|
||||
'(COALESCE("' + self._table + '".write_date, '
|
||||
'"' + self._table + '".create_date))) AS ' + \
|
||||
FIELDS['numeric'].sql_type(self.create_date)[1] + \
|
||||
') AS _timestamp']
|
||||
query_str = cursor.limit_clause(
|
||||
'SELECT ' + ','.join(select_fields) + ' FROM ' + \
|
||||
' '.join(tables) + (qu1 and ' WHERE ' + qu1 or '') + \
|
||||
|
||||
Reference in new issue
Block a user