Skip to content

Commit d2775ba

Browse files
committedFeb 14, 2012
fix 659abb8 (fixes #5016)
1 parent 6d5fc5f commit d2775ba

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,20 +1462,22 @@ bool QgsPostgresProvider::determinePrimaryKey()
14621462
{
14631463
QString name = res.PQgetvalue( i, 0 );
14641464

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

1467-
if ( idx < 0 )
1469+
if ( it == mAttributeFields.end() )
14681470
{
14691471
QgsDebugMsg( "Skipping " + name );
14701472
continue;
14711473
}
14721474

14731475
if ( isInt &&
1474-
mAttributeFields[idx].type() != QVariant::Int &&
1475-
mAttributeFields[idx].type() != QVariant::LongLong )
1476+
it->type() != QVariant::Int &&
1477+
it->type() != QVariant::LongLong )
14761478
isInt = false;
14771479

1478-
mPrimaryKeyAttrs << idx;
1480+
mPrimaryKeyAttrs << it.key();
14791481
}
14801482

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

0 commit comments

Comments
 (0)
Please sign in to comment.