<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Here is the reply concerning copy/pase with primary keys on postgis.<br>
<br>
Jürgen, can you comment this?<br>
<br>
Thanks,<br>
<br>
Denis<br>
<br>
<br>
<div class="moz-cite-prefix">On 03. 02. 14 09:40, F T wrote:<br>
</div>
<blockquote
cite="mid:CABmeFjffpa=5r7wPvWEwD24OzTrqzbG0GPmxAWJ-Kdw1+7qV+Q@mail.gmail.com"
type="cite">
<div dir="ltr">
<pre>Hi,
QGis should not deal with Postgre SQl explicit primary keys.
</pre>
<pre>It is postgreSQL to manage the explicit primary key.
</pre>
<pre>With Qgis 1.7.4, copy/paste with explicit primary keys where ok
If QGis 1.7.4 sends a unique primary key, PostgreSQL accept it, if the explicit key is not unique, it reject it.
QGis 2.0 brings a regression, it put all the primary keys to null...
</pre>
<pre>Denis 's workaround to add a serial to the table and a constraint (unique not null) to the explicit primary key is not a solution for us.
</pre>
<pre>We have a lots of tables that are used not only with QGis...
</pre>
<pre>Changing all the tables just because QGis 2.0 needs a non-standard feature is a pain.
</pre>
<pre>And QGis 1.7.4 was doing this copy/paste job fine.
</pre>
<pre>However, this is a QGis 2.0 pb and not a postgis pb.
</pre>
<pre>I will continue on the QGis List
</pre>
<pre>Thanks
</pre>
<pre>Fabrice
</pre>
<pre>
------------------------------
Hi,
QGIS prevent to overwrite the primary key field when it copies/pastes,
this is why it leaves the field empty.
One way would be to add the constraint after the copy/paste if it's for
a single shot.
Otherwise, just add a unique constraint on f1 and add a serial as
primary key.
Cheers,
Denis
On 31. 01. 14 15:02, F T wrote:
><i> Hello
</i>><i>
</i>><i> We have a pb with copy/paste from a shapefile to postgis if the
</i>><i> primary key is a string.
</i>><i> The primary key is left NULL and no commit is possible.
</i>><i>
</i>><i> To reproduce the pb :
</i>><i>
</i>><i> Create *table1 *with a string primary key
</i>><i>
</i>><i> CREATE TABLE table1
</i>><i> (
</i>><i> f1 character varying(10) NOT NULL,
</i>><i> f2 character varying(10),
</i>><i> geom geometry,
</i>><i> *CONSTRAINT t1_pkey PRIMARY KEY (f1),*
</i>><i> CONSTRAINT enforce_dims_geom CHECK (st_ndims(geom) = 2),
</i>><i> CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) =
</i>><i> 'POINT'::text),
</i>><i> CONSTRAINT enforce_srid_geom CHECK (st_srid(geom) = 2154)
</i>><i> )
</i>><i>
</i>><i>
</i>><i> *table2* is the same as table 1 but it has no primary key
</i>><i>
</i>><i> CREATE TABLE table2
</i>><i> (
</i>><i> f1 character varying(10) NOT NULL,
</i>><i> f2 character varying(10),
</i>><i> geom geometry,
</i>><i> CONSTRAINT enforce_dims_geom CHECK (st_ndims(geom) = 2),
</i>><i> CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) =
</i>><i> 'POINT'::text),
</i>><i> CONSTRAINT enforce_srid_geom CHECK (st_srid(geom) = 2154)
</i>><i> )
</i>><i>
</i>><i>
</i>><i> *shapes.shp* is a shapefile that contains the points I would like to
</i>><i> copy/paste in the Postgis tables
</i>><i> (see attached zip file)
</i>><i>
</i>><i> 1) if I copy/paste the points from shapes.shp to table1, the key field
</i>><i> stays NULL and the commit is impossible.
</i>><i> 2) if I copy/paste the points from shapes.shp to table2, everything is ok.
</i>><i>
</i>><i> Have you ever seen this bug?
</i>><i>
</i>><i> Thanks
</i>><i>
</i>><i> Fabrice</i></pre>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a></pre>
</blockquote>
<br>
</body>
</html>