Skip to content
Permalink
Browse files

oracle provider: skip updating of key attributes of added features fo…

…r versioned tables (backport of e7700db)
  • Loading branch information
jef-n committed Aug 15, 2017
1 parent ebf20a5 commit 987f1acff8a97ab4f802445c7b4078bc8984f6c8
Showing with 24 additions and 21 deletions.
  1. +3 −3 src/app/dwg/libdxfrw/intern/dwgreader18.cpp
  2. +21 −18 src/providers/oracle/qgsoracleprovider.cpp
@@ -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 );
@@ -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 );
@@ -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() );
@@ -1226,7 +1226,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )
return false;

bool returnvalue = true;

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

QSqlDatabase db( *mConnection );

@@ -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 );
}
}
}
}

0 comments on commit 987f1ac

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