From b0e00e919ef62a826dfadb07166e3938d0def385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 11 Sep 2016 11:55:47 +0200 Subject: [PATCH] Fix migration from days to overdue It is the overdue column that must be updated. And as the table can be empty, it is not possible to iterate over the cursor because it raise the exception "psycopg2.ProgrammingError: no results to fetch" so it must iterate over the fetchall result. --- dunning.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dunning.py b/dunning.py index f4b910751d..78e8e7e1ac 100644 --- a/dunning.py +++ b/dunning.py @@ -48,10 +48,10 @@ class Level(ModelSQL, ModelView): if table.column_exist('days'): cursor.execute(*sql_table.select(sql_table.id, sql_table.days, where=sql_table.days != Null)) - for id_, days in cursor: + for id_, days in cursor.fetchall(): overdue = datetime.timedelta(days) cursor.execute(*sql_table.update( - [sql_table.days_duration], + [sql_table.overdue], [overdue], where=sql_table.id == id_)) table.drop_column('days')