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

CI Fixes and others #111

Merged
merged 7 commits into from
Oct 15, 2024
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
2 changes: 1 addition & 1 deletion .docker/docker-compose.gh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
- "POSTGRES_HOST_AUTH_METHOD=md5"

mssql:
image: mcr.microsoft.com/mssql/server:2019-CU11-ubuntu-20.04
image: mcr.microsoft.com/mssql/server:2019-CU28-ubuntu-20.04
environment:
ACCEPT_EULA: Y
SA_PASSWORD: <YourStrong!Passw0rd>
Expand Down
52 changes: 26 additions & 26 deletions modelbaker/dbconnector/gpkg_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ def _get_tables_info(self):
interlis_joins = """LEFT JOIN T_ILI2DB_TABLE_PROP p
ON p.tablename = s.name
AND p.tag = 'ch.ehi.ili2db.tableKind'
LEFT JOIN t_ili2db_table_prop alias
LEFT JOIN T_ILI2DB_TABLE_PROP alias
ON alias.tablename = s.name
AND alias.tag = 'ch.ehi.ili2db.dispName'
LEFT JOIN t_ili2db_classname c
LEFT JOIN T_ILI2DB_CLASSNAME c
ON s.name == c.sqlname
LEFT JOIN t_ili2db_attrname attrs
LEFT JOIN T_ILI2DB_ATTRNAME attrs
ON c.iliname = attrs.iliname """
try:
cursor.execute(
Expand Down Expand Up @@ -267,7 +267,7 @@ def _get_tables_info(self):
for record in filtered_records:
cursor.execute(
"""
PRAGMA table_info({})
PRAGMA table_info("{}")
""".format(
record["tablename"]
)
Expand Down Expand Up @@ -336,7 +336,7 @@ def get_fields_info(self, table_name):
cursor.execute(
"""
SELECT *
FROM t_ili2db_column_prop
FROM T_ILI2DB_COLUMN_PROP
WHERE tablename = ?;""",
(table_name,),
)
Expand All @@ -347,15 +347,15 @@ def get_fields_info(self, table_name):
cursor.execute(
"""
SELECT SqlName, IliName
FROM t_ili2db_attrname
FROM T_ILI2DB_ATTRNAME
WHERE owner = ?;""",
(table_name,),
)
else:
cursor.execute(
"""
SELECT SqlName, IliName
FROM t_ili2db_attrname
FROM T_ILI2DB_ATTRNAME
WHERE colowner = ?;""",
(table_name,),
)
Expand Down Expand Up @@ -463,7 +463,7 @@ def get_t_type_map_info(self, table_name):
cursor.execute(
"""
SELECT *
FROM t_ili2db_column_prop
FROM T_ILI2DB_COLUMN_PROP
WHERE tablename = ?
AND tag = 'ch.ehi.ili2db.types';""",
(table_name,),
Expand Down Expand Up @@ -508,8 +508,8 @@ def get_relations_info(self, filter_layer_list=[]):
# Get strength
cursor.execute(
"""SELECT META_ATTRS.attr_value as strength
FROM t_ili2db_attrname AS ATTRNAME
INNER JOIN t_ili2db_meta_attrs AS META_ATTRS
FROM T_ILI2DB_ATTRNAME AS ATTRNAME
INNER JOIN T_ILI2DB_META_ATTRS AS META_ATTRS
ON META_ATTRS.ilielement = ATTRNAME.iliname AND META_ATTRS.attr_name = 'ili2db.ili.assocKind'
WHERE ATTRNAME.sqlname = ? AND ATTRNAME.{colowner} = ? AND ATTRNAME.target = ?;
""".format(
Expand All @@ -529,8 +529,8 @@ def get_relations_info(self, filter_layer_list=[]):
# Get cardinality max
cursor.execute(
"""SELECT META_ATTRS.attr_value as cardinality_max
FROM t_ili2db_attrname AS ATTRNAME
INNER JOIN t_ili2db_meta_attrs AS META_ATTRS
FROM T_ILI2DB_ATTRNAME AS ATTRNAME
INNER JOIN T_ILI2DB_META_ATTRS AS META_ATTRS
ON META_ATTRS.ilielement = ATTRNAME.iliname AND META_ATTRS.attr_name = 'ili2db.ili.attrCardinalityMax'
WHERE ATTRNAME.sqlname = ? AND ATTRNAME.{colowner} = ? AND ATTRNAME.target = ?;
""".format(
Expand Down Expand Up @@ -561,14 +561,14 @@ def get_bags_of_info(self):
cursor.execute(
"""SELECT cprop.tablename as current_layer_name, cprop.columnname as attribute, cprop.setting as target_layer_name,
meta_attrs_cardinality_min.attr_value as cardinality_min, meta_attrs_cardinality_max.attr_value as cardinality_max
FROM t_ili2db_column_prop as cprop
LEFT JOIN t_ili2db_classname as cname
FROM T_ILI2DB_COLUMN_PROP as cprop
LEFT JOIN T_ILI2DB_CLASSNAME as cname
ON cname.sqlname = cprop.tablename
LEFT JOIN t_ili2db_meta_attrs as meta_attrs_array
LEFT JOIN T_ILI2DB_META_ATTRS as meta_attrs_array
ON LOWER(meta_attrs_array.ilielement) = LOWER(cname.iliname||'.'||cprop.columnname) AND meta_attrs_array.attr_name = 'ili2db.mapping'
LEFT JOIN t_ili2db_meta_attrs as meta_attrs_cardinality_min
LEFT JOIN T_ILI2DB_META_ATTRS as meta_attrs_cardinality_min
ON LOWER(meta_attrs_cardinality_min.ilielement) = LOWER(cname.iliname||'.'||cprop.columnname) AND meta_attrs_cardinality_min.attr_name = 'ili2db.ili.attrCardinalityMin'
LEFT JOIN t_ili2db_meta_attrs as meta_attrs_cardinality_max
LEFT JOIN T_ILI2DB_META_ATTRS as meta_attrs_cardinality_max
ON LOWER(meta_attrs_cardinality_max.ilielement) = LOWER(cname.iliname||'.'||cprop.columnname) AND meta_attrs_cardinality_max.attr_name = 'ili2db.ili.attrCardinalityMax'
WHERE cprop.tag = 'ch.ehi.ili2db.foreignKey' AND meta_attrs_array.attr_value = 'ARRAY'
"""
Expand Down Expand Up @@ -596,7 +596,7 @@ def get_iliname_dbname_mapping(self, sqlnames=list()):

cursor.execute(
"""SELECT iliname, sqlname
FROM t_ili2db_classname
FROM T_ILI2DB_CLASSNAME
{where}
""".format(
where=where
Expand All @@ -616,7 +616,7 @@ def get_classili_classdb_mapping(self, models_info, extended_classes):
)
cursor.execute(
"""SELECT *
FROM t_ili2db_classname
FROM T_ILI2DB_CLASSNAME
WHERE iliname IN ({class_names})
""".format(
class_names=class_names
Expand All @@ -630,7 +630,7 @@ def get_attrili_attrdb_mapping(self, attrs_list):
attr_names = "'" + "','".join(attrs_list) + "'"
cursor.execute(
"""SELECT iliname, sqlname, owner
FROM t_ili2db_attrname
FROM T_ILI2DB_ATTRNAME
WHERE iliname IN ({attr_names})
""".format(
attr_names=attr_names
Expand All @@ -644,7 +644,7 @@ def get_attrili_attrdb_mapping_by_owner(self, owners):
owner_names = "'" + "','".join(owners) + "'"
cursor.execute(
"""SELECT iliname, sqlname, owner
FROM t_ili2db_attrname
FROM T_ILI2DB_ATTRNAME
WHERE owner IN ({owner_names})
""".format(
owner_names=owner_names
Expand All @@ -653,22 +653,22 @@ def get_attrili_attrdb_mapping_by_owner(self, owners):
return cursor

def get_models(self):
if not self._table_exists("t_ili2db_trafo"):
if not self._table_exists("T_ILI2DB_TRAFO"):
return {}

# Get MODELS
cursor = self.conn.cursor()

cursor.execute(
"""SELECT distinct substr(iliname, 1, pos-1) AS modelname from
(SELECT *, instr(iliname,'.') AS pos FROM t_ili2db_trafo)"""
(SELECT *, instr(iliname,'.') AS pos FROM T_ILI2DB_TRAFO)"""
)

models = cursor.fetchall()

cursor.execute(
"""SELECT modelname, content
FROM t_ili2db_model"""
FROM T_ILI2DB_MODEL"""
)

contents = cursor.fetchall()
Expand Down Expand Up @@ -696,13 +696,13 @@ def get_models(self):

def ili_version(self):
cursor = self.conn.cursor()
cursor.execute("""PRAGMA table_info(t_ili2db_attrname)""")
cursor.execute("""PRAGMA table_info(T_ILI2DB_ATTRNAME)""")
table_info = cursor.fetchall()
result = 0
for column_info in table_info:
if column_info[1] == "Owner":
result += 1
cursor.execute("""PRAGMA table_info(t_ili2db_model)""")
cursor.execute("""PRAGMA table_info(T_ILI2DB_MODEL)""")
table_info = cursor.fetchall()
for column_info in table_info:
if column_info[1] == "file":
Expand Down
12 changes: 6 additions & 6 deletions modelbaker/dbconnector/mssql_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def create_dataset(self, datasetname):
return True, self.tr('Successfully created dataset "{}".').format(
datasetname
)
except pyodbc.errors.UniqueViolation as e:
except pyodbc.UniqueViolation as e:
return False, self.tr('Dataset with name "{}" already exists.').format(
datasetname
)
Expand All @@ -965,7 +965,7 @@ def rename_dataset(self, tid, datasetname):
return True, self.tr('Successfully created dataset "{}".').format(
datasetname
)
except pyodbc.errors.UniqueViolation as e:
except pyodbc.UniqueViolation as e:
return False, self.tr('Dataset with name "{}" already exists.').format(
datasetname
)
Expand Down Expand Up @@ -1086,7 +1086,7 @@ def create_basket(
cur.execute(
"""
INSERT INTO {schema}.{basket_table} ({tid_name}, dataset, topic, {tilitid_name}, attachmentkey )
VALUES (NEXT VALUE FOR {schema}.{sequence}, {dataset_tid}, '{topic}', {tilitid}, {attachment_key})
VALUES (NEXT VALUE FOR {schema}.{sequence}, {dataset_tid}, '{topic}', {tilitid}, '{attachment_key}')
""".format(
schema=self.schema,
sequence="t_ili2db_seq",
Expand All @@ -1103,7 +1103,7 @@ def create_basket(
return True, self.tr(
'Successfully created basket for topic "{}".'
).format(topic)
except pyodbc.errors.Error as e:
except pyodbc.Error as e:
error_message = " ".join(e.args)
return False, self.tr(
'Could not create basket for topic "{}": {}'
Expand Down Expand Up @@ -1139,7 +1139,7 @@ def edit_basket(self, basket_config: dict) -> tuple[bool, str]:
return True, self.tr(
'Successfully edited basket for topic "{}" and dataset "{}".'
).format(basket_config["topic"], basket_config["datasetname"])
except pyodbc.errors.Error as e:
except pyodbc.Error as e:
error_message = " ".join(e.args)
return False, self.tr(
'Could not edit basket for topic "{}" and dataset "{}": {}'
Expand Down Expand Up @@ -1215,7 +1215,7 @@ def set_ili2db_sequence_value(self, value):
return True, self.tr(
'Successfully reset sequence value to "{}".'
).format(value)
except pyodbc.errors.Error as e:
except pyodbc.Error as e:
error_message = " ".join(e.args)
return False, self.tr("Could not reset sequence: {}").format(
error_message
Expand Down
2 changes: 1 addition & 1 deletion scripts/package_pip_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
LIBS_DIR="modelbaker/libs"

DEPRECATION=("deprecation" "2.1.0")
PGSERVICEPARSER=("pgserviceparser" "2.1.0")
PGSERVICEPARSER=("pgserviceparser" "2.2.1")
TOPPINGMAKER=("toppingmaker" "1.4.0")

PACKAGES=(
Expand Down
18 changes: 10 additions & 8 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,28 @@ Run all test starting with ``test_array_`
These are dirty notes for the quickest way to test mssql queries manually in the way the tests work.

1. Create a new dir. E.g. `.local_docker_test`
2. Copy the original docker-compose file from directory `.docker` and remove everything except the qgis and the mssql container.
3. Copy the original Dockerfile as well. Leave it like it is...
4. Copy the original `run-docker-tests.sh` and remove everything except:
2. Copy the original docker-compose file from directory `.docker` and remove everything except the qgis and the mssql container (remove the postgis dependency in qgis as well).
3. Copy the original `run-docker-tests.sh` and remove everything except:
```bash
set -e

/usr/src/tests/testdata/mssql/setup-mssql.sh
```
5. Do the following:
4. Do the following:
Go to the local folder
```bash
docker-compose up -d
docker exec -it local_docker_tests_qgis_1 bash
export QGIS_TEST_VERSION=latest
export GITHUB_WORKSPACE=$PWD
docker-compose -f .local_docker_test/docker-compose.gh.yml up -d
docker exec -it local_docker_test_qgis_1 bash
```
And then in the qgis docker:
```bash
/usr/src/.local_docker_tests/run-docker-tests.sh;
/usr/src/.local_docker_test/run-docker-tests.sh
java -jar /usr/src/modelbaker/iliwrapper/bin/ili2mssql-5.0.0/ili2mssql-5.0.0.jar --schemaimport --dbhost mssql --dbusr sa --dbpwd '<YourStrong!Passw0rd>' --dbdatabase gis --dbschema optimal_polymorph_manuel --coalesceCatalogueRef --createEnumTabs --createNumChecks --createUnique --createFk --createFkIdx --coalesceMultiSurface --coalesceMultiLine --coalesceMultiPoint --coalesceArray --beautifyEnumDispName --createGeomIdx --createMetaInfo --expandMultilingual --createTypeConstraint --createEnumTabsWithId --createTidCol --importTid --smart2Inheritance --strokeArcs --createBasketCol --defaultSrsAuth EPSG --defaultSrsCode 2056 --preScript NULL --postScript NULL --models Polymorphic_Ortsplanung_V1_1 --iliMetaAttrs NULL /usr/src/tests/testdata/ilimodels/Polymorphic_Ortsplanung_V1_1.ili
```
(Surely this could be done without this qgis container, but there you have everything for the set up already...)
6. Now connect (with eg. the VS Code extension) with these params:
5. Now connect (with eg. the VS Code extension) with these params:
```
localhost
1433
Expand Down
Loading