From f8cf2a8a8cce414053d0634233e093080c4d37d2 Mon Sep 17 00:00:00 2001
From: godp21 <godp21@inf.ufpr.br>
Date: Thu, 1 Sep 2022 10:30:17 -0300
Subject: [PATCH] updating insert functions

---
 database/actions.py        | 1 +
 database/database_table.py | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/database/actions.py b/database/actions.py
index ec5302f..8563824 100644
--- a/database/actions.py
+++ b/database/actions.py
@@ -53,6 +53,7 @@ def temporary_data(connection, file_name, table, year, offset=2,
     table.populate_temporary(ttable, file_name, header, year, delimiters, null, offset, bind=connection)
 
     table.apply_derivatives(ttable, ttable.columns.keys(), year, bind=connection)
+
     table.add_pk_to_temporary(ttable, bind=connection)
 
     return ttable
diff --git a/database/database_table.py b/database/database_table.py
index 8d0c638..67aee66 100644
--- a/database/database_table.py
+++ b/database/database_table.py
@@ -908,10 +908,13 @@ class DatabaseTable(Table):
         '''
         if bind is None:
             bind = self.metadata.bind
-
+		
         for original in columns:
             self._resolv_derivative(original, year)
 
+        if (len(self._derivatives) == 0):
+            return;
+
         max_level = max([self._derivatives[d]['level'] for d in self._derivatives])
 
         for i in range(1, max_level + 1):
-- 
GitLab