Skip to content
Permalink
Browse files

Check table name when adding features in offline editing

  • Loading branch information
m-kuhn committed Mar 2, 2020
1 parent a76c2dd commit dcb07c4c2c0d58051b9f7ebefb753a2c7b1da6ab
Showing with 11 additions and 2 deletions.
  1. +11 −2 src/core/qgsofflineediting.cpp
@@ -1480,7 +1480,8 @@ void QgsOfflineEditing::committedFeaturesAdded( const QString &qgisLayerId, cons

// get new feature ids from db
QgsMapLayer *layer = QgsProject::instance()->mapLayer( qgisLayerId );
QgsDataSourceUri uri = QgsDataSourceUri( layer->source() );
QString dataSourceString = layer->source();
QgsDataSourceUri uri = QgsDataSourceUri( dataSourceString );

QString offlinePath = QgsProject::instance()->readPath( QgsProject::instance()->readEntry( PROJECT_ENTRY_SCOPE_OFFLINE, PROJECT_ENTRY_KEY_OFFLINE_DB_PATH ) );
QString tableName;
@@ -1491,7 +1492,15 @@ void QgsOfflineEditing::committedFeaturesAdded( const QString &qgisLayerId, cons
}
else
{
tableName = uri.param( offlinePath + "|layername" );
if ( dataSourceString.indexOf( QLatin1String( "|layername=" ) ) != -1 )
{
QRegularExpression regex( QStringLiteral( "\\|layername=([^|]*)" ) );
tableName = regex.match( dataSourceString ).captured( 1 );
}
else
{
showWarning( tr( "Could not deduce table name from data source %1." ).arg( dataSourceString ) );
}
}

// only store feature ids

0 comments on commit dcb07c4

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