I have a PostGIS database which has a wonderful topology rule (ST_overlap), implemented following "dbaston"s suggestions in this post: Enforce PostGIS constraint that geometries do not overlap .
(I did not post enough on Stack Exchange to add comments directly under the post)
It took me quite a while to ensure the topology in QGIS with lots of manual editing and vertices movement. But eventually, I could add all polygons without an error message regarding overlaps. I saved the PostGIS edits, and everything works fine.
However, if I now try to edit some attributes in my database in the QGIS edit mode, a common exercise that will happen in the future, I get this error message after trying to save the change of attribute:
PostGIS error while changing attributes: ERROR: new row for relation "MyTable" violates check constraint "myOverlapConstraint"
How can this be? Or is PostGIS assuming a new temporal polygon that conflicts with the existing one when I edit attributes?
Weird, as all polygons were saved with the same constraint before and did not produce an error, as said above.
Additional Info: I have tried to edit field values in PGAdmin resulting in the same error message. But if I run:
SELECT *
FROM YourProject.YourTable a
INNER JOIN YourProject.YourTable b ON
(a.geom && b.geom AND ST_Relate(a.geom, b.geom, '2********'))
WHERE a.ctid != b.ctid
LIMIT 1
I get 0 rows are affected.
round(((st_area((geom)::geometry) / (10000)::double precision))::numeric, 4)
ID:nextval('YourProject.YourTable_fid_seq"'::regclass)
could they be the problem?