Skip to content

Commit

Permalink
Merge pull request #148 from QGEP/2024-06-17-abwasser_session-add-ALL…
Browse files Browse the repository at this point in the history
…-DEFERRE

add ALL DEFERRED
  • Loading branch information
ponceta committed Jun 25, 2024
2 parents 4f4cef3 + 78043f7 commit 9416466
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions qgepqwat2ili/qgep/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
from geoalchemy2.functions import ST_Force2D, ST_GeomFromGeoJSON
from sqlalchemy import or_
from sqlalchemy.orm import Session
from sqlalchemy.sql import text

from .. import utils
from ..utils.various import logger
from .model_abwasser import get_abwasser_model
from .model_qgep import get_qgep_model


#def qgep_export(selection=None, labels_file=None):
def qgep_export(selection=None, labels_file=None, orientation=None):
"""
Expand All @@ -28,6 +30,9 @@ def qgep_export(selection=None, labels_file=None, orientation=None):
abwasser_session = Session(utils.sqlalchemy.create_engine(), autocommit=False, autoflush=False)
tid_maker = utils.ili2db.TidMaker(id_attribute="obj_id")

# backport from tww https://github.com/teksi/wastewater/blob/3acfba249866d299f8a22e249d9f1e475fe7b88d/plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py#L83
abwasser_session.execute(text("SET CONSTRAINTS ALL DEFERRED;"))

# Filtering
filtered = selection is not None
subset_ids = selection if selection is not None else []
Expand Down
4 changes: 4 additions & 0 deletions qgepqwat2ili/qgepdss/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from geoalchemy2.functions import ST_Force2D, ST_GeomFromGeoJSON
from sqlalchemy import or_
from sqlalchemy.orm import Session
from sqlalchemy.sql import text

from .. import utils
from ..utils.various import logger
Expand Down Expand Up @@ -32,6 +33,9 @@ def qgep_export(selection=None, labels_file=None, orientation=None):
abwasser_session = Session(utils.sqlalchemy.create_engine(), autocommit=False, autoflush=False)
tid_maker = utils.ili2db.TidMaker(id_attribute="obj_id")

# backport from tww https://github.com/teksi/wastewater/blob/3acfba249866d299f8a22e249d9f1e475fe7b88d/plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py#L83
abwasser_session.execute(text("SET CONSTRAINTS ALL DEFERRED;"))

# Filtering
filtered = selection is not None
subset_ids = selection if selection is not None else []
Expand Down
4 changes: 4 additions & 0 deletions qgepqwat2ili/qgepsia405/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from geoalchemy2.functions import ST_Force2D, ST_GeomFromGeoJSON
from sqlalchemy import or_
from sqlalchemy.orm import Session
from sqlalchemy.sql import text

from .. import utils
from ..utils.various import logger
Expand All @@ -29,6 +30,9 @@ def qgep_export(selection=None, labels_file=None, orientation=None):
abwasser_session = Session(utils.sqlalchemy.create_engine(), autocommit=False, autoflush=False)
tid_maker = utils.ili2db.TidMaker(id_attribute="obj_id")

# backport from tww https://github.com/teksi/wastewater/blob/3acfba249866d299f8a22e249d9f1e475fe7b88d/plugin/teksi_wastewater/interlis/interlis_model_mapping/interlis_exporter_to_intermediate_schema.py#L83
abwasser_session.execute(text("SET CONSTRAINTS ALL DEFERRED;"))

# Filtering
filtered = selection is not None
subset_ids = selection if selection is not None else []
Expand Down

0 comments on commit 9416466

Please sign in to comment.