Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to get back the next sequence value #76

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modelbaker/dbconnector/db_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions modelbaker/dbconnector/gpkg_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions modelbaker/dbconnector/mssql_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions modelbaker/dbconnector/pg_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions modelbaker/iliwrapper/ili2dbtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Loading