[Qgis-developer] Hidden fields inserts null values rather than not inserting the field at all

Olivier Dalang olivier.dalang at gmail.com
Fri Apr 18 10:28:55 PDT 2014


Hi !

When inserting features on a postgis table, it seems columns whose widget
is hidden are set to null, rather than not inserted at all.

If I hide (or set to readonly) the "id" column (a good idea anyways), it
make the following query on creating features:
INSERT INTO mytable("id","name","geometry") VALUES (null,'abc',geom)
But the user intends to do this query:
INSERT INTO mytable("name","geometry") VALUES ('abc',geom)

It seem QGIS is clever enough to fix the obvious problem for the primary
key of the tables (since one doesn't get not-null constrain violation upon
inserts), but is not clever enough to make it work on views (for whose you
get that non-null violation).

Postgres' views are editable by default when on single tables without
needing any rule/trigger, which is a very neat feature. But it's unusable
in QGIS for now because of this.

I think we should make it work as state above, maybe even removing the fix
for the primary id, but rather set the form to "readonly" by default for
autoincrementing primary fields.

What do you think ? Should I file a bug ? Am I missing something ?

Thanks and happy easters !

Olivier Dalang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140418/1da14074/attachment-0001.html>


More information about the Qgis-developer mailing list