Throw invalid column count errors where the insert statement is executed
authorKarl O. Pinc <kop@karlpinc.com>
Sun, 23 Jun 2024 02:03:57 +0000 (21:03 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Sun, 23 Jun 2024 02:03:57 +0000 (21:03 -0500)
Psycopg 3 throws a generic ProgramimgError, so core.py has trouble
reporting the problem.  Perhaps this can be solved by creating a
generic PreparedStmt class at the core level, but this works for
the moment.

src/pgwui_bulk_upload/views/bulk_upload.py

index 633fc186dacead4c4ef925bf38b8113e08a99896..9dd250a2023ffed621747d9334ce05208aad4ffa 100644 (file)
@@ -47,6 +47,7 @@ from pgwui_core.core import (
 from pgwui_upload_core.views.upload import (
     BaseTableUploadHandler,
     UploadCoreInitialPost,
+    match_insert_to_dataline,
     set_upload_response,
 )
 
@@ -114,7 +115,9 @@ class SaveBulkLine(DataLineProcessor, ParameterExecutor):
         filepath = data.filepath
         try:
             udl = thunk()
-            self.param_execute(self.insert_map[filepath], udl)
+            insert_stmt = self.insert_map[filepath]
+            match_insert_to_dataline(udl, insert_stmt, source_file=filepath)
+            self.param_execute(insert_stmt.stmt, udl)
         except (core_ex.DataLineError, core_ex.DBError) as exp:
             relation = data.relation
             raise exp.color(map_description(filepath, relation),