Skip to content
Permalink
Browse files
fix 659abb8 (fixes #5016)
  • Loading branch information
jef-n committed Feb 14, 2012
1 parent 6d5fc5f commit d2775ba5cc27bf3d9a4ac8bcd9c2c9eb327bf7f6
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/providers/postgres/qgspostgresprovider.cpp
@@ -1462,20 +1462,22 @@ bool QgsPostgresProvider::determinePrimaryKey()
{
QString name = res.PQgetvalue( i, 0 );

int idx = mAttributeFields.key( name, -1 );
QgsFieldMap::const_iterator it = mAttributeFields.begin();
while ( it != mAttributeFields.end() && it->name() != name )
it++;

if ( idx < 0 )
if ( it == mAttributeFields.end() )
{
QgsDebugMsg( "Skipping " + name );
continue;
}

if ( isInt &&
mAttributeFields[idx].type() != QVariant::Int &&
mAttributeFields[idx].type() != QVariant::LongLong )
it->type() != QVariant::Int &&
it->type() != QVariant::LongLong )
isInt = false;

mPrimaryKeyAttrs << idx;
mPrimaryKeyAttrs << it.key();
}

mPrimaryKeyType = ( mPrimaryKeyAttrs.size() == 1 && isInt ) ? pktInt : pktFidMap;

0 comments on commit d2775ba

Please sign in to comment.