[Qgis-developer] PostGIS warning details in QGIS master

Rouzaud Denis denis.rouzaud at gmail.com
Fri Oct 3 01:37:17 PDT 2014


QGIS is not pasting the field of the primary key to avoid conflict.

I am not sure to understand your problem.

I tested with two postgis layers having a primary key. In both layers, I have a feature with pkey = 1. I copy/paste from layer 1 to layer 2, and at end I have two features in layer 2, one with pkey= 1 and the second with pkwy =2.

paste was successful.

Could you provide a small dump of your postgis layers and the exact steps to reproduce?





On 03 Oct 2014, at 01:48, Pedro Venâncio <pedrongvenancio at gmail.com> wrote:

> Hi Denis,
> 
> I just tested on Linux, with two simple shapefiles (attached), with only two lines each. Making a copy of the shapefiles, all goes well.
> 
> If you import the shapefiles to postgis (with dbmanager) to multilinestring, they stay with equal pkeys. When I do the copy / paste (which worked fine with the same data in shapefile format), QGIS shows the warning message "Paste features: no features could be successfully pasted.". Running QGIS with GNU gdb, does not appear any error at the time the warning is shown.
> 
> I also tested this with points, multipoints, and Multipolygons, and the same happens.
> 
> The proof that I believe show that the problem is in primary key is:
> 
> importing the two layers attached to the postgis with dbmanager, you get
> 
> layer_1
> id_0* | id | desc
> 1 | 1 | 1
> 2 | 2 | 2
> 
> layer_2
> id_0* | id | desc
> 1 | 1 | 1
> 2 | 2 | 2
> 
> *pkey
> 
> If I delete the second line of layer_2, and copy the second line of layer_1 and paste on layer_2, it already works, and layer_2 becomes:
> 
> layer_2
> id_0* | id | desc
> 1 | 1 | 1
> 3 | 2 | 2
> 
> (id_0 is 3 because of the sequence).
> 
> The only explanation I find for this behavior is QGIS verify the violation of unique constraint of pkey field id_0, and launch the warning and prevent the pasting.
> 
> What do you think?
> 
> Thanks!
> 
> Best regards,
> Pedro
> 
> 
> 
> 
> 2014-10-02 14:42 GMT+01:00 Rouzaud Denis <denis.rouzaud at gmail.com>:
> Hi Pedro,
> 
> As said, copy/paste only tries to convert geometries and will paste if possible.
> 
> Foreign key violation is only detected by Postgis, so the reason why QGIS is not actually pasting is not due to a FKey violation.
> 
> Do you have a debugging environment or can you provide some demo data?
> 
> Best wishes,
> 
> Denis
> <qgis_25_copy_paste.zip>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20141003/c1cf3c6a/attachment.html>


More information about the Qgis-developer mailing list