I have a Multipolygon-Layer stored in a PostgreSQL/PostGIS database. The primary key field 'gid' is SERIAL. When trying to add a new polygon in QGIS (LYON 2.12.1 on OSX El Capitan), the attributes form shows me:
nextval('test_gid_seq'::regclass) for the gid field (which is the correct sequence to autoincrement the field).
When I try to save the edits, I always get an error:
ERROR: duplicate key value violates unique constraint "test_pkey" DETAIL: Key (gid)=(1) already exists.
This is strange, since the actual value in the sequence is 114. Why does QGIS tries to use 1? Is this a bug in QGIS? Or does anybody know how to avoid these problems?