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

ARA-Bauwerk in SIA405 export not handled correctly #177

Closed
sjib opened this issue Nov 1, 2024 · 1 comment
Closed

ARA-Bauwerk in SIA405 export not handled correctly #177

sjib opened this issue Nov 1, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@sjib
Copy link
Contributor

sjib commented Nov 1, 2024

          Next test: Export with SIA405, no selection: The same error as till now: I have ARA-Bauwerk-Records in my database, the wastewater-nodes go into the export, but the wastewater_structure can not be found, because ARA-Bauwerk is not part of the SIA405 model.

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

sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) insert or update on table "abwassernetzelement" violates foreign key constraint "abwassernetzelement_abwasserbauwerkref_fkey" DETAIL: Key (abwasserbauwerkref)=(6157) is not present in table "abwasserbauwerk". (Background on this error at: http://sqlalche.me/e/13/gkpj)
Traceback (most recent call last):
File "C:\PROGRA1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 771, in _commit_impl
self.engine.dialect.do_commit(self.connection)
File "C:\PROGRA
1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\engine\default.py", line 561, in do_commit
dbapi_connection.commit()
psycopg2.errors.ForeignKeyViolation: insert or update on table "abwassernetzelement" violates foreign key constraint "abwassernetzelement_abwasserbauwerkref_fkey"
DETAIL: Key (abwasserbauwerkref)=(6157) is not present in table "abwasserbauwerk".

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

Traceback (most recent call last):
File "C:\Users/KAU/AppData/Roaming/QGIS/QGIS3\profiles\qgep161_prerealise/python/plugins\qgepplugin\qgepqwat2ili\qgepqwat2ili\gui_init_.py", line 715, in action_do_export
qgepsia405_export(
File "C:\Users/KAU/AppData/Roaming/QGIS/QGIS3\profiles\qgep161_prerealise/python/plugins\qgepplugin\qgepqwat2ili\qgepqwat2ili\qgepsia405\export.py", line 1196, in qgep_export
abwasser_session.commit()
File "C:\PROGRA1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\orm\session.py", line 1046, in commit
self.transaction.commit()
File "C:\PROGRA
1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\orm\session.py", line 508, in commit
t[1].commit()
File "C:\PROGRA1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1762, in commit
self._do_commit()
File "C:\PROGRA
1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1793, in _do_commit
self.connection.commit_impl()
File "C:\PROGRA1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 773, in _commit_impl
self._handle_dbapi_exception(e, None, None, None, None)
File "C:\PROGRA
1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1510, in handle_dbapi_exception
util.raise
(
File "C:\PROGRA~1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\util\compat.py", line 182, in raise

raise exception
File "C:\PROGRA1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 771, in _commit_impl
self.engine.dialect.do_commit(self.connection)
File "C:\PROGRA
1\QGIS3\apps\Python312\Lib\site-packages\sqlalchemy\engine\default.py", line 561, in do_commit
dbapi_connection.commit()
sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) insert or update on table "abwassernetzelement" violates foreign key constraint "abwassernetzelement_abwasserbauwerkref_fkey"
DETAIL: Key (abwasserbauwerkref)=(6157) is not present in table "abwasserbauwerk".

(Background on this error at: http://sqlalche.me/e/13/gkpj)

Python-Version: 3.12.6 (main, Sep 7 2024, 18:59:42) [MSC v.1938 64 bit (AMD64)]
QGIS-Version: 3.34.10-Prizren Prizren, 113de9e1

Originally posted by @urskaufmann in QGEP/QGEP#880 (comment)

@sjib sjib transferred this issue from QGEP/QGEP Nov 4, 2024
@sjib sjib self-assigned this Nov 4, 2024
@sjib sjib added the bug Something isn't working label Nov 4, 2024
@sjib
Copy link
Contributor Author

sjib commented Nov 4, 2024

This check if is not working as expected:

        # get the value of the fk_ attribute as str out of the relation to be able to check whether it is in the subset
        fremdschluesselstr = getattr(relation, "obj_id")
        logger.debug(f"check_fk_in_subsetid -  fremdschluesselstr '{fremdschluesselstr}'")

        if fremdschluesselstr in subset:
            logger.debug(f"check_fk_in_subsetid - '{fremdschluesselstr}' is in subset ")
            logger.debug(f"check_fk_in_subsetid - tid = '{tid_maker.tid_for_row(relation)}' ")
            return tid_maker.tid_for_row(relation)
        else:
            if filtered:
                logger.warning(
                    f"check_fk_in_subsetid - '{fremdschluesselstr}' is not in subset - replaced with None instead!"
                )
                return None
            else:
                return tid_maker.tid_for_row(relation)

ch080qwzAW001080 is a ARA_Bauwerk and not in the Subset, but it does not recognize that:

2024-11-04T16:17:41        qgepplugin.qgepqwat2ili.qgepqwat2ili.utils:check_fk_in_subsetid - Subset ID's '['ch080qwzKA000018', 'ch080qwzKA000020', 'ch080qwzKA000023', 'ch080qwzKA000030', 'ch080qwzKA000039', 'ch080qwzKA000042', 'ch080qwzKA000047', 'ch080qwzKA000050', 'ch080qwzKA000055', 'ch080qwzKA000059', 'ch080qwzSW001067', 'ch080qwzKA001114', 'ch080qwzKA001115', 'ch080qwzKA000062', 'ch080qwzKA000065', 'ch080qwzKA000068', 'ch080qwzKA000071', 'ch080qwzKA000074', 'ch080qwzKA000077', 'ch080qwzKA000080', 'ch080qwzKA000083', 'ch080qwzKA000087', 'ch080qwzKA000090', 'ch080qwzKA000095', 'ch080qwzKA000096', 'ch080qwzKA000097', 'ch080qwzKA000101', 'ch080qwzKA000102', 'ch080qwzKA000103', 'ch080qwzKA000105', 'ch080qwzKA000108', 'ch080qwzKA000111', 'ch080qwzKA000114', 'ch080qwzKA000117', 'ch080qwzKA000120', 'ch080qwzKA000123', 'ch080qwzKA000126', 'ch080qwzKA000131', 'ch080qwzKA000134', 'ch080qwzKA000137', 'ch080qwzKA000140', 'ch080qwzKA000144', 'ch080qwzKA000146', 'ch080qwzKA000149', 'ch080qwzKA000152', 'ch080qwzKA000155', 'ch080qwzKA000158', 'ch080qwzKA001014', 'ch080qwzKA001032', 'ch080qwzKA001068', 'ch080qwzKA001069', 'ch080qwzKA001070', 'ch080qwzKA001072', 'ch080qwzKA001073', 'ch080qwzKA001110', 'ch080qwzKA001111', 'ch080qwzKA001112', 'ch080qwzKA001116', 'ch080qwzKA001117', 'ch080qwzKA001118', 'ch080qwzKA001119', 'ch080qwzKA001120', 'ch080qwzKA001121', 'ch080qwzKA001122', 'ch080qwzKA001134', 'ch080qwzKA001135', 'ch080qwzKA001136', 'ch080qwzKA001137', 'ch080qwzKA001138', 'ch080qwzKA001139', 'ch080qwzKA001140', 'ch080qwzKA001141', 'ch080qwzKA001142', 'ch080qwzKA001143', 'ch080qwzKA001144', 'ch080qwzKA001145', 'ch080qwzKA001147', 'ch080qwzKA001148', 'ch080qwzKA001215', 'ch080qwzKA001325', 'ch080qwzKA001326', 'ch080qwzKA001327', 'ch080qwzKA001328', 'ch080qwzKA001329', 'ch080qwzKA001330', 'ch080qwzKA001331', 'ch080qwzKA001332', 'ch080qwzKA001333', 'ch080qwzKA001334', 'ch080qwzKA001335', 'ch080qwzKA001336', 'ch080qwzKA001337', 'ch080qwzKA001338', 'ch080qwzKA001339', 'ch080qwzKA001342', 'ch080qwzKA001343', 'ch080qwzKA001344', 'ch080qwzKA001345', 'ch080qwzKA001353', 'ch080qwzKA001354', 'ch080qwzKA001404', 'ch080qwzKA001406', 'ch080qwzNS000011', 'ch080qwzNS000013', 'ch080qwzNS000021', 'ch080qwzNS000026', 'ch080qwzNS000040', 'ch080qwzNS000049', 'ch080qwzNS000052', 'ch080qwzNS000058', 'ch080qwzNS000061', 'ch080qwzNS000064', 'ch080qwzNS000067', 'ch080qwzNS000070', 'ch080qwzNS000073', 'ch080qwzNS000076', 'ch080qwzNS000079', 'ch080qwzNS000082', 'ch080qwzNS000086', 'ch080qwzNS000107', 'ch080qwzNS000110', 'ch080qwzNS000113', 'ch080qwzNS000116', 'ch080qwzNS000119', 'ch080qwzNS000122', 'ch080qwzNS000130', 'ch080qwzNS000133', 'ch080qwzNS000136', 'ch080qwzNS000139', 'ch080qwzNS000145', 'ch080qwzNS000148', 'ch080qwzNS000151', 'ch080qwzNS000157', 'ch080qwzNS001030', 'ch080qwzNS001065', 'ch080qwzNS001066', 'ch080qwzNS001245', 'ch080qwzNS001317', 'ch080qwzNS001318', 'ch080qwzNS001319', 'ch080qwzNS001320', 'ch080qwzNS001321', 'ch080qwzNS001322', 'ch080qwzNS001323', 'ch080qwzNS001324', 'ch080qwzNS001340', 'ch080qwzNS001341', 'ch080qwzNS001351', 'ch080qwzNS001352', 'ch080qwzNS001406', 'ch080qwzNS001407', 'ch080qwzSW000001', 'ch080qwzSW000037', 'ch080qwzSW000089', 'ch080qwzSW000094', 'ch080qwzSW000099', 'ch080qwzSW000125', 'ch080qwzSW000142', 'ch080qwzSW001100', 'ch080qwzSW001101', 'ch080qwzSW001102', 'ch080qwzSW001103', 'ch080qwzSW001128', 'ch080qwzSW001131', 'ch080qwzSW001132', 'ch080qwzSW001133', 'ch080qwzSW001150', 'ch080qwzSW001207', 'ch080qwzVA001062', 'ch080qwzVE000019', 'ch080qwzVE000046', 'ch080qwzVE000104', 'ch080qwzVE001033', 'ch080qwzVE001062', 'ch080qwzVE001400']'
2024-11-04T16:17:41        qgepplugin.qgepqwat2ili.qgepqwat2ili.utils:check_fk_in_subsetid - fremdschluesselstr 'ch080qwzAW001080'
2024-11-04T16:17:41        qgepplugin.qgepqwat2ili.qgepqwat2ili.utils:check_fk_in_subsetid - Subset ID's '['ch080qwzKA000018', 'ch080qwzKA000020', 'ch080qwzKA000023', 'ch080qwzKA000030', 'ch080qwzKA000039', 'ch080qwzKA000042', 'ch080qwzKA000047', 'ch080qwzKA000050', 'ch080qwzKA000055', 'ch080qwzKA000059', 'ch080qwzSW001067', 'ch080qwzKA001114', 'ch080qwzKA001115', 'ch080qwzKA000062', 'ch080qwzKA000065', 'ch080qwzKA000068', 'ch080qwzKA000071', 'ch080qwzKA000074', 'ch080qwzKA000077', 'ch080qwzKA000080', 'ch080qwzKA000083', 'ch080qwzKA000087', 'ch080qwzKA000090', 'ch080qwzKA000095', 'ch080qwzKA000096', 'ch080qwzKA000097', 'ch080qwzKA000101', 'ch080qwzKA000102', 'ch080qwzKA000103', 'ch080qwzKA000105', 'ch080qwzKA000108', 'ch080qwzKA000111', 'ch080qwzKA000114', 'ch080qwzKA000117', 'ch080qwzKA000120', 'ch080qwzKA000123', 'ch080qwzKA000126', 'ch080qwzKA000131', 'ch080qwzKA000134', 'ch080qwzKA000137', 'ch080qwzKA000140', 'ch080qwzKA000144', 'ch080qwzKA000146', 'ch080qwzKA000149', 'ch080qwzKA000152', 'ch080qwzKA000155', 'ch080qwzKA000158', 'ch080qwzKA001014', 'ch080qwzKA001032', 'ch080qwzKA001068', 'ch080qwzKA001069', 'ch080qwzKA001070', 'ch080qwzKA001072', 'ch080qwzKA001073', 'ch080qwzKA001110', 'ch080qwzKA001111', 'ch080qwzKA001112', 'ch080qwzKA001116', 'ch080qwzKA001117', 'ch080qwzKA001118', 'ch080qwzKA001119', 'ch080qwzKA001120', 'ch080qwzKA001121', 'ch080qwzKA001122', 'ch080qwzKA001134', 'ch080qwzKA001135', 'ch080qwzKA001136', 'ch080qwzKA001137', 'ch080qwzKA001138', 'ch080qwzKA001139', 'ch080qwzKA001140', 'ch080qwzKA001141', 'ch080qwzKA001142', 'ch080qwzKA001143', 'ch080qwzKA001144', 'ch080qwzKA001145', 'ch080qwzKA001147', 'ch080qwzKA001148', 'ch080qwzKA001215', 'ch080qwzKA001325', 'ch080qwzKA001326', 'ch080qwzKA001327', 'ch080qwzKA001328', 'ch080qwzKA001329', 'ch080qwzKA001330', 'ch080qwzKA001331', 'ch080qwzKA001332', 'ch080qwzKA001333', 'ch080qwzKA001334', 'ch080qwzKA001335', 'ch080qwzKA001336', 'ch080qwzKA001337', 'ch080qwzKA001338', 'ch080qwzKA001339', 'ch080qwzKA001342', 'ch080qwzKA001343', 'ch080qwzKA001344', 'ch080qwzKA001345', 'ch080qwzKA001353', 'ch080qwzKA001354', 'ch080qwzKA001404', 'ch080qwzKA001406', 'ch080qwzNS000011', 'ch080qwzNS000013', 'ch080qwzNS000021', 'ch080qwzNS000026', 'ch080qwzNS000040', 'ch080qwzNS000049', 'ch080qwzNS000052', 'ch080qwzNS000058', 'ch080qwzNS000061', 'ch080qwzNS000064', 'ch080qwzNS000067', 'ch080qwzNS000070', 'ch080qwzNS000073', 'ch080qwzNS000076', 'ch080qwzNS000079', 'ch080qwzNS000082', 'ch080qwzNS000086', 'ch080qwzNS000107', 'ch080qwzNS000110', 'ch080qwzNS000113', 'ch080qwzNS000116', 'ch080qwzNS000119', 'ch080qwzNS000122', 'ch080qwzNS000130', 'ch080qwzNS000133', 'ch080qwzNS000136', 'ch080qwzNS000139', 'ch080qwzNS000145', 'ch080qwzNS000148', 'ch080qwzNS000151', 'ch080qwzNS000157', 'ch080qwzNS001030', 'ch080qwzNS001065', 'ch080qwzNS001066', 'ch080qwzNS001245', 'ch080qwzNS001317', 'ch080qwzNS001318', 'ch080qwzNS001319', 'ch080qwzNS001320', 'ch080qwzNS001321', 'ch080qwzNS001322', 'ch080qwzNS001323', 'ch080qwzNS001324', 'ch080qwzNS001340', 'ch080qwzNS001341', 'ch080qwzNS001351', 'ch080qwzNS001352', 'ch080qwzNS001406', 'ch080qwzNS001407', 'ch080qwzSW000001', 'ch080qwzSW000037', 'ch080qwzSW000089', 'ch080qwzSW000094', 'ch080qwzSW000099', 'ch080qwzSW000125', 'ch080qwzSW000142', 'ch080qwzSW001100', 'ch080qwzSW001101', 'ch080qwzSW001102', 'ch080qwzSW001103', 'ch080qwzSW001128', 'ch080qwzSW001131', 'ch080qwzSW001132', 'ch080qwzSW001133', 'ch080qwzSW001150', 'ch080qwzSW001207', 'ch080qwzVA001062', 'ch080qwzVE000019', 'ch080qwzVE000046', 'ch080qwzVE000104', 'ch080qwzVE001033', 'ch080qwzVE001062', 'ch080qwzVE001400']'
2024-11-04T16:17:41        qgepplugin.qgepqwat2ili.qgepqwat2ili.utils:check_fk_in_subsetid - fremdschluesselstr 'ch080qwzAW001081'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant