Bug report #19671
The Ok button for the form dialog is disabled for NOT NULL Postgres columns
|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|
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.
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
#3 Updated by Tudor Bărăscu almost 3 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
Thank you for taking a look Alessandro!
#4 Updated by Alessandro Pasotti almost 3 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 :)
#11 Updated by Hugo Mercier over 2 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