teksi / wastewater

[DEV] Future TEKSI wastewater module, adapted data model to fit VSA-DSS 2020 new standard
https://teksi.github.io/wastewater
GNU General Public License v3.0
2 stars 5 forks source link

Database default values don't work in QGIS #420

Open ponceta opened 2 months ago

ponceta commented 2 months ago

Describe the bug Database default values only work database side but are overwritten by QGIS

To Reproduce Exact steps to reproduce the behavior:

  1. Open TWW QGIS project
  2. Define values for fk_provider and fk_dataowner
  3. Create a Wastewater structure
  4. default fk_provider and fk_dataowner are not displayed
  5. Click ok and reopen the same form
  6. fk_provider and fk_dataowner are not selected

Expected behavior A user can define default fk_provider and fk_dataowner in QGIS too.

Screenshots / data image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

cymed commented 2 months ago

When did you create your default values entries? We only set the default values on od (using tww_app.set_default_values) by using a trigger on tww_od.default_values. https://github.com/teksi/wastewater/blob/c7c7e36b71a8bbde9aa1da13dd17347300e74007/datamodel/app/functions/organisation_functions.sql#L57

sjib commented 1 month ago

see also https://github.com/teksi/wastewater/issues/425

ponceta commented 15 hours ago

Default values have been inserted :

image

But when the db queries it, it returns NULL :

image

Is it right to call it BEFORE the INSERT?

https://github.com/teksi/wastewater/blob/4a9d9bb469c5335bec06b7e822f93cbe833763bf/datamodel/app/functions/organisation_functions.sql#L124-L130

My current workaround is to define QGIS variables :

image

But this will require some project configurations and I would rather have a db working solution.