Skip to content

Commit

Permalink
oracle provider: skip updating of key attributes of added features fo…
Browse files Browse the repository at this point in the history
…r versioned tables (backport of e7700db)
  • Loading branch information
jef-n committed Aug 15, 2017
1 parent ebf20a5 commit 987f1ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/app/dwg/libdxfrw/intern/dwgreader18.cpp
Expand Up @@ -116,7 +116,7 @@ void dwgReader18::parseSysPage( duint8 *decompSec, duint32 decompSize )
}
DRW_DBG( "\n" );
#endif
DRW_DBG( "decompresing " );
DRW_DBG( "decompressing " );
DRW_DBG( compSize );
DRW_DBG( " bytes in " );
DRW_DBG( decompSize );
Expand Down Expand Up @@ -231,7 +231,7 @@ bool dwgReader18::parseDataPage( dwgSectionInfo si/*, duint8 *dData*/ )

duint8* oData = objData + pi.startOffset;
pi.uSize = si.maxSize;
DRW_DBG( "decompresing " );
DRW_DBG( "decompressing " );
DRW_DBG( pi.cSize );
DRW_DBG( " bytes in " );
DRW_DBG( pi.uSize );
Expand All @@ -251,7 +251,7 @@ bool dwgReader18::readMetaData()
if ( ! fileBuf->setPosition( 11 ) )
return false;
maintenanceVersion = fileBuf->getRawChar8();
DRW_DBG( "maintenance verion= " );
DRW_DBG( "maintenance version= " );
DRW_DBGH( maintenanceVersion );
DRW_DBG( "\nbyte at 0x0C= " );
DRW_DBGH( fileBuf->getRawChar8() );
Expand Down
39 changes: 21 additions & 18 deletions src/providers/oracle/qgsoracleprovider.cpp
Expand Up @@ -1226,7 +1226,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )
return false;

bool returnvalue = true;

bool fetchNewFid = getWorkspace().isEmpty() || getWorkspace().toUpper() == "LIVE";

QSqlDatabase db( *mConnection );

Expand Down Expand Up @@ -1394,26 +1394,29 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )
if ( !ins.exec() )
throw OracleException( tr( "Could not insert feature %1" ).arg( features->id() ), ins );

if ( mPrimaryKeyType == pktRowId )
{
features->setFeatureId( mShared->lookupFid( QList<QVariant>() << QVariant( ins.lastInsertId() ) ) );
QgsDebugMsgLevel( QString( "new fid=%1" ).arg( features->id() ), 4 );
}
else if ( mPrimaryKeyType == pktInt || mPrimaryKeyType == pktFidMap )
if ( fetchNewFid )
{
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 ( mPrimaryKeyType == pktRowId )
{
const QgsField &fld = field( idx );
features->setFeatureId( mShared->lookupFid( QList<QVariant>() << QVariant( ins.lastInsertId() ) ) );
QgsDebugMsgLevel( QString( "new fid=%1" ).arg( features->id() ), 4 );
}
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 );

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 )
{
const 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 987f1ac

Please sign in to comment.