Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
oracle provider: check for valid lastInsertId() on ::addFeatures (fixes
  • Loading branch information
jef-n committed Jan 22, 2019
1 parent 3c83503 commit 855b3b4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -1337,19 +1337,22 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist, QgsFeatureSink::Flag
}
else if ( mPrimaryKeyType == PktInt || mPrimaryKeyType == PktFidMap )
{
getfid.addBindValue( QVariant( ins.lastInsertId() ) );
if ( !getfid.exec() || !getfid.next() )
throw OracleException( tr( "Could not retrieve feature id %1" ).arg( features->id() ), getfid );

int col = 0;
Q_FOREACH ( int idx, mPrimaryKeyAttrs )
if ( ins.lastInsertId().isValid() )
{
QgsField fld = field( idx );
getfid.addBindValue( QVariant( ins.lastInsertId() ) );
if ( !getfid.exec() || !getfid.next() )
throw OracleException( tr( "Could not retrieve feature id %1" ).arg( features->id() ), getfid );

QVariant v = getfid.value( col++ );
if ( v.type() != fld.type() )
v = QgsVectorDataProvider::convertValue( fld.type(), v.toString() );
features->setAttribute( idx, v );
int col = 0;
Q_FOREACH ( int idx, mPrimaryKeyAttrs )
{
QgsField fld = field( idx );

QVariant v = getfid.value( col++ );
if ( v.type() != fld.type() )
v = QgsVectorDataProvider::convertValue( fld.type(), v.toString() );
features->setAttribute( idx, v );
}
}
}
}
Expand Down

0 comments on commit 855b3b4

Please sign in to comment.