diff --git a/modelbaker/dbconnector/db_connector.py b/modelbaker/dbconnector/db_connector.py index d811e75..2a9fde6 100644 --- a/modelbaker/dbconnector/db_connector.py +++ b/modelbaker/dbconnector/db_connector.py @@ -344,6 +344,12 @@ def get_ili2db_sequence_value(self): """ return None + def get_next_ili2db_sequence_value(self): + """ + Increases and returns the value of the sequence used for the t_id + """ + return None + def set_ili2db_sequence_value(self, value): """ Resets the current value of the sequence used for the t_id diff --git a/modelbaker/dbconnector/gpkg_connector.py b/modelbaker/dbconnector/gpkg_connector.py index 1b90c33..f29cef4 100644 --- a/modelbaker/dbconnector/gpkg_connector.py +++ b/modelbaker/dbconnector/gpkg_connector.py @@ -1022,6 +1022,14 @@ def get_ili2db_sequence_value(self): return content[0] return None + def get_next_ili2db_sequence_value(self): + ( + status, + next_id, + fetch_and_increment_feedback, + ) = self._fetch_and_increment_key_object(self.tid) + return next_id + def set_ili2db_sequence_value(self, value): if self._table_exists("T_KEY_OBJECT"): try: diff --git a/modelbaker/dbconnector/mssql_connector.py b/modelbaker/dbconnector/mssql_connector.py index d1c595c..2cb76d0 100644 --- a/modelbaker/dbconnector/mssql_connector.py +++ b/modelbaker/dbconnector/mssql_connector.py @@ -1044,6 +1044,10 @@ def get_ili2db_settings(self): return result def get_ili2db_sequence_value(self): + # not implemented, return the next one + return self.get_next_ili2db_sequence_value() + + def get_next_ili2db_sequence_value(self): if self.schema: cur = self.conn.cursor() cur.execute( diff --git a/modelbaker/dbconnector/pg_connector.py b/modelbaker/dbconnector/pg_connector.py index 2319b87..0fec384 100644 --- a/modelbaker/dbconnector/pg_connector.py +++ b/modelbaker/dbconnector/pg_connector.py @@ -1099,6 +1099,22 @@ def get_ili2db_sequence_value(self): return content[0] return None + def get_next_ili2db_sequence_value(self): + + if self.schema: + cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor) + cur.execute( + """ + SELECT nextval('{schema}.{sequence}') + """.format( + schema=self.schema, sequence="t_ili2db_seq" + ) + ) + content = cur.fetchone() + if content: + return content[0] + return None + def set_ili2db_sequence_value(self, value): if self.schema: cur = self.conn.cursor() diff --git a/modelbaker/iliwrapper/ili2dbtools.py b/modelbaker/iliwrapper/ili2dbtools.py index ef559a4..54f198f 100644 --- a/modelbaker/iliwrapper/ili2dbtools.py +++ b/modelbaker/iliwrapper/ili2dbtools.py @@ -25,17 +25,17 @@ def get_tool_version(tool, db_ili_version): if db_ili_version == 3: return "3.11.3" else: - return "5.0.0" + return "5.0.1" elif tool == DbIliMode.ili2pg: if db_ili_version == 3: return "3.11.2" else: - return "5.0.0" + return "5.0.1" elif tool == DbIliMode.ili2mssql: if db_ili_version == 3: return "3.12.2" else: - return "5.0.0" + return "5.0.1" return "0"