[QGIS Commit] r11703 - trunk/qgis/src/providers/postgres
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Sep 22 19:26:16 EDT 2009
Author: jef
Date: 2009-09-22 19:26:15 -0400 (Tue, 22 Sep 2009)
New Revision: 11703
Modified:
trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
Log:
postgres provider update:
- only use typlen for char fields
- use subset string when checking for key uniqueness and recheck in setSubsetString() (fixes #1933)
Modified: trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
===================================================================
--- trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp 2009-09-22 17:32:37 UTC (rev 11702)
+++ trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp 2009-09-22 23:26:15 UTC (rev 11703)
@@ -907,7 +907,6 @@
fieldSize = -1;
}
else if ( fieldTypeName == "text" ||
- fieldTypeName == "char" ||
fieldTypeName == "bpchar" ||
fieldTypeName == "varchar" ||
fieldTypeName == "bool" ||
@@ -917,7 +916,12 @@
fieldTypeName.startsWith( "date" ) )
{
fieldType = QVariant::String;
+ fieldSize = -1;
}
+ else if ( fieldTypeName == "char" )
+ {
+ fieldType = QVariant::String;
+ }
else
{
QgsDebugMsg( "Field " + fieldName + " ignored, because of unsupported type " + fieldTypeName );
@@ -1382,6 +1386,11 @@
.arg( quotedIdentifier( schemaName ) )
.arg( quotedIdentifier( tableName ) );
+ if ( !sqlWhereClause.isEmpty() )
+ {
+ sql += " where " + sqlWhereClause;
+ }
+
Result unique = connectionRO->PQexec( sql );
if ( PQntuples( unique ) == 1 && QString::fromUtf8( PQgetvalue( unique, 0, 0 ) ).startsWith( "t" ) )
@@ -2506,7 +2515,16 @@
void QgsPostgresProvider::setSubsetString( QString theSQL )
{
+ QString prevWhere = sqlWhereClause;
+
sqlWhereClause = theSQL;
+
+ if( !uniqueData( mSchemaName, mTableName, primaryKey ) )
+ {
+ sqlWhereClause = prevWhere;
+ return;
+ }
+
// Update datasource uri too
mUri.setSql( theSQL );
// Update yet another copy of the uri. Why are there 3 copies of the
More information about the QGIS-commit
mailing list