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

Database default values don't work in QGIS #420

Closed
ponceta opened this issue Sep 18, 2024 · 3 comments · Fixed by #502
Closed

Database default values don't work in QGIS #420

ponceta opened this issue Sep 18, 2024 · 3 comments · Fixed by #502
Labels
bug Something isn't working QGIS project Concern the .qgs QGIS project

Comments

@ponceta
Copy link
Member

ponceta commented Sep 18, 2024

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):

  • TWW version
  • QGIS Version
  • OS

Additional context
Add any other context about the problem here.

@ponceta ponceta added bug Something isn't working QGIS project Concern the .qgs QGIS project labels Sep 18, 2024
@cymed
Copy link
Contributor

cymed commented Sep 26, 2024

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.

CREATE OR REPLACE FUNCTION tww_app.ft_set_default_values()

@sjib
Copy link
Contributor

sjib commented Oct 3, 2024

see also #425

@ponceta
Copy link
Member Author

ponceta commented Nov 27, 2024

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?

DROP TRIGGER IF EXISTS set_default_values ON tww_od.default_values;
CREATE TRIGGER set_default_values
BEFORE INSERT OR UPDATE
ON tww_od.default_values
FOR EACH ROW
EXECUTE PROCEDURE tww_app.ft_set_default_values();

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.

@cymed cymed linked a pull request Nov 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working QGIS project Concern the .qgs QGIS project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants