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.
This commit is contained in:
Cédric Krier committed 2016-09-11 11:55:47 +02:00
1 parent c55ad9a3e4
commit b0e00e919e
1 file changed
+2 -2
+2 -2
View File
@@ -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')