Skip to content

Commit

Permalink
fix 659abb8 (fixes #5016)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 14, 2012
1 parent 6d5fc5f commit d2775ba
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit d2775ba

Please sign in to comment.