Commit 4a7758d7 authored by Alice Salsé's avatar Alice Salsé
Browse files

👌 related tables VM

parent eef01f59
......@@ -7,8 +7,9 @@ from qgis.core import QgsDataSourceUri, QgsWkbTypes, QgsMapLayerType,QgsFeature
# initialize Qt resources from file resources.py
# execute : pyrcc5 -o resources.py resources.qrc
from . import resources
import csv
qconst = """select * from utils.related_table
qconst = """select * from utils.vm_related_table
where pt_schema='{0}'
and pt_name='{1}';"""
......@@ -126,7 +127,7 @@ class NetworkTools:
def activeLayerSelection(self) :
layer = self.iface.activeLayer()
if not layer:
if not layer :
self.iface.messageBar().pushMessage("Veuillez sélectionner une couche d'abord", Qgis.Warning)
return
else :
......@@ -278,7 +279,7 @@ class NetworkTools:
column_names, records = executeQuery(layer.dataProvider(), qconst.format(_schema, typ))
for rec in records :
self.selectLayerFromTable(rec[0], rec[1], 'id in ({0})'.format(','.join([str(i) for i in ids] or '0')))
self.selectLayerFromTable(rec[0], typ, 'id in ({0})'.format(','.join([str(i) for i in ids] or '0')))
self.selectLayerFromTable(_schema, typ, 'id in ({0})'.format(','.join([str(i) for i in ids] or '0')))
else :
self.iface.messageBar().pushMessage("La couche sélectionnée n'est pas de type ligne", Qgis.Warning)
......
......@@ -3,7 +3,8 @@
set search_path to utils, public;
-- VUE recensant les tables reliées
CREATE OR REPLACE VIEW utils.related_table AS
DROP MATERIALIZED VIEW IF EXISTS utils.vm_related_table;
CREATE MATERIALIZED VIEW utils.vm_related_table AS
select kcu.table_schema as ft_schema,
kcu.table_name as ft_name,
kcu.table_schema || '.' || kcu.table_name as foreign_table,
......
......@@ -6,7 +6,7 @@ SET tmpvar.schemaname TO :'schemaname';
DO $$
DECLARE
_relations CURSOR FOR
select * from utils.related_table
select * from utils.vm_related_table
where ft_schema=current_setting('tmpvar.schemaname', true)
and no=1;
l record;
......
......@@ -8,7 +8,7 @@ CREATE OR REPLACE FUNCTION fnc_duplicate_attributes(
RETURNS void AS $BODY$
DECLARE
_relations CURSOR FOR
select * from utils.related_table
select * from utils.vm_related_table
where foreign_table = i_nw_regclass::text;
_new_obj jsonb;
BEGIN
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment