Skip to content

Commit

Permalink
[oracle] Fix broken iterator rewind
Browse files Browse the repository at this point in the history
On behalf of Faunalia, sponsored by ENEL

(cherry-picked from d785b90)
  • Loading branch information
nyalldawson committed Jul 6, 2016
1 parent 0c060bd commit 0307495
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/providers/oracle/qgsoraclefeatureiterator.cpp
Expand Up @@ -209,10 +209,16 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature& feature )
if ( mRewind )
{
mRewind = false;
if ( !mQry.first() )
return true;
if ( !QgsOracleProvider::exec( mQry, mSql ) )
{
QgsMessageLog::logMessage( QObject::tr( "Fetching features failed.\nSQL:%1\nError: %2" )
.arg( mQry.lastQuery() )
.arg( mQry.lastError().text() ),
QObject::tr( "Oracle" ) );
return false;
}
}
else if ( !mQry.next() )
if ( !mQry.next() )
{
return false;
}
Expand Down Expand Up @@ -444,6 +450,7 @@ bool QgsOracleFeatureIterator::openQuery( QString whereClause )
query += QString( " WHERE %1" ).arg( whereClause );

QgsDebugMsg( QString( "Fetch features: %1" ).arg( query ) );
mSql = query;
if ( !QgsOracleProvider::exec( mQry, query ) )
{
QgsMessageLog::logMessage( QObject::tr( "Fetching features failed.\nSQL:%1\nError: %2" )
Expand Down
1 change: 1 addition & 0 deletions src/providers/oracle/qgsoraclefeatureiterator.h
Expand Up @@ -84,6 +84,7 @@ class QgsOracleFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Qgs
bool mExpressionCompiled;
bool mFetchGeometry;
QgsAttributeList mAttributeList;
QString mSql;
};

#endif // QGSORACLEFEATUREITERATOR_H

0 comments on commit 0307495

Please sign in to comment.