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

Load a GMLAS database not working #201

Open
sgrellet opened this issue Feb 4, 2022 · 3 comments
Open

Load a GMLAS database not working #201

sgrellet opened this issue Feb 4, 2022 · 3 comments
Assignees
Labels
bug Houston, we've a problem!

Comments

@sgrellet
Copy link
Member

sgrellet commented Feb 4, 2022

Environment

  • Plugin version: 1.4.0-beta4:
  • QGIS version: 3.16.16-Hannover, f5778a89
  • Operating System: Windows 10 1909
  • Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]

Description

  • loading a GMLAS database created by previously running versions of the plugin is not working
  • 2 files attached : in one case the file is loaded but no geometry layer is retrieved, in the other case the plugin crashes

To Reproduce

Steps to reproduce the behavior:
Attached file:
20210525_HydroGeoUnit.zip
20210625_BoreholeViewB.zip

  1. Load a GMLAS Database
  2. Connexion to
    • 20210525_HydroGeoUnit.sqlite : all tables loaded but no geometry
    • 20210625_BoreholeViewB.sqlite : -> python error

-> Python error

"2022-02-03T15:20:32     WARNING    Traceback (most recent call last):
              File "C:\Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\main.py", line 302, in onLoad
              import_in_qgis(
              File "C:\Users/grellets/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\gml_application_schema_toolbox\core\load_gmlas_in_qgis.py", line 144, in import_in_qgis
              PlgLogger.log(message=f"DEBUG List of layers : {result}", log_level=4)
             UnboundLocalError: local variable 'result' referenced before assignment"

Expected behavior

  • the database should be properly loaded : tables, links (pk, fk) and also the geometry
@sgrellet sgrellet added the bug Houston, we've a problem! label Feb 4, 2022
@Guts Guts self-assigned this Feb 11, 2022
@Guts
Copy link
Collaborator

Guts commented Feb 11, 2022

Already fixed by ecf302a

@Guts
Copy link
Collaborator

Guts commented Mar 2, 2022

2022-03-02T14:47:26     NONE    DEBUG - 4 connections listed.
2022-03-02T14:47:29     INFO    Selected database to load: 20210525_HydroGeoUnit.sqlite - Schema: None - Format: spatialite
2022-03-02T14:47:29     NONE    Start importing dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite' (provider: spatialite) into QGIS
2022-03-02T14:47:29     NONE    DEBUG Connect to dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite'
2022-03-02T14:47:29     NONE    DEBUG Get list of layers with query : select o.layer_name, o.layer_xpath, o.layer_category, o.layer_pkid_name, o.layer_parent_pkid_name, g.f_geometry_column, g.srid from _ogr_layers_metadata o left join geometry_columns g on g.f_table_name = o.layer_name
2022-03-02T14:47:29     NONE    DEBUG List of layers : [['gw_confiningbed', 'gwml2:GW_ConfiningBed', 'TOP_LEVEL_ELEMENT', 'id', NULL, NULL, NULL], ['gw_confiningbed_name', 'gwml2:GW_ConfiningBed/gml:name', 'NESTED_ELEMENT', 'ogr_pkid', 'parent_id', NULL, NULL], ['gw_confiningbed_gwconfinedaquifer', 'gwml2:GW_ConfiningBed/gwml2:gwConfinedAquifer', 'NESTED_ELEMENT', 'ogr_pkid', 'parent_id', NULL, NULL], ['category', 'swe:Category', 'TOP_LEVEL_ELEMENT', 'ogr_pkid', NULL, NULL, NULL], ['mappedfeature', 'gsml:MappedFeature', 'TOP_LEVEL_ELEMENT', 'id', NULL, 'shape', 4326], ['mappedfeature_observationmethod', 'gsml:MappedFeature/gsml:observationMethod', 'NESTED_ELEMENT', 'ogr_pkid', 'parent_id', NULL, NULL], ['observationmethod', 'gsml:observationMethod', 'NESTED_ELEMENT', 'ogr_pkid', NULL, NULL, NULL], ['occurrence', 'gsml:occurrence', 'NESTED_ELEMENT', 'ogr_pkid', NULL, NULL, NULL], ['gwaquifersystem', 'gwml2:gwAquiferSystem', 'NESTED_ELEMENT', 'ogr_pkid', NULL, NULL, NULL], ['gw_confiningbed_observationmethod_observationmethod', NULL, 'JUNCTION_TABLE', NULL, NULL, NULL, NULL], ['gw_confiningbed_occurrence_occurrence', NULL, 'JUNCTION_TABLE', NULL, NULL, NULL, NULL], ['gw_confiningbed_gwaquifersystem_gwaquifersystem', NULL, 'JUNCTION_TABLE', NULL, NULL, NULL, NULL]]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer gw_confiningbed with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='gw_confiningbed'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['id', 'gwml2:GW_ConfiningBed/@gml:id'], ['description_href', 'gwml2:GW_ConfiningBed/gml:description/@xlink:href'], ['description_title', 'gwml2:GW_ConfiningBed/gml:description/@xlink:title'], ['description_nilreason', 'gwml2:GW_ConfiningBed/gml:description/@nilReason'], ['description', 'gwml2:GW_ConfiningBed/gml:description'], ['descriptionreference_href', 'gwml2:GW_ConfiningBed/gml:descriptionReference/@xlink:href'], ['descriptionreference_title', 'gwml2:GW_ConfiningBed/gml:descriptionReference/@xlink:title'], ['descriptionreference_nilreason', 'gwml2:GW_ConfiningBed/gml:descriptionReference/@nilReason'], ['identifier_codespace', 'gwml2:GW_ConfiningBed/gml:identifier/@codeSpace'], ['identifier', 'gwml2:GW_ConfiningBed/gml:identifier'], ['name', 'gwml2:GW_ConfiningBed/gml:name'], ['observationmethod_observationmethod', 'gwml2:GW_ConfiningBed/gsml:observationMethod'], ['occurrence_occurrence', 'gwml2:GW_ConfiningBed/gsml:occurrence'], ['purpose_nilreason', 'gwml2:GW_ConfiningBed/gsml:purpose/@nilReason'], ['purpose_nil', 'gwml2:GW_ConfiningBed/gsml:purpose/@xsi:nil'], ['purpose', 'gwml2:GW_ConfiningBed/gsml:purpose'], ['geologicunittype_owns', 'gwml2:GW_ConfiningBed/gsml:geologicUnitType/@owns'], ['geologicunittype_href', 'gwml2:GW_ConfiningBed/gsml:geologicUnitType/@xlink:href'], ['geologicunittype_title', 'gwml2:GW_ConfiningBed/gsml:geologicUnitType/@xlink:title'], ['geologicunittype_nilreason', 'gwml2:GW_ConfiningBed/gsml:geologicUnitType/@nilReason'], ['rank_owns', 'gwml2:GW_ConfiningBed/gsml:rank/@owns'], ['rank_href', 'gwml2:GW_ConfiningBed/gsml:rank/@xlink:href'], ['rank_title', 'gwml2:GW_ConfiningBed/gsml:rank/@xlink:title'], ['rank_nilreason', 'gwml2:GW_ConfiningBed/gsml:rank/@nilReason'], ['gwunitmedia_owns', 'gwml2:GW_ConfiningBed/gwml2:gwUnitMedia/@owns'], ['gwunitmedia_href', 'gwml2:GW_ConfiningBed/gwml2:gwUnitMedia/@xlink:href'], ['gwunitmedia_title', 'gwml2:GW_ConfiningBed/gwml2:gwUnitMedia/@xlink:title'], ['gwunitmedia_nilreason', 'gwml2:GW_ConfiningBed/gwml2:gwUnitMedia/@nilReason'], ['gwaquifersystem_gwaquifersystem', 'gwml2:GW_ConfiningBed/gwml2:gwAquiferSystem'], ['gwspatialconfinement_owns', 'gwml2:GW_ConfiningBed/gwml2:gwSpatialConfinement/@owns'], ['gwspatialconfinement_href', 'gwml2:GW_ConfiningBed/gwml2:gwSpatialConfinement/@xlink:href'], ['gwspatialconfinement_title', 'gwml2:GW_ConfiningBed/gwml2:gwSpatialConfinement/@xlink:title'], ['gwspatialconfinement_nilreason', 'gwml2:GW_ConfiningBed/gwml2:gwSpatialConfinement/@nilReason'], ['gwconductivityconfinement_owns', 'gwml2:GW_ConfiningBed/gwml2:gwConductivityConfinement/@owns'], ['gwconductivityconfinement_href', 'gwml2:GW_ConfiningBed/gwml2:gwConductivityConfinement/@xlink:href'], ['gwconductivityconfinement_title', 'gwml2:GW_ConfiningBed/gwml2:gwConductivityConfinement/@xlink:title'], ['gwconductivityconfinement_nilreason', 'gwml2:GW_ConfiningBed/gwml2:gwConductivityConfinement/@nilReason'], ['gwconfinedaquifer', 'gwml2:GW_ConfiningBed/gwml2:gwConfinedAquifer']]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer gw_confiningbed_name with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='gw_confiningbed_name'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['codespace', 'gwml2:GW_ConfiningBed/gml:name/@codeSpace'], ['value', 'gwml2:GW_ConfiningBed/gml:name']]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer gw_confiningbed_gwconfinedaquifer with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='gw_confiningbed_gwconfinedaquifer'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['href', 'gwml2:GW_ConfiningBed/gwml2:gwConfinedAquifer/@xlink:href'], ['title', 'gwml2:GW_ConfiningBed/gwml2:gwConfinedAquifer/@xlink:title'], ['nilreason', 'gwml2:GW_ConfiningBed/gwml2:gwConfinedAquifer/@nilReason'], ['owns', 'gwml2:GW_ConfiningBed/gwml2:gwConfinedAquifer/@owns'], ['gw_aquiferunit_gw_confiningbed_pkid', 'gwml2:GW_ConfiningBed/gwml2:gwConfinedAquifer/gwml2:GW_ConfiningBed']]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer category with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='category'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['referenceframe', 'swe:Category/@referenceFrame'], ['axisid', 'swe:Category/@axisID'], ['updatable', 'swe:Category/@updatable'], ['optional', 'swe:Category/@optional'], ['definition', 'swe:Category/@definition'], ['id', 'swe:Category/@id'], ['identifier', 'swe:Category/swe:identifier'], ['label', 'swe:Category/swe:label'], ['description', 'swe:Category/swe:description'], ['codespace_href', 'swe:Category/swe:codeSpace/@xlink:href'], ['codespace_title', 'swe:Category/swe:codeSpace/@xlink:title'], ['constraint_href', 'swe:Category/swe:constraint/@xlink:href'], ['constraint_title', 'swe:Category/swe:constraint/@xlink:title'], ['value', 'swe:Category/swe:value']]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer mappedfeature with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='mappedfeature'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['id', 'gsml:MappedFeature/@gml:id'], ['description_href', 'gsml:MappedFeature/gml:description/@xlink:href'], ['description_title', 'gsml:MappedFeature/gml:description/@xlink:title'], ['description_nilreason', 'gsml:MappedFeature/gml:description/@nilReason'], ['description', 'gsml:MappedFeature/gml:description'], ['descriptionreference_href', 'gsml:MappedFeature/gml:descriptionReference/@xlink:href'], ['descriptionreference_title', 'gsml:MappedFeature/gml:descriptionReference/@xlink:title'], ['descriptionreference_nilreason', 'gsml:MappedFeature/gml:descriptionReference/@nilReason'], ['identifier_codespace', 'gsml:MappedFeature/gml:identifier/@codeSpace'], ['identifier', 'gsml:MappedFeature/gml:identifier'], ['observationmethod', 'gsml:MappedFeature/gsml:observationMethod'], ['positionalaccuracy_href', 'gsml:MappedFeature/gsml:positionalAccuracy/@xlink:href'], ['positionalaccuracy_title', 'gsml:MappedFeature/gsml:positionalAccuracy/@xlink:title'], ['positionalaccuracy_nilreason', 'gsml:MappedFeature/gsml:positionalAccuracy/@nilReason'], ['positionalaccuracy_owns', 'gsml:MappedFeature/gsml:positionalAccuracy/@owns'], ['resolutionrepresentativefraction_nilreason', 'gsml:MappedFeature/gsml:resolutionRepresentativeFraction/@nilReason'], ['resolutionrepresentativefraction_nil', 'gsml:MappedFeature/gsml:resolutionRepresentativeFraction/@xsi:nil'], ['resolutionrepresentativefraction', 'gsml:MappedFeature/gsml:resolutionRepresentativeFraction'], ['mappingframe_owns', 'gsml:MappedFeature/gsml:mappingFrame/@owns'], ['mappingframe_href', 'gsml:MappedFeature/gsml:mappingFrame/@xlink:href'], ['mappingframe_title', 'gsml:MappedFeature/gsml:mappingFrame/@xlink:title'], ['mappingframe_nilreason', 'gsml:MappedFeature/gsml:mappingFrame/@nilReason'], ['exposure_owns', 'gsml:MappedFeature/gsml:exposure/@owns'], ['exposure_href', 'gsml:MappedFeature/gsml:exposure/@xlink:href'], ['exposure_title', 'gsml:MappedFeature/gsml:exposure/@xlink:title'], ['exposure_nilreason', 'gsml:MappedFeature/gsml:exposure/@nilReason'], ['specification_owns', 'gsml:MappedFeature/gsml:specification/@owns'], ['specification_href', 'gsml:MappedFeature/gsml:specification/@xlink:href'], ['specification_title', 'gsml:MappedFeature/gsml:specification/@xlink:title'], ['specification_nilreason', 'gsml:MappedFeature/gsml:specification/@nilReason'], ['specification_abstractfeature_gw_confiningbed_pkid', 'gsml:MappedFeature/gsml:specification/gwml2:GW_ConfiningBed'], ['specification_abstractfeature_mappedfeature_pkid', 'gsml:MappedFeature/gsml:specification/gsml:MappedFeature'], ['shape', 'gsml:MappedFeature/gsml:shape']]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer mappedfeature_observationmethod with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='mappedfeature_observationmethod'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['href', 'gsml:MappedFeature/gsml:observationMethod/@xlink:href'], ['title', 'gsml:MappedFeature/gsml:observationMethod/@xlink:title'], ['nilreason', 'gsml:MappedFeature/gsml:observationMethod/@nilReason'], ['owns', 'gsml:MappedFeature/gsml:observationMethod/@owns'], ['category_pkid', 'gsml:MappedFeature/gsml:observationMethod/swe:Category']]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer observationmethod with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='observationmethod'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['href', 'gsml:observationMethod/@xlink:href'], ['title', 'gsml:observationMethod/@xlink:title'], ['nilreason', 'gsml:observationMethod/@nilReason'], ['owns', 'gsml:observationMethod/@owns'], ['category_pkid', 'gsml:observationMethod/swe:Category']]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer occurrence with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='occurrence'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['href', 'gsml:occurrence/@xlink:href'], ['title', 'gsml:occurrence/@xlink:title'], ['nilreason', 'gsml:occurrence/@nilReason'], ['owns', 'gsml:occurrence/@owns'], ['mappedfeature_pkid', 'gsml:occurrence/gsml:MappedFeature']]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer gwaquifersystem with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='gwaquifersystem'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['href', 'gwml2:gwAquiferSystem/@xlink:href'], ['title', 'gwml2:gwAquiferSystem/@xlink:title'], ['nilreason', 'gwml2:gwAquiferSystem/@nilReason'], ['owns', 'gwml2:gwAquiferSystem/@owns']]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer gw_confiningbed_observationmethod_observationmethod with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='gw_confiningbed_observationmethod_observationmethod'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['occurrence', NULL], ['parent_pkid', NULL], ['child_pkid', NULL]]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer gw_confiningbed_occurrence_occurrence with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='gw_confiningbed_occurrence_occurrence'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['occurrence', NULL], ['parent_pkid', NULL], ['child_pkid', NULL]]
2022-03-02T14:47:29     NONE    DEBUG Get fields of layer gw_confiningbed_gwaquifersystem_gwaquifersystem with query : select field_name, field_xpath from _ogr_fields_metadata where layer_name='gw_confiningbed_gwaquifersystem_gwaquifersystem'
2022-03-02T14:47:29     NONE    DEBUG List of fields : [['occurrence', NULL], ['parent_pkid', NULL], ['child_pkid', NULL]]
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=category, geometry=None, provider=spatialite, ln=category, xpath=swe:Category, uid=ogr_pkid
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=gw_confiningbed, geometry=None, provider=spatialite, ln=gw_confiningbed, xpath=gwml2:GW_ConfiningBed, uid=id
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=gw_confiningbed_gwaquifersystem_gwaquifersystem, geometry=None, provider=spatialite, ln=gw_confiningbed_gwaquifersystem_gwaquifersystem, xpath=NULL, uid=NULL
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=gw_confiningbed_gwconfinedaquifer, geometry=None, provider=spatialite, ln=gw_confiningbed_gwconfinedaquifer, xpath=gwml2:GW_ConfiningBed/gwml2:gwConfinedAquifer, uid=ogr_pkid
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=gw_confiningbed_name, geometry=None, provider=spatialite, ln=gw_confiningbed_name, xpath=gwml2:GW_ConfiningBed/gml:name, uid=ogr_pkid
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=gw_confiningbed_observationmethod_observationmethod, geometry=None, provider=spatialite, ln=gw_confiningbed_observationmethod_observationmethod, xpath=NULL, uid=NULL
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=gw_confiningbed_occurrence_occurrence, geometry=None, provider=spatialite, ln=gw_confiningbed_occurrence_occurrence, xpath=NULL, uid=NULL
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=gwaquifersystem, geometry=None, provider=spatialite, ln=gwaquifersystem, xpath=gwml2:gwAquiferSystem, uid=ogr_pkid
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=mappedfeature, geometry=shape, provider=spatialite, ln=mappedfeature, xpath=gsml:MappedFeature, uid=id
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=mappedfeature_observationmethod, geometry=None, provider=spatialite, ln=mappedfeature_observationmethod, xpath=gsml:MappedFeature/gsml:observationMethod, uid=ogr_pkid
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=observationmethod, geometry=None, provider=spatialite, ln=observationmethod, xpath=gsml:observationMethod, uid=ogr_pkid
2022-03-02T14:47:29     INFO    DEBUG Load layer with uri=dbname='C:/Users/risor/Documents/GIS DataBase/BRGM/20210525_HydroGeoUnit.sqlite', schema=None, layer=occurrence, geometry=None, provider=spatialite, ln=occurrence, xpath=gsml:occurrence, uid=ogr_pkid
2022-03-02T14:47:29     NONE    DEBUG Add relations 1:1 with query : select
              layer_name, field_name, field_related_layer, r.child_pkid
             from
              _ogr_fields_metadata f
              join _ogr_layer_relationships r
              on r.parent_layer = f.layer_name
              and r.parent_element_name = f.field_name
             where
              field_category in ('PATH_TO_CHILD_ELEMENT_WITH_LINK', 'PATH_TO_CHILD_ELEMENT_NO_LINK')
              and field_max_occurs=1
             
2022-03-02T14:47:29     NONE    DEBUG Relations 1:1 : [['gw_confiningbed_gwconfinedaquifer', 'gw_aquiferunit_gw_confiningbed_pkid', 'gw_confiningbed', 'id'], ['mappedfeature', 'specification_abstractfeature_gw_confiningbed_pkid', 'gw_confiningbed', 'id'], ['mappedfeature', 'specification_abstractfeature_mappedfeature_pkid', 'mappedfeature', 'id'], ['mappedfeature_observationmethod', 'category_pkid', 'category', 'ogr_pkid'], ['observationmethod', 'category_pkid', 'category', 'ogr_pkid'], ['occurrence', 'mappedfeature_pkid', 'mappedfeature', 'id']]
2022-03-02T14:47:29     NONE    DEBUG Add relations 1:N with query : select
              layer_name, r.parent_pkid, field_related_layer as child_layer, r.child_pkid
             from
              _ogr_fields_metadata f
              join _ogr_layer_relationships r
              on r.parent_layer = f.layer_name
              and r.child_layer = f.field_related_layer
             where
              field_category in ('PATH_TO_CHILD_ELEMENT_WITH_LINK', 'PATH_TO_CHILD_ELEMENT_NO_LINK')
              and field_max_occurs>1
             -- junctions - 1st way
             union all
             select
              layer_name, r.parent_pkid, field_junction_layer as child_layer, 'parent_pkid' as child_pkid
             from
              _ogr_fields_metadata f
              join _ogr_layer_relationships r
              on r.parent_layer = f.layer_name
              and r.child_layer = f.field_related_layer
             where
              field_category = 'PATH_TO_CHILD_ELEMENT_WITH_JUNCTION_TABLE'
             -- junctions - 2nd way
             union all
             select
              field_related_layer as layer_name, r.child_pkid, field_junction_layer as child_layer, 'child_pkid' as child_pkid
             from
              _ogr_fields_metadata f
              join _ogr_layer_relationships r
              on r.parent_layer = f.layer_name
              and r.child_layer = f.field_related_layer
             where
              field_category = 'PATH_TO_CHILD_ELEMENT_WITH_JUNCTION_TABLE'
             
2022-03-02T14:47:29     NONE    DEBUG Relations 1:N : [['gw_confiningbed', 'id', 'gw_confiningbed_name', 'parent_id'], ['gw_confiningbed', 'id', 'gw_confiningbed_gwconfinedaquifer', 'parent_id'], ['mappedfeature', 'id', 'mappedfeature_observationmethod', 'parent_id'], ['gw_confiningbed', 'id', 'gw_confiningbed_observationmethod_observationmethod', 'parent_pkid'], ['gw_confiningbed', 'id', 'gw_confiningbed_occurrence_occurrence', 'parent_pkid'], ['gw_confiningbed', 'id', 'gw_confiningbed_gwaquifersystem_gwaquifersystem', 'parent_pkid'], ['observationmethod', 'ogr_pkid', 'gw_confiningbed_observationmethod_observationmethod', 'child_pkid'], ['occurrence', 'ogr_pkid', 'gw_confiningbed_occurrence_occurrence', 'child_pkid'], ['gwaquifersystem', 'ogr_pkid', 'gw_confiningbed_gwaquifersystem_gwaquifersystem', 'child_pkid']]

@frida-161
Copy link
Contributor

I have run into the same error from time to time.
I tried to reproduce it right now but it just seems to happen only once in a while.

What I think happens is that that in some cases when the QgsProviderConnectionException is catched, it gets logged but the plugin still throws an error afterwards because in that case results is not defined.

This could be fixed by defining result (as and empty list) before the try block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Houston, we've a problem!
Projects
None yet
Development

No branches or pull requests

3 participants