You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/02/27 14:09:01 UTC

[GitHub] Fokko commented on a change in pull request #4773: [AIRFLOW-3767] Correct bulk insert function

Fokko commented on a change in pull request #4773: [AIRFLOW-3767] Correct bulk insert function
URL: https://github.com/apache/airflow/pull/4773#discussion_r260763896
 
 

 ##########
 File path: airflow/hooks/oracle_hook.py
 ##########
 @@ -199,12 +199,20 @@ def bulk_insert_rows(self, table, rows, target_fields=None, commit_every=5000):
             Default 5000. Set greater than 0. Set 1 to insert each row in each transaction
         :type commit_every: int
         """
+        if not rows:
+            raise ValueError("parameter rows could not be None or empty iterable")
         conn = self.get_conn()
         cursor = conn.cursor()
-        values = ', '.join(':%s' % i for i in range(1, len(target_fields) + 1))
-        prepared_stm = 'insert into {tablename} ({columns}) values ({values})'.format(
+        if target_fields:
+            columns = ', '.join(target_fields)
 
 Review comment:
   Maybe move this directly inside of the format? or give it a different name, I don't like overwriting variables :-)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services