From 68ecf08bb2e2809572500ad7982df642c042a23d Mon Sep 17 00:00:00 2001 From: signedav Date: Wed, 22 Nov 2023 17:07:12 +0100 Subject: [PATCH 1/3] function to get back the next sequence value --- modelbaker/dbconnector/db_connector.py | 6 ++++++ modelbaker/dbconnector/gpkg_connector.py | 8 ++++++++ modelbaker/dbconnector/mssql_connector.py | 4 ++++ modelbaker/dbconnector/pg_connector.py | 16 ++++++++++++++++ 4 files changed, 34 insertions(+) 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..5a90624 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_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() From b1a40a861ef2eebbf1e740e7878662abe42a4e25 Mon Sep 17 00:00:00 2001 From: signedav Date: Thu, 23 Nov 2023 08:36:47 +0100 Subject: [PATCH 2/3] fix recursion in mssql functions --- modelbaker/dbconnector/mssql_connector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modelbaker/dbconnector/mssql_connector.py b/modelbaker/dbconnector/mssql_connector.py index 5a90624..2cb76d0 100644 --- a/modelbaker/dbconnector/mssql_connector.py +++ b/modelbaker/dbconnector/mssql_connector.py @@ -1045,7 +1045,7 @@ def get_ili2db_settings(self): def get_ili2db_sequence_value(self): # not implemented, return the next one - return self.get_ili2db_sequence_value() + return self.get_next_ili2db_sequence_value() def get_next_ili2db_sequence_value(self): if self.schema: From a02af09258a11f207675f7f06c68793c237753fd Mon Sep 17 00:00:00 2001 From: signedav Date: Thu, 23 Nov 2023 09:41:20 +0100 Subject: [PATCH 3/3] bump ili2db 5.0.1 --- modelbaker/iliwrapper/ili2dbtools.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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"