Skip to content
Permalink
Browse files
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/qgis@11703 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Sep 22, 2009
1 parent a73f1cf commit b6c3bc09c28b746ff8460770dbb150a2bff681b7
Showing with 19 additions and 1 deletion.
  1. +19 −1 src/providers/postgres/qgspostgresprovider.cpp
@@ -907,14 +907,18 @@ void QgsPostgresProvider::loadFields()
fieldSize = -1;
}
else if ( fieldTypeName == "text" ||
fieldTypeName == "char" ||
fieldTypeName == "bpchar" ||
fieldTypeName == "varchar" ||
fieldTypeName == "bool" ||
fieldTypeName == "geometry" ||
fieldTypeName == "money" ||
fieldTypeName.startsWith( "time" ) ||
fieldTypeName.startsWith( "date" ) )
{
fieldType = QVariant::String;
fieldSize = -1;
}
else if ( fieldTypeName == "char" )
{
fieldType = QVariant::String;
}
@@ -1382,6 +1386,11 @@ bool QgsPostgresProvider::uniqueData( QString schemaName,
.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 @@ int QgsPostgresProvider::capabilities() const

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

0 comments on commit b6c3bc0

Please sign in to comment.