convert enumerate/generator into list before checking it't not empty (#32259)
This commit is contained in:
parent
0ef61ec694
commit
f628a6b6fd
|
@ -402,8 +402,11 @@ CREATE TABLE public.dates AS (SELECT
|
|||
ids = range(next_id, next_id + len(to_insert))
|
||||
labels = zip(ids, to_insert)
|
||||
|
||||
if labels:
|
||||
if labels is not None:
|
||||
# turn enumerate generator object into a proper list
|
||||
labels = list(labels)
|
||||
|
||||
if labels:
|
||||
tmpl = ', '.join(['(%s, %s)'] * len(labels))
|
||||
query_str = 'INSERT INTO {name} (id, label) VALUES %s' % tmpl
|
||||
self.ex(query_str, ctx={'name': name}, vars=list(itertools.chain(*labels)))
|
||||
|
|
Loading…
Reference in New Issue