Skip to content

Commit

Permalink
postgres provider: remove attribute in reverse order (fixes #8142)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 29, 2013
1 parent ee17616 commit 4a37805
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
19 changes: 7 additions & 12 deletions src/core/qgsvectorlayereditbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,27 +462,22 @@ void QgsVectorLayerEditBuffer::rollBack()
Q_ASSERT( mAddedFeatures.isEmpty() );
}





/*QString QgsVectorLayerEditBuffer::dumpEditBuffer()
#if 0
QString QgsVectorLayerEditBuffer::dumpEditBuffer()
{
QString msg;
if (!mChangedGeometries.isEmpty())
if ( !mChangedGeometries.isEmpty() )
{
msg += "CHANGED GEOMETRIES:\n";
for (QgsGeometryMap::const_iterator it = mChangedGeometries.begin(); it != mChangedGeometries.end(); ++it)
for ( QgsGeometryMap::const_iterator it = mChangedGeometries.begin(); it != mChangedGeometries.end(); ++it )
{
// QgsFeatureId, QgsGeometry
msg += QString("- FID %1: %2").arg(it.key()).arg(it.value().to)
msg += QString( "- FID %1: %2" ).arg( it.key() ).arg( it.value().to );
}
}
return msg;
}*/



}
#endif

void QgsVectorLayerEditBuffer::handleAttributeAdded( int index )
{
Expand Down
8 changes: 2 additions & 6 deletions src/providers/oracle/qgsoracleprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1509,11 +1509,6 @@ bool QgsOracleProvider::addAttributes( const QList<QgsField> &attributes )
return returnvalue;
}

static int moreThan( int a, int b )
{
return a > b;
}

bool QgsOracleProvider::deleteAttributes( const QgsAttributeIds& ids )
{
bool returnvalue = true;
Expand All @@ -1535,7 +1530,8 @@ bool QgsOracleProvider::deleteAttributes( const QgsAttributeIds& ids )
qry.finish();

QList<int> idsList = ids.values();
qSort( idsList.begin(), idsList.end(), moreThan );
qSort( idsList.begin(), idsList.end(), qGreater<int>() );

foreach ( int id, idsList )
{
const QgsField &fld = mAttributeFields.at( id );
Expand Down
5 changes: 4 additions & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,10 @@ bool QgsPostgresProvider::deleteAttributes( const QgsAttributeIds& ids )
{
mConnectionRW->PQexecNR( "BEGIN" );

for ( QgsAttributeIds::const_iterator iter = ids.begin(); iter != ids.end(); ++iter )
QList<int> idsList = ids.values();
qSort( idsList.begin(), idsList.end(), qGreater<int>() );

for ( QList<int>::const_iterator iter = idsList.begin(); iter != idsList.end(); ++iter )
{
int index = *iter;
if ( index < 0 || index >= mAttributeFields.count() )
Expand Down

0 comments on commit 4a37805

Please sign in to comment.