Bug report #19671
The Ok button for the form dialog is disabled for NOT NULL Postgres columns
Status: | Open | ||
---|---|---|---|
Priority: | High | ||
Assignee: | - | ||
Category: | Forms | ||
Affected QGIS version: | 3.5(master) | Regression?: | Yes |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 27496 |
Description
Some Postgres NOT NULL columns are filled automatically database side but the QGIS Dialog enforces filling of values. I found no way to disable this.
To recreate:
CREATE TABLE testtable (id serial PRIMARY KEY, status integer NOT NULL, geom geometry(Point, 4326));
- Add the table to a project.
- Imagine there's a trigger/function that fills the status column automatically.
- Try and add a feature without filling the status column
- Problem: Cannot Save the dialog
Related issues
History
#1 Updated by Alessandro Pasotti about 6 years ago
How do you think QGIS would know if a NOT NULL column is filled by a trigger?
Do you have any solution in mind?
#2 Updated by Alessandro Pasotti about 6 years ago
- Status changed from Open to Feedback
#3 Updated by Tudor Bărăscu about 6 years ago
- File problem1.jpg added
From my perspective, it should all function like this:
- When QGIS detects the NOT NULL column, the QGIS side NOT NULL contraint should be enabled automagically
- However, the user should have the option to disable it
The user should be able to uncheck the Not Null checkbox in the constraints part
Sounds good?
Thank you for taking a look Alessandro!
#4 Updated by Alessandro Pasotti about 6 years ago
- Tracker changed from Bug report to Feature request
That sounds reasonable to me, perhaps also issue a warning when the user unticks the checkbox: "The fields is marked NOT NULL but you are overriding this check, if you do not fill this field and there is nothing to set its value the operation will probably be rejected by the backend".
Changing to feature request (ok, I know it's debatable :)
#5 Updated by Tudor Bărăscu about 6 years ago
- Status changed from Feedback to Open
#6 Updated by Nyall Dawson about 6 years ago
- Assignee set to Nyall Dawson
#7 Updated by Nyall Dawson about 6 years ago
- Status changed from Open to Feedback
- Assignee deleted (
Nyall Dawson)
Does this relate to #20073 ?
#8 Updated by Tudor Bărăscu about 6 years ago
@Nyall Yes! IMHO It's ok that the forms get the constraints automatically but the settings of the constraints should override this.
#9 Updated by Tudor Bărăscu about 6 years ago
- Status changed from Feedback to Open
A workaround would be to simply fill those specific columns with a default value, -1 let's say and it will let you pass while the database logic will change it to what's supposed to be.
#10 Updated by Hugo Mercier almost 6 years ago
- Related to Bug report #20831: Range widget does not honor default value on not null column added
#11 Updated by Hugo Mercier almost 6 years ago
Tudor, about your proposed workaround, I observed this is not even possible when the primary key has the default widget "Range". It seems the Range widget does not take the default value into account. However changing the widget type to "Text editor" allows to use a default value (and postgres is ok to receive a text for an integer)
Related issue #20831
#12 Updated by Hugo Mercier almost 6 years ago
- Assignee set to Hugo Mercier
#13 Updated by Hugo Mercier almost 6 years ago
- Assignee deleted (
Hugo Mercier)
#14 Updated by Jürgen Fischer almost 6 years ago
- Tracker changed from Feature request to Bug report
- Affected QGIS version set to 3.5(master)
- Crashes QGIS or corrupts data set to No
- Regression? set to Yes