Merge pull request #376 from Remalloc/master

Remove all keys from values
This commit is contained in:
Friedrich Lindenberg 2021-07-29 15:49:56 +02:00 committed by GitHub
commit 41b7552df1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -228,14 +228,13 @@ class Table(object):
chunk = [] chunk = []
columns = [] columns = []
for index, row in enumerate(rows): for index, row in enumerate(rows):
chunk.append(row) columns.extend(col for col in row.keys() if (col not in columns) and (col not in keys))
for col in row.keys():
if col not in columns:
columns.append(col)
# bindparam requires names to not conflict (cannot be "id" for id) # bindparam requires names to not conflict (cannot be "id" for id)
for key in keys: for key in keys:
row["_%s" % key] = row[key] row["_%s" % key] = row[key]
row.pop(key)
chunk.append(row)
# Update when chunk_size is fulfilled or this is the last row # Update when chunk_size is fulfilled or this is the last row
if len(chunk) == chunk_size or index == len(rows) - 1: if len(chunk) == chunk_size or index == len(rows) - 1: