qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.14k stars 2.93k forks source link

The Ok button for the form dialog is disabled for NOT NULL Postgres columns #27496

Open qgib opened 5 years ago

qgib commented 5 years ago

Author Name: Tudor Bărăscu (@tudorbarascu) Original Redmine Issue: 19671 Affected QGIS version: 3.5(master) Redmine category:forms


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

problem.jpg



Related issue(s): #28650 (relates) Redmine related issue(s): 20831


qgib commented 5 years ago

Author Name: Alessandro Pasotti (@elpaso)


How do you think QGIS would know if a NOT NULL column is filled by a trigger?

Do you have any solution in mind?

qgib commented 5 years ago

Author Name: Alessandro Pasotti (@elpaso)


qgib commented 5 years ago

Author Name: Tudor Bărăscu (@tudorbarascu)


From my perspective, it should all function like this:

Sounds good?

Thank you for taking a look Alessandro!



qgib commented 5 years ago

Author Name: Alessandro Pasotti (@elpaso)


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


qgib commented 5 years ago

Author Name: Tudor Bărăscu (@tudorbarascu)


qgib commented 5 years ago

Author Name: Nyall Dawson (@nyalldawson)


qgib commented 5 years ago

Author Name: Nyall Dawson (@nyalldawson)


Does this relate to #27895 ?


qgib commented 5 years ago

Author Name: Tudor Bărăscu (@tudorbarascu)


@Nyall Yes! IMHO It's ok that the forms get the constraints automatically but the settings of the constraints should override this.

qgib commented 5 years ago

Author Name: Tudor Bărăscu (@tudorbarascu)


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.


qgib commented 5 years ago

Author Name: Hugo Mercier (@mhugo)


qgib commented 5 years ago

Author Name: Hugo Mercier (@mhugo)


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 #28650

qgib commented 5 years ago

Author Name: Hugo Mercier (@mhugo)


qgib commented 5 years ago

Author Name: Hugo Mercier (@mhugo)


qgib commented 5 years ago

Author Name: Jürgen Fischer (@jef-n)


Pedro-Murteira commented 2 years ago

Still valid on QGIS 3.22.3.