[Qgis-user] QGis 1.7.4 possible bug with PostgreSQL/Postgis manual integer primary key?

F T oukile at gmail.com
Tue May 15 04:07:18 PDT 2012


Hi all,

We are not able to set explicitly the value of an integer primary key field.

It is possible to set this value with pgAdmin.
But when the feature is created with QGis, it takes the next max value of
the field and not the spécified value...

To reproduce this strange behaviour :

-- create a table in the schema public with an integer primary key
CREATE TABLE the_table
(
  the_key integer NOT NULL,
  the_obs character varying(150),
  geom geometry,
  CONSTRAINT the_table_pkey PRIMARY KEY (the_key),
  CONSTRAINT enforce_dims_geom CHECK (st_ndims(geom) = 2),
  CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) =
'MULTILINESTRING'::text OR geom IS NULL),
  CONSTRAINT enforce_srid_geom CHECK (st_srid(geom) = 2154)
)
WITH (
  OIDS=TRUE
);
-- spatialize the table
INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name,
f_geometry_column, coord_dimension, srid, "type") VALUES('', 'public',
'the_table', 'geom', 2, 2154, 'MULTILINESTRING');

Then in QGIS :
- add this table to a project
- create 1 line with the_key=100 and save the edition -> open the attribute
table and you see the_key=0
- create 1 line with the_key=102 and save the edition -> open the attribute
table and you see the_key=1

If I modify the value of the_key in pgAdmin, by example put the value 1000
instead of 1, then the next line created with QGis will have the value 1001.

Any help is welcome !
Thanks

Fabrice
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20120515/75d5765e/attachment.html>


More information about the Qgis-user mailing list