qgsoracleprovider.cpp.patch

Ivan Lucena, 2018-11-09 08:06 PM

Download (1.96 KB)

View differences:

src/providers/oracle/qgsoracleprovider.cpp
1239 1239
        fieldId << idx;
1240 1240
        defaultValues << defaultValue( idx ).toString();
1241 1241
      }
1242

  
1243
      if ( !getfid.prepare( QStringLiteral( "SELECT %1 FROM %2 WHERE ROWID=?" ).arg( keys ).arg( mQuery ) ) )
1244
      {
1245
        throw OracleException( tr( "Could not prepare get feature id statement" ), getfid );
1246
      }
1247 1242
    }
1248 1243

  
1249 1244
    QgsAttributes attributevec = flist[0].attributes();
......
1328 1323
      if ( !ins.exec() )
1329 1324
        throw OracleException( tr( "Could not insert feature %1" ).arg( features->id() ), ins );
1330 1325

  
1331
      if ( !( flags & QgsFeatureSink::FastInsert ) )
1332
      {
1333
        if ( mPrimaryKeyType == PktRowId )
1334
        {
1335
          features->setId( mShared->lookupFid( QList<QVariant>() << QVariant( ins.lastInsertId() ) ) );
1336
          QgsDebugMsgLevel( QStringLiteral( "new fid=%1" ).arg( features->id() ), 4 );
1337
        }
1338
        else if ( mPrimaryKeyType == PktInt || mPrimaryKeyType == PktFidMap )
1339
        {
1340
          getfid.addBindValue( QVariant( ins.lastInsertId() ) );
1341
          if ( !getfid.exec() || !getfid.next() )
1342
            throw OracleException( tr( "Could not retrieve feature id %1" ).arg( features->id() ), getfid );
1343

  
1344
          int col = 0;
1345
          Q_FOREACH ( int idx, mPrimaryKeyAttrs )
1346
          {
1347
            QgsField fld = field( idx );
1348

  
1349
            QVariant v = getfid.value( col++ );
1350
            if ( v.type() != fld.type() )
1351
              v = QgsVectorDataProvider::convertValue( fld.type(), v.toString() );
1352
            features->setAttribute( idx, v );
1353
          }
1354
        }
1355
      }
1356 1326
    }
1357 1327

  
1358 1328
    ins.finish();