[QGIS-trac] [Quantum GIS] #1535: qgspostgresprovider choosing non-unique column as primary key

Quantum GIS qgis at qgis.org
Mon Feb 9 18:15:39 EST 2009


#1535: qgspostgresprovider choosing non-unique column as primary key
------------------------------------------------+---------------------------
   Reporter:  jcs                               |              Owner:  nobody       
       Type:  bug                               |             Status:  new          
   Priority:  major: does not work as expected  |          Milestone:  Version 1.0.1
  Component:  Data Provider                     |            Version:  0.10.0       
   Keywords:  postgres                          |   Platform_version:               
   Platform:  All                               |           Must_fix:  No           
Status_info:  0                                 |  
------------------------------------------------+---------------------------
 [[BR]]
 Table A (rid primary key, bid int, loc geometry)

 Table B (rid primary key, id2 unique)

 View V is (select Table.rid, Table B.id2, Table A.loc from Table A left
 outer join Table B on Table A.bid=Table B.rid;)

 The problem is Qgis may select Table B.id2 as its primary key because of
 the unique constraint in the table definition even though V.id2 is not
 constrained to be unique in the view.

 For example if Table A has[[BR]]
 rid | bid | loc[[BR]]
 1 | 1 | POINTA[[BR]]
 2 | 2 | POINTB[[BR]]
 3 | 1 | POINTC[[BR]]

 and Table B has[[BR]]
 rid | id2[[BR]]
 1 | 47[[BR]]
 2 | 48[[BR]]

 View V would have[[BR]]
 rid | id2 | loc[[BR]]
 1 | 47 | POINTA[[BR]]
 2 | 48 | POINTB[[BR]]
 3 | 47 | POINTC


 Resolution... columns obtained through a left outer join should not be
 included for consideration as a primary key...  this could be implemented
 by a modification to findColumns() in qgspostgresprovider to not return
 such columns.

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