[Qgis-user] Relations in .qlr not restored ?

Alessandro Pasotti apasotti at gmail.com
Wed May 6 00:45:59 PDT 2020


On Wed, May 6, 2020 at 9:26 AM Yann Voté <ygversil at lilo.org> wrote:
>
> Hi all,
>
> I've recently discovered a somewhat unadvertised new feature in QGIS
> 3.12: relations can now be exported as styles!
>
> Consequently, when exporting a bunch of layers as a QGIS Layer
> Definition file (.qlr), relations for each layer are now saved under the
> tags `<referencedLayers>` and `<referencingLayers>`.
>
> But when loading back the .qlr file, relations are not restored: project
> relations are empty. Am I missing something ? Is this by design ? A
> feature request ?
>
> Anyway, thanks to all developers and team for the excellent work !
>
> Regards.
>
> Yann
>

Hi Yann,

yes, the relations are now saved within the configuration of the form
widgets that are supposed to use them.

The idea behind that development is that we are now able to
automatically restore relations (and automatically search and load
related layers) when a layer is loaded (or restored if it was a "bad
layer") if the associated style uses a relation (i.e. the style uses a
form that requires a relation, such as relation-reference, but
value-relation also triggers automatic loading).

Coming to your question: it should work, given that the related layers
can be found.
Layers are searched by id, then name and a few providers (postgres)
can also automatically scan for the tables with the same name in the
"current" schema and in other schemas of the same DB of the original
layer (the one stored in the relation information in the style).

You can have a look to the PRs for further details:
https://github.com/qgis/QGIS/pull/33283
https://github.com/qgis/QGIS/pull/33103
https://github.com/qgis/QGIS/pull/32487

Hope this helps.

-- 
Alessandro Pasotti
QCooperative:  www.qcooperative.net
ItOpen:   www.itopen.it


More information about the Qgis-user mailing list