[QGIS-trac] [Quantum GIS] #1545: Qgis erroneously fails to find a unique key in a PostGIS view

Quantum GIS qgis at qgis.org
Mon Feb 16 17:16:01 EST 2009


#1545: Qgis erroneously fails to find a unique key in a PostGIS view
------------------------------------------------+---------------------------
   Reporter:  pcreso                            |              Owner:  nobody
       Type:  bug                               |             Status:  new   
   Priority:  major: does not work as expected  |          Milestone:        
  Component:  Data Provider                     |            Version:  0.11.0
   Keywords:  Postgis view unique               |   Platform_version:        
   Platform:  SuSE                              |           Must_fix:  No    
Status_info:  0                                 |  
------------------------------------------------+---------------------------
 A view with a unique primary key can't be opened by QGIS as it says the
 key is not unique. It is.
 This is on Qgis v0.11, but also I believe in v1.0.

 I believe QGIS uses the following SQL to test for uniqeness in a column,
 which returns true in this case:
 select count(distinct obs_id) = count(obs_id) from v_obs_pos ;
 ?column?
 ----------
 t
 (1 row)


 My version of the same test gives 0 duplicates in the underlying table &
 the view:

 select count(*) from (select obs_id from v_obs_pos group by obs_id having
 count(*) > 1 limit 1) as foo;
 count
 -------
      0
 (1 row)

 ofop=# select count(*) from (select id from obs group by id having
 count(*) > 1 limit 1) as foo;
 count
 -------
      0
 (1 row)

 But QGIS gives an error msg:
 "Note: 'id' initially appeared suitable but does not contain unique data,
 so is not suitable."

 This error does not appear to be genuine.

-- 
Ticket URL: <https://trac.osgeo.org/qgis/ticket/1545>
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