bstroebl / DigitizingTools

A QGIS plugin, that subsumes different tools useful during digitizing sessions
GNU General Public License v2.0
22 stars 9 forks source link

Make "Split Features" tool aware of PostgreSQL/PostGIS sequence #31

Closed andywicht closed 6 years ago

andywicht commented 6 years ago

The default value for the ID attribute of the new feature is set to NULL when splitting a feature. This behavior is not desirable when dealing with an ID column which is filled by a sequence and NOT NULL, because that means, you have to define a value for that attribute manually when using the QGIS "Edit Feature Form".

edit_attributes DigitizingTools

It would be very helpful here to copy the behavior of the QGIS core "Split Features" tool, which automatically inserts the nextval() call of the sequence and therefore the attribute is NOT NULL and does not have to be changed manually.

edit_attributes_2 QGIS core

A workaround is, to use the attribute table to edit the attributes, because the attribute table does not enforce the NOT NULL constraint on the QGIS GUI side like the "Edit Feature Form" does.

Here is the minimal example to reproduce:

create table temp.serial_test (
    gid serial not null primary key,
    poly_name text,
    geom geometry(polygon, 4326)
);

insert into temp.serial_test (poly_name, geom) 
values(
    'test',
    st_geomfromewkt(
        'SRID=4326; Polygon ((-1.189097 0.512776, -1.172061 0.117546, -0.534923 0.049403, -0.613287 0.727427, -1.189097 0.512776))'
    )
);
bstroebl commented 6 years ago

Hi Andy, pleaes check if the new version of the plugin fixes the problem. Thanks for the hint.

andywicht commented 6 years ago

Hi Bernd, I can confirm, works now as expected! Many thanks.