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

  • I have the same problem: a postgis table like this: gid | integer | non null preimpostato nextval('fogn_tronchi_gid_seq'::regclass) anno | numeric(10,0) | codice_via | numeric(10,0) | diametro | numeric(10,0) | id_n1 | character varying(255) | id_n2 | character varying(255) | materiale | character varying(255) | nome_via | character varying(255) | note | character varying(255) | pendenza | numeric | pend_ind | numeric | proprieta | character varying(255) | qfondo_mon | numeric | qfondo_val | numeric | regime | character varying(255) | stato_cons | character varying(255) | tipologia | character – Luca Pauluzzi Jun 27 '17 at 13:05
  • Welcome to GIS:SE @LucaPauluzzi! Please ask this as a new question instead of posting it as an answer. You can always add a link to this post in your question to show you did some research :) – Joseph Jun 27 '17 at 13:24
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – mgri Jun 27 '17 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.