misc: fix insertion in previously empty table (#31655)

This commit is contained in:
Frédéric Péters 2019-03-29 17:00:03 +01:00
parent 084b0d06b4
commit 25100cf7bd
1 changed files with 1 additions and 1 deletions

View File

@ -388,7 +388,7 @@ CREATE TABLE public.dates AS (SELECT
labels = None
if to_insert:
self.ex('SELECT MAX(id) FROM {name}', ctx={'name': name})
next_id = self.cur.fetchone()[0] + 1
next_id = (self.cur.fetchone()[0] or 0) + 1
ids = range(next_id, next_id + len(to_insert))
labels = zip(ids, to_insert)