@@ -797,14 +797,12 @@ def _add_common_extend_steps_to_queue(self, md_template, conn_handler,
797
797
existing_samples = curr_samples .intersection (sample_ids )
798
798
new_samples = set (sample_ids ).difference (existing_samples )
799
799
800
- # Check if we are adding new columns
800
+ # Check if we are adding new columns, by getting all the columns from
801
+ # the database
801
802
table_name = self ._table_name (self ._id )
802
- # Get the required columns from the DB
803
803
db_cols = get_table_cols (self ._table , conn_handler )
804
- # Remove the sample_id and _id_column columns
805
804
db_cols .remove ('sample_id' )
806
805
db_cols .remove (self ._id_column )
807
- # Get the columns from the dynamic table and do the union with the db
808
806
curr_cols = set (
809
807
get_table_cols (table_name , conn_handler )).union (db_cols )
810
808
headers = md_template .keys ().tolist ()
@@ -867,6 +865,10 @@ def _add_common_extend_steps_to_queue(self, md_template, conn_handler,
867
865
values = as_python_types (md_template , db_cols )
868
866
values .insert (0 , new_samples )
869
867
values .insert (0 , [self ._id ] * num_samples )
868
+ # psycopg2 requires a list of tuples, in which each tuple is a
869
+ # tuple of values to use in the string formatting of the query. We
870
+ # have all the values in different lists (but in the same order) so
871
+ # use zip to create the list of tuples that psycopg2 requires.
870
872
values = [v for v in zip (* values )]
871
873
sql = """INSERT INTO qiita.{0} ({1}, sample_id, {2})
872
874
VALUES (%s, %s, {3})""" .format (
0 commit comments