Bug report #1933

Fix PostGIS dataprovider to check for unique data with SQL where clause

Added by Jeremy Palmer about 11 years ago. Updated almost 11 years ago.

Status:Closed
Priority:Low
Assignee:Jürgen Fischer
Category:Data Provider
Affected QGIS version: Regression?:No
Operating System:All Easy fix?:No
Pull Request or Patch supplied: Resolution:fixed
Crashes QGIS or corrupts data: Copied to github as #:11993

Description

The method QgsPostgresProvider::uniqueData within qgspostgresprovider.cpp should be updated to use the SQL where cause for determining if the set primary key provides unique data.

i.e

  if ( !sqlWhereClause.isEmpty() )
  {
    sql += " where " + sqlWhereClause;
  }

Associated revisions

Revision b6c3bc09
Added by Jürgen Fischer almost 11 years ago

postgres provider update:
- only use typlen for char fields
- use subset string when checking for key uniqueness and recheck in setSubsetString() (fixes #1933)

git-svn-id: http://svn.osgeo.org/qgis/trunk/[email protected] c8812cc2-4d05-0410-92ff-de0c093fc19c

Revision b9508088
Added by Jürgen Fischer almost 11 years ago

postgres provider update:
- only use typlen for char fields
- use subset string when checking for key uniqueness and recheck in setSubsetString() (fixes #1933)

git-svn-id: http://svn.osgeo.org/qgis/[email protected] c8812cc2-4d05-0410-92ff-de0c093fc19c

History

#1 Updated by Jürgen Fischer almost 11 years ago

  • Resolution set to wontfix
  • Status changed from Open to Closed

the where clause can be changed later, to the id needs to be unique even without the where clause. An alternative would be to create a view with the desired clause.

#2 Updated by Jürgen Fischer almost 11 years ago

s/to/so/

#3 Updated by Jeremy Palmer almost 11 years ago

  • Status changed from Closed to Feedback
  • Resolution deleted (wontfix)

The case I was wanting to implement already involves a view. It would be useful to use the where cause to show different spatial datasets based on this view.

How about modifying the QgsPostgresProvider::setSubsetString method to recheck for the unique primary key by calling the QgsPostgresProvider::uniqueData() method?

I would be really great to have this feature so I can build a python plug-in to dynamically add and view multiple vector layers based on a dataset identifier.

#4 Updated by Jürgen Fischer almost 11 years ago

  • Resolution set to fixed
  • Status changed from Feedback to Closed

Replying to [comment:3 jpalmer]:

How about modifying the QgsPostgresProvider::setSubsetString method to recheck for the unique primary key by calling the QgsPostgresProvider::uniqueData() method?

good point. Thanks.

Fixed in b9508088 (SVN r11704)

Also available in: Atom PDF