Forms, realtions and foreign keys

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Forms, realtions and foreign keys

Karl Magnus Jönsson

Hi list!

I have a project with tree tabels stored in PostGIS. One is holding the geometry the other two is holding data related to the first table as child and grandchild. I have set up foreign keys between the tables in the database to be sure that there will be no orphan records. In QGIS there are relations and (sub)forms. When I digitize a new geometry I get the new id from the database (before it’s saved, OK) in the form but I can’t add any children. I get a database error that says that there are no parent with that ID (and that’s true). I have to  press OK to create the feature in QGIS, change tool to identify, find the feature and klick on it to open the form again. Then I can add children. But I haven’t saved so there is still no parent. But it works then. It’s the same with the grandchild table but then the grandparent form is still open so it’s not such a big problem. Anyone got a better way to skip this closing and reopening of the form in the workflow?

 

Karl-Magnus Jönsson | Gis-Utvecklare
Geografisk information
Miljö- och samhällsbyggnadsförvaltningen
Kristianstads kommun
Besöksadress: Västra Storgatan 12
Postadress: 291 80 KRISTIANSTAD
Telefon: 044-135416 | Mobil: 0733-135416
E-post:
[hidden email]
www.kristianstad.se

 

Läs mer om hur vi hanterar dina personuppgifter på www.kristianstad.se/personuppgifter

 


_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Forms, realtions and foreign keys

Matthias Kuhn 🌍

Hello,

If you enable "evaluate default values server side" and "automatic transaction groups" and set the foreign key check in the database to initially deferred you'll get pretty much what you want :)

Hope that helps

Matthias

On 6/4/19 11:14 AM, Karl Magnus Jönsson wrote:

Hi list!

I have a project with tree tabels stored in PostGIS. One is holding the geometry the other two is holding data related to the first table as child and grandchild. I have set up foreign keys between the tables in the database to be sure that there will be no orphan records. In QGIS there are relations and (sub)forms. When I digitize a new geometry I get the new id from the database (before it’s saved, OK) in the form but I can’t add any children. I get a database error that says that there are no parent with that ID (and that’s true). I have to  press OK to create the feature in QGIS, change tool to identify, find the feature and klick on it to open the form again. Then I can add children. But I haven’t saved so there is still no parent. But it works then. It’s the same with the grandchild table but then the grandparent form is still open so it’s not such a big problem. Anyone got a better way to skip this closing and reopening of the form in the workflow?

 

Karl-Magnus Jönsson | Gis-Utvecklare
Geografisk information
Miljö- och samhällsbyggnadsförvaltningen
Kristianstads kommun
Besöksadress: Västra Storgatan 12
Postadress: 291 80 KRISTIANSTAD
Telefon: 044-135416 | Mobil: 0733-135416
E-post:
[hidden email]
www.kristianstad.se

 

Läs mer om hur vi hanterar dina personuppgifter på www.kristianstad.se/personuppgifter

 


_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Forms, realtions and foreign keys

Karl Magnus Jönsson

Thanks. Works perfect. I  missed the ”initially deferred” in the FK.

 

Karl-Magnus

 

Från: Qgis-user [mailto:[hidden email]] För Matthias Kuhn
Skickat: den 4 juni 2019 11:27
Till: [hidden email]
Ämne: Re: [Qgis-user] Forms, realtions and foreign keys

 

Hello,

If you enable "evaluate default values server side" and "automatic transaction groups" and set the foreign key check in the database to initially deferred you'll get pretty much what you want :)

Hope that helps

Matthias

On 6/4/19 11:14 AM, Karl Magnus Jönsson wrote:

Hi list!

I have a project with tree tabels stored in PostGIS. One is holding the geometry the other two is holding data related to the first table as child and grandchild. I have set up foreign keys between the tables in the database to be sure that there will be no orphan records. In QGIS there are relations and (sub)forms. When I digitize a new geometry I get the new id from the database (before it’s saved, OK) in the form but I can’t add any children. I get a database error that says that there are no parent with that ID (and that’s true). I have to  press OK to create the feature in QGIS, change tool to identify, find the feature and klick on it to open the form again. Then I can add children. But I haven’t saved so there is still no parent. But it works then. It’s the same with the grandchild table but then the grandparent form is still open so it’s not such a big problem. Anyone got a better way to skip this closing and reopening of the form in the workflow?

 

Karl-Magnus Jönsson | Gis-Utvecklare
Geografisk information
Miljö- och samhällsbyggnadsförvaltningen
Kristianstads kommun
Besöksadress: Västra Storgatan 12
Postadress: 291 80 KRISTIANSTAD
Telefon: 044-135416 | Mobil: 0733-135416
E-post:
[hidden email]
www.kristianstad.se

 

Läs mer om hur vi hanterar dina personuppgifter på www.kristianstad.se/personuppgifter

 



_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user