diff --git a/dataset/table.py b/dataset/table.py index 45600ff..119d155 100644 --- a/dataset/table.py +++ b/dataset/table.py @@ -132,7 +132,8 @@ class Table(object): sync_row = {} for row in rows: # Only get non-existing columns. - for key in [k for k in row.keys() if k not in sync_row.keys()]: + sync_keys = list(sync_row.keys()) + for key in [k for k in row.keys() if k not in sync_keys]: # Get a sample of the new column(s) from the row. sync_row[key] = row[key] self._sync_columns(sync_row, ensure, types=types) @@ -197,7 +198,9 @@ class Table(object): columns = [] for index, row in enumerate(rows): chunk.append(row) - columns = [col for col in row.keys() if col not in columns] + for col in row.keys(): + if col not in columns: + columns.append(col) # bindparam requires names to not conflict (cannot be "id" for id) for key in keys: