I am using QGIS with a PostgreSQL/PostGIS database, where the lines table (named 'segments'), besides the integer serial primary key, has a UUID column having a UNIQUE constraint. Trying to split a line with the SplitFeatures tool of the Advanced Digitizing toolbar fails to commit to the database because the new line that is created after the split, has the same uuid of the original line and therefore violates the database constraint.
In order to simulate the way the primary key is generated using the PostgreSQL sequence generator
, I have tried to manually set a default value in the database using a random uuid generated by:
uuid_generate_v5(uuid_ns_url(), ( (md5(((random())::text || (clock_timestamp())::text)))::cstring))
but this does not work. QGIS continues to duplicate the uuid of the original line to both lines that occur after the split. (Tested that after removing the UNIQUE constraint)
Also tried to include the uuid column into the primary key definition, along with the integer serial. Did not work either.
I assume that QGIS must have a way to identify such columns with constraints when splitting features, because it handles properly the auto-increment of the primary key.
Environment: QGIS 2.8.5-Wien, PostgreSQL 9.4