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

Disable symbology triggers instead of dropping #88

Merged
merged 6 commits into from
Jan 19, 2024

Conversation

cymed
Copy link
Contributor

@cymed cymed commented Jan 17, 2024

To drop or disable a trigger, one must own the table.
It is better practice to disable the trigger, as one can see what is enabled/disabled easier.
Also, a new table tww_sys.symbology_triggers is introduced, which allows handling trigger enabling/disabling dynamically

@cymed
Copy link
Contributor Author

cymed commented Jan 17, 2024

@domi4484 Tested this PR solves in my installation. Solves #87 once we rename every call in plugin from drop_symbology_triggers/create_symbology_triggers to disable_symbology_triggers/enable_symbology_triggers

@cymed cymed marked this pull request as ready for review January 17, 2024 13:16
@sjib
Copy link
Contributor

sjib commented Jan 17, 2024

@cymed I now get the following error on INTERLIS import with the latest database version: https://github.com/teksi/wastewater/actions/runs/7556220562/artifacts/1175190367
So this seems to have a connection with the plugin somehow.

Ein Fehler trat bei der Ausführung von Python-Code auf:

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedFunction) FEHLER: Funktion tww_sys.drop_symbology_triggers() existiert nicht LINE 1: SELECT tww_sys.drop_symbology_triggers(); ^ HINT: Keine Funktion stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen. [SQL: SELECT tww_sys.drop_symbology_triggers();] (Background on this error at: http://sqlalche.me/e/13/f405)
Traceback (most recent call last):
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\engine\base.py", line 1276, in _execute_context
self.dialect.do_execute(
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\engine\default.py", line 608, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.UndefinedFunction: FEHLER: Funktion tww_sys.drop_symbology_triggers() existiert nicht
LINE 1: SELECT tww_sys.drop_symbology_triggers();
^
HINT: Keine Funktion stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python/plugins\teksi_wastewater\teksi_wastewater_plugin.py", line 495, in actionImportClicked
self.interlisImporterExporter.action_import()
File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python/plugins\teksi_wastewater\interlis\gui\interlis_importer_exporter.py", line 106, in action_import
raise exception
File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python/plugins\teksi_wastewater\interlis\gui\interlis_importer_exporter.py", line 90, in action_import
self._action_import(xtf_file_input)
File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python/plugins\teksi_wastewater\interlis\gui\interlis_importer_exporter.py", line 201, in _action_import
tww_session = self._import_from_intermediate_schema(import_model)
File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python/plugins\teksi_wastewater\interlis\gui\interlis_importer_exporter.py", line 263, in _import_from_intermediate_schema
interlisImporterToIntermediateSchema.tww_import(skip_closing_tww_session=True)
File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python/plugins\teksi_wastewater\interlis\interlis_model_mapping\interlis_importer_to_intermediate_schema.py", line 39, in tww_import
raise exception
File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python/plugins\teksi_wastewater\interlis\interlis_model_mapping\interlis_importer_to_intermediate_schema.py", line 31, in tww_import
self._tww_import(skip_closing_tww_session)
File "C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python/plugins\teksi_wastewater\interlis\interlis_model_mapping\interlis_importer_to_intermediate_schema.py", line 57, in _tww_import
pre_session.execute(text("SELECT tww_sys.drop_symbology_triggers();"))
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\orm\session.py", line 1295, in execute
return self._connection_for_bind(bind, close_with_result=True).execute(
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\engine\base.py", line 1011, in execute
return meth(self, multiparams, params)
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\sql\elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\engine\base.py", line 1124, in _execute_clauseelement
ret = self._execute_context(
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\engine\base.py", line 1316, in _execute_context
self.handle_dbapi_exception(
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\engine\base.py", line 1510, in handle_dbapi_exception
util.raise
(
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\util\compat.py", line 182, in raise

raise exception
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\engine\base.py", line 1276, in _execute_context
self.dialect.do_execute(
File "C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages\sqlalchemy\engine\default.py", line 608, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedFunction) FEHLER: Funktion tww_sys.drop_symbology_triggers() existiert nicht
LINE 1: SELECT tww_sys.drop_symbology_triggers();
^
HINT: Keine Funktion stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen.

[SQL: SELECT tww_sys.drop_symbology_triggers();]
(Background on this error at: http://sqlalche.me/e/13/f405)

Python-Version: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]
QGIS-Version: 3.28.4-Firenze Firenze, fd0fb72ab3

Python-Pfad:
C:/PROGRA1/QGIS 3.28.4/apps/qgis-ltr/./python
C:/Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python
C:/Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python/plugins
C:/PROGRA
1/QGIS 3.28.4/apps/qgis-ltr/./python/plugins
C:\Program Files\QGIS 3.28.4\bin\python39.zip
C:\PROGRA1\QGIS 3.28.4\apps\Python39\DLLs
C:\PROGRA
1\QGIS 3.28.4\apps\Python39\lib
C:\Program Files\QGIS 3.28.4\bin
C:\Users\Stefan\AppData\Roaming\Python\Python39\site-packages
C:\PROGRA1\QGIS 3.28.4\apps\Python39
C:\PROGRA
1\QGIS 3.28.4\apps\Python39\lib\site-packages
C:\PROGRA1\QGIS 3.28.4\apps\Python39\lib\site-packages\win32
C:\PROGRA
1\QGIS 3.28.4\apps\Python39\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS 3.28.4\apps\Python39\lib\site-packages\Pythonwin
C:/Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python
C:/Daten/QGEP/testing_dss2020
C:\Users/Stefan/AppData/Roaming/QGIS/QGIS3\profiles\tww_testing/python/plugins\teksi_wastewater\interlis\gui....

@cymed
Copy link
Contributor Author

cymed commented Jan 17, 2024

@sjib see my prior response. It is a mere substituting of function names.

@domi4484 Tested this PR solves in my installation. Solves #87 once we rename every call in plugin from drop_symbology_triggers/create_symbology_triggers to disable_symbology_triggers/enable_symbology_triggers

@3nids
Copy link
Contributor

3nids commented Jan 19, 2024

Disabling rather than dropping sounds good, but I'm not convinced by the complexity of maintaining a table with the triggers and the fact of using execute format.

@sjib
Copy link
Contributor

sjib commented Jan 19, 2024

  • Feedback to code: remove extra table - keep enable instead of dropping @cymed rewrites code
  • @3nids reviews and merges

@3nids 3nids merged commit 99a1707 into teksi:main Jan 19, 2024
4 checks passed
@cymed cymed deleted the disable_symbology_triggers_insteadof-dropping branch January 22, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants