diff --git a/tabellio/pcfdb/sync.py b/tabellio/pcfdb/sync.py index 5a3a606..b05b27d 100644 --- a/tabellio/pcfdb/sync.py +++ b/tabellio/pcfdb/sync.py @@ -951,9 +951,10 @@ class SyncFromPcfDbView(BrowserView): where_ts = '' if timestamp: - where_ts = cursor.mogrify('''AND EXISTS (SELECT ts FROM t_histoline + where_ts = cursor.mogrify('''AND (EXISTS (SELECT ts FROM t_histoline WHERE idhisto = t_histo.id - AND ts > %s)''', (timestamp,)) + AND ts > %s) + OR t_histo.ts > %s)''', (timestamp, timestamp)) ### Handle t_dossiers cursor.execute('''SELECT t_histo.id, t_histo.st, t_histo.type, @@ -1023,9 +1024,10 @@ class SyncFromPcfDbView(BrowserView): ### Handle t_qx where_ts = '' if timestamp: - where_ts = cursor.mogrify('''AND EXISTS (SELECT ts FROM t_histoline + where_ts = cursor.mogrify('''AND (EXISTS (SELECT ts FROM t_histoline WHERE idhisto = t_histo.id - AND ts > %s)''', (timestamp,)) + AND ts > %s) + OR t_histo.ts > %s)''', (timestamp, timestamp)) cursor.execute('''SELECT t_histo.id, t_histo.st, t_histo.type, t_histo.sess, t_histo.no, t_histo.intit, t_histo.auteurs,