Skip to content
Permalink
Browse files

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

  • Loading branch information
jef-n committed Jan 22, 2019
1 parent 3c83503 commit 855b3b4e26377647de5c5f9d38485f9f00bc9257
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 855b3b4

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