[QGIS Commit] r11770 - trunk/qgis/src/providers/postgres

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Oct 8 09:03:14 EDT 2009


Author: jef
Date: 2009-10-08 09:03:14 -0400 (Thu, 08 Oct 2009)
New Revision: 11770

Modified:
   trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
Log:
postgres: consider subset string when deleting, updating and retrieving by fid

Modified: trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
===================================================================
--- trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp	2009-10-08 12:41:41 UTC (rev 11769)
+++ trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp	2009-10-08 13:03:14 UTC (rev 11770)
@@ -685,14 +685,26 @@
 
 QString QgsPostgresProvider::whereClause( int featureId ) const
 {
+  QString whereClause;
+
   if ( primaryKeyType != "tid" )
   {
-    return QString( "%1=%2" ).arg( quotedIdentifier( primaryKey ) ).arg( featureId );
+    whereClause = QString( "%1=%2" ).arg( quotedIdentifier( primaryKey ) ).arg( featureId );
   }
   else
   {
-    return QString( "%1='(%2,%3)'" ).arg( quotedIdentifier( primaryKey ) ).arg( featureId >> 16 ).arg( featureId & 0xffff );
+    whereClause = QString( "%1='(%2,%3)'" ).arg( quotedIdentifier( primaryKey ) ).arg( featureId >> 16 ).arg( featureId & 0xffff );
   }
+
+  if ( !sqlWhereClause.isEmpty() )
+  {
+    if ( !whereClause.isEmpty() )
+      whereClause += " and ";
+
+    whereClause += "(" + sqlWhereClause + ")";
+  }
+
+  return whereClause;
 }
 
 bool QgsPostgresProvider::featureAtId( int featureId, QgsFeature& feature, bool fetchGeometry, QgsAttributeList fetchAttributes )



More information about the QGIS-commit mailing list