[QGIS-trac] [Quantum GIS] #1338: nextval values of a postgis layer are not saved

Quantum GIS qgis at qgis.org
Tue Oct 7 06:02:49 EDT 2008


#1338: nextval values of a postgis layer are not saved
---------------------------------------------------------+------------------
   Reporter:  cmoe                                       |              Owner:  nobody       
       Type:  bug                                        |             Status:  new          
   Priority:  critical: causes crash or data corruption  |          Milestone:  Version 1.0.0
  Component:  Data Provider                              |            Version:  HEAD         
   Keywords:  Postgis default values                     |   Platform_version:               
   Platform:  RedHat                                     |           Must_fix:  Yes          
Status_info:  0                                          |  
---------------------------------------------------------+------------------
 I'm trying to edit a postgis table (feature type point) like the
 following:
 {{{
 CREATE TABLE avt_oev_haltestellen
 (
   ogc_fid integer NOT NULL DEFAULT
 nextval(('"avt_oev_haltestelle_ogc_fid_seq"'::text)::regclass), -- OGC
 Feature ID
   wkb_geometry geometry, -- OGC WKB Geometrie
   haltest_id integer NOT NULL DEFAULT
 nextval(('"avt_oev_haltest_id_seq"'::text)::regclass),
   anzahl_hs integer,
   new_date date DEFAULT ('now'::text)::date,
   archive_date date DEFAULT '9999-01-01'::date,
   archive integer DEFAULT 0,
   CONSTRAINT avt_oev_haltestellen_pkey PRIMARY KEY (ogc_fid),
   CONSTRAINT haltest_id_unique UNIQUE (haltest_id),
   CONSTRAINT "$1" CHECK (srid(wkb_geometry) = (-1)),
   CONSTRAINT "$2" CHECK (geometrytype(wkb_geometry) = 'POINT'::text OR
 wkb_geometry IS NULL)
 )
 }}}

 If I add a point the enter attribute values dialog pops up, with all the
 default values written in the fields. If I try to save it now,
 qgis/postgis answers that 'ERROR:  null value in column "haltest_id"
 violates not-null constraint'. If I overwrite the nextval command/function
 of this fields with a number it works. Seems like the nextval only is
 working for the primary key. The other defaults in the example work.

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/1338>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list