Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#2137 closed bug (fixed)

Wrong ID provided to the PostGIS on save

Reported by: fsat Owned by: nobody
Priority: major: does not work as expected Milestone: Version 1.4.0
Component: Data Provider Version: Trunk
Keywords: Cc: fsat
Must Fix for Release: No Platform: Gentoo
Platform Version: Awaiting user input: no

Description

I'm trying to use qgis with my PostGIS database. I have only 3 tables for different kinds of components. So I've created a couple of updatable views to make a work with QGIS more comfortable and to keep my internal structure. But when I'm setting a unique ID to the element (in QGIS) I receive a complaints about duplicate ID. For example: I have an empty view (but not empty table with elements), but I know - the ID=15 is unique, I create a new element in the layer associated with this view and set the ID to 15, but on save I receive error. After the empty record created manualy with ID=15 and I'm saving to this view - I see ID's started from 16. Inspite of provided data to ID field it is counted automaticaly.

Attachments (1)

gis.sql (8.2 KB ) - added by fsat 14 years ago.
Database schema

Download all attachments as: .zip

Change History (7)

comment:1 by fsat, 14 years ago

Cc: fsat added

comment:2 by jef, 14 years ago

can you provide sample data?

comment:3 by fsat, 14 years ago

Schema is attached to the ticket, to populate it with sample data just execute the following statements.

insert into maps (ID, NAME) values(1, "map1"); insert into layers (ID, NAME, MAP_ID) values(1, "layer1", 1);


After that you can add LINESTRING layer in QGIS using view with name "map1_l1_l" and draw a line. And after that add POINT layer in QGIS using view with name "map1_l1_s" and reproduce my error.

As you can see from section:

query := 'create or replace rule '
view_name 'i ' '
as on insert to '
view_name '

do instead (

insert into layer_elements (layer_id, id, name) values('insert into '
lid ', NEW.id, NEW.name);
le ' (id, the_geom) values(NEW.id, NEW.the_geom);

)';

The ID is not calculated automaticaly, I'm using the provided one, without defaults.

PostGIS version - 1.4.0, Postgresql version - 8.2.14, QGIS version - 1.3.0

by fsat, 14 years ago

Attachment: gis.sql added

Database schema

comment:4 by fsat, 14 years ago

Sorry, little mistake in queries. Following are correct ones.

insert into maps (ID, NAME) values(1, 'map1');

insert into layers (ID, NAME, MAP_ID) values(1, 'layer1', 1);

comment:5 by jef, 14 years ago

Resolution: fixed
Status: newclosed

should be fixed in r12235 - hopefully without breaking something else.

in reply to:  5 comment:6 by jef, 14 years ago

Replying to jef:

should be fixed in r12235 - hopefully without breaking something else.

actually it was. r12418 roll r12235 back and deduces the default value the column the id column of the view is derived from and uses that to retrieve new ids.

Note: See TracTickets for help on using tickets.