Skip to content
Permalink
Browse files

oracle provider: check for valid lastInsertId() on ::addFeatures (fixes

#20109)

(cherry picked from commit 855b3b4)
  • Loading branch information
jef-n committed Jan 23, 2019
1 parent 21af807 commit 3d4c6c4e3f3f270d46a419787eb20bd02f8e16d3
Showing with 14 additions and 11 deletions.
  1. +14 −11 src/providers/oracle/qgsoracleprovider.cpp
@@ -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 );
}
}
}
}

0 comments on commit 3d4c6c4

Please sign in to comment.
You can’t perform that action at this time.