@@ -1173,7 +1173,7 @@ QString QgsOracleProvider::paramValue( QString fieldValue, const QString &defaul
1173
1173
}
1174
1174
1175
1175
1176
- bool QgsOracleProvider::addFeatures ( QgsFeatureList &flist )
1176
+ bool QgsOracleProvider::addFeatures ( QgsFeatureList &flist, QgsFeatureSink::Flags flags )
1177
1177
{
1178
1178
if ( flist.size () == 0 )
1179
1179
return true ;
@@ -1311,26 +1311,29 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )
1311
1311
if ( !ins.exec () )
1312
1312
throw OracleException ( tr ( " Could not insert feature %1" ).arg ( features->id () ), ins );
1313
1313
1314
- if ( mPrimaryKeyType == PktRowId )
1314
+ if ( !( flags & QgsFeatureSink::FastInsert ) )
1315
1315
{
1316
- features->setId ( mShared ->lookupFid ( QList<QVariant>() << QVariant ( ins.lastInsertId () ) ) );
1317
- QgsDebugMsgLevel ( QString ( " new fid=%1" ).arg ( features->id () ), 4 );
1318
- }
1319
- else if ( mPrimaryKeyType == PktInt || mPrimaryKeyType == PktFidMap )
1320
- {
1321
- getfid.addBindValue ( QVariant ( ins.lastInsertId () ) );
1322
- if ( !getfid.exec () || !getfid.next () )
1323
- throw OracleException ( tr ( " Could not retrieve feature id %1" ).arg ( features->id () ), getfid );
1324
-
1325
- int col = 0 ;
1326
- Q_FOREACH ( int idx, mPrimaryKeyAttrs )
1316
+ if ( mPrimaryKeyType == PktRowId )
1327
1317
{
1328
- QgsField fld = field ( idx );
1318
+ features->setId ( mShared ->lookupFid ( QList<QVariant>() << QVariant ( ins.lastInsertId () ) ) );
1319
+ QgsDebugMsgLevel ( QString ( " new fid=%1" ).arg ( features->id () ), 4 );
1320
+ }
1321
+ else if ( mPrimaryKeyType == PktInt || mPrimaryKeyType == PktFidMap )
1322
+ {
1323
+ getfid.addBindValue ( QVariant ( ins.lastInsertId () ) );
1324
+ if ( !getfid.exec () || !getfid.next () )
1325
+ throw OracleException ( tr ( " Could not retrieve feature id %1" ).arg ( features->id () ), getfid );
1329
1326
1330
- QVariant v = getfid.value ( col++ );
1331
- if ( v.type () != fld.type () )
1332
- v = QgsVectorDataProvider::convertValue ( fld.type (), v.toString () );
1333
- features->setAttribute ( idx, v );
1327
+ int col = 0 ;
1328
+ Q_FOREACH ( int idx, mPrimaryKeyAttrs )
1329
+ {
1330
+ QgsField fld = field ( idx );
1331
+
1332
+ QVariant v = getfid.value ( col++ );
1333
+ if ( v.type () != fld.type () )
1334
+ v = QgsVectorDataProvider::convertValue ( fld.type (), v.toString () );
1335
+ features->setAttribute ( idx, v );
1336
+ }
1334
1337
}
1335
1338
}
1336
1339
}
@@ -1342,29 +1345,32 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )
1342
1345
throw OracleException ( tr ( " Could not commit transaction" ), db );
1343
1346
}
1344
1347
1345
- // update feature ids
1346
- if ( mPrimaryKeyType == PktInt || mPrimaryKeyType == PktFidMap )
1348
+ if ( !( flags & QgsFeatureSink::FastInsert ) )
1347
1349
{
1348
- for ( QgsFeatureList::iterator features = flist.begin (); features != flist.end (); ++features )
1350
+ // update feature ids
1351
+ if ( mPrimaryKeyType == PktInt || mPrimaryKeyType == PktFidMap )
1349
1352
{
1350
- QgsAttributes attributevec = features->attributes ();
1351
-
1352
- if ( mPrimaryKeyType == PktInt )
1353
+ for ( QgsFeatureList::iterator features = flist.begin (); features != flist.end (); ++features )
1353
1354
{
1354
- features->setId ( STRING_TO_FID ( attributevec[ mPrimaryKeyAttrs [0 ] ] ) );
1355
- }
1356
- else
1357
- {
1358
- QList<QVariant> primaryKeyVals;
1355
+ QgsAttributes attributevec = features->attributes ();
1359
1356
1360
- Q_FOREACH ( int idx, mPrimaryKeyAttrs )
1357
+ if ( mPrimaryKeyType == PktInt )
1361
1358
{
1362
- primaryKeyVals << attributevec[ idx ] ;
1359
+ features-> setId ( STRING_TO_FID ( attributevec[ mPrimaryKeyAttrs [ 0 ] ] ) ) ;
1363
1360
}
1361
+ else
1362
+ {
1363
+ QList<QVariant> primaryKeyVals;
1364
1364
1365
- features->setId ( mShared ->lookupFid ( QVariant ( primaryKeyVals ) ) );
1365
+ Q_FOREACH ( int idx, mPrimaryKeyAttrs )
1366
+ {
1367
+ primaryKeyVals << attributevec[ idx ];
1368
+ }
1369
+
1370
+ features->setId ( mShared ->lookupFid ( QVariant ( primaryKeyVals ) ) );
1371
+ }
1372
+ QgsDebugMsgLevel ( QString ( " new fid=%1" ).arg ( features->id () ), 4 );
1366
1373
}
1367
- QgsDebugMsgLevel ( QString ( " new fid=%1" ).arg ( features->id () ), 4 );
1368
1374
}
1369
1375
}
1370
1376
0 commit comments