Skip to content

Commit

Permalink
fixes after weird merge
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed Nov 17, 2023
1 parent c56017d commit c59253f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions modelbaker/dbconnector/gpkg_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
import re
import sqlite3
import uuid

import qgis.utils
from qgis.core import Qgis
Expand Down Expand Up @@ -881,11 +882,13 @@ def create_basket(self, dataset_tid, topic, tilitid_value=None):
).format(topic, fetch_and_increment_feedback)
if not tilitid_value:
# default value
tilitid_value = f"'uuid.uuid4()'"
tilitid_value = f"'{uuid.uuid4()}'"
elif not tilitid_value.isnumeric():
tilitid_value = f"'{tilitid_value}'"
cursor.execute(
"""
INSERT INTO {basket_table} ({tid_name}, dataset, topic, {tilitid_name}, attachmentkey )
VALUES ({next_id}, {dataset_tid}, '{topic}', '{uuid}', 'modelbaker')
VALUES ({next_id}, {dataset_tid}, '{topic}', {tilitid}, 'modelbaker')
""".format(
tid_name=self.tid,
tilitid_name=self.tilitid,
Expand Down
8 changes: 5 additions & 3 deletions modelbaker/dbconnector/mssql_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,14 +946,14 @@ def get_topics_info(self):
cur = self.conn.cursor()
cur.execute(
"""
SELECT DISTINCT PARSENAME(cn.iliname,1) as model,
SELECT DISTINCT PARSENAME(cn.iliname,3) as model,
PARSENAME(cn.iliname,2) as topic,
ma.attr_value as bid_domain
FROM {schema}.t_ili2db_classname as cn
JOIN {schema}.t_ili2db_table_prop as tp
ON cn.sqlname = tp.tablename
LEFT JOIN {schema}.t_ili2db_meta_attrs as ma
ON CONCAT(PARSENAME(cn.iliname,1),'.',PARSENAME(cn.iliname,2)) = ma.ilielement AND ma.attr_name = 'ili2db.ili.bidDomain'
ON CONCAT(PARSENAME(cn.iliname,3),'.',PARSENAME(cn.iliname,2)) = ma.ilielement AND ma.attr_name = 'ili2db.ili.bidDomain'
WHERE PARSENAME(cn.iliname,3) != '' and tp.setting != 'ENUM'
""".format(
schema=self.schema
Expand Down Expand Up @@ -984,10 +984,12 @@ def create_basket(self, dataset_tid, topic, tilitid_value=None):
if not tilitid_value:
# default value
tilitid_value = "NEWID()"
elif not tilitid_value.isnumeric():
tilitid_value = f"'{tilitid_value}'"
cur.execute(
"""
INSERT INTO {schema}.{basket_table} ({tid_name}, dataset, topic, {tilitid_name}, attachmentkey )
VALUES (NEXT VALUE FOR {schema}.{sequence}, {dataset_tid}, '{topic}', NEWID(), 'modelbaker')
VALUES (NEXT VALUE FOR {schema}.{sequence}, {dataset_tid}, '{topic}', {tilitid}, 'modelbaker')
""".format(
schema=self.schema,
sequence="t_ili2db_seq",
Expand Down
6 changes: 4 additions & 2 deletions modelbaker/dbconnector/pg_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,13 +1020,15 @@ def create_basket(self, dataset_tid, topic, tilitid_value=None):
topic
)
try:
if tilitid_value == None:
if not tilitid_value:
# default value
tilitid_value = "uuid_generate_v4()"
elif not tilitid_value.isnumeric():
tilitid_value = f"'{tilitid_value}'"
cur.execute(
"""
INSERT INTO {schema}.{basket_table} ({tid_name}, dataset, topic, {tilitid_name}, attachmentkey )
VALUES (nextval('{schema}.{sequence}'), {dataset_tid}, '{topic}', uuid_generate_v4(), 'modelbaker')
VALUES (nextval('{schema}.{sequence}'), {dataset_tid}, '{topic}', {tilitid}, 'modelbaker')
""".format(
schema=self.schema,
sequence="t_ili2db_seq",
Expand Down

0 comments on commit c59253f

Please sign in to comment.