opengisch / QgisModelBaker

Create QGIS projects from database schemas or Interlis models
https://opengisch.github.io/QgisModelBaker/
GNU Lesser General Public License v3.0
55 stars 17 forks source link

Adding new features to classes who are connected by two relations #913

Closed margruene closed 5 months ago

margruene commented 5 months ago

We have a model where we have two classes who are connected through two relations. When we start editing in the class and then directly try to create a geometry within the other class using the same editing mask, it is not possible to safe the edits.

In the ZIP-File, I uploaded the respective model.

SZ_Waldfeststellungen_V2 _Test.zip

signedav commented 5 months ago

I can imagine that sometimes QGIS has limits when having kind of recursive workflows. Still I think this should work like creating a Waldgrenze, there a rBegruendung and in the rBegruendung a Waldgrenze for the rAufhebung etc. Played around a little bit and it worked. Can you clearly note the steps to reproduce... And yes, GeoPackage or PosgreSQL ?

margruene commented 5 months ago

Thank You for the response. I could reproduce the error only within the GeoPackage. I tried to describe it in the image in the appendix. The crucial step, that causes the error would be step No. 8. It seems like the child cannot be saved before the parent. Though, I can adjust the layer properties so that the option which causes the error "Save child layer edits" will not be shown to the user. So I could ommit that the user can create an error while editing. With PostgreSQL, the "save-button" will not be displayed, so I could not reproduce the error there... I appologize for the bad quality of the screenshots. error_reproduction_complete

signedav commented 5 months ago

Yes. You cannot save the child before the parent. In PG you would have the same problem but there Model Baker sets the Automatic Transaction Groups Mode in the project settings. With this, all the edits are stored in one single transaction to the database and you won't have this parent-child-problem. On GeoPackage this mode leaded to issues (DB locks) in the past, why Model Baker does not set it by default.

But you can choose this mode for GeoPackage as well: Project > Properties... and there Data Sources...

image

Buffered Transaction Groups is another mode created for GeoPackage (and less powerfull DBs) but lately I did not encounter big problems with Automatic Transaction Groups Mode on GeoPackage why I suggest you to try this out. Do some nested operation for tests and if you don't encounter problems I think it's a good sollution for you.

If not, then you have to save your layers in the correct order. Means after adding Waldfeststellungen and Waldgrenzen, first save layer Waldfeststellungen and after Waldgrenzen..

margruene commented 5 months ago

Many thanks for the detailed explanation. The solution that you outlined in the comment is perfect for us.