Skip to content

Commit f8d5d43

Browse files
committed
in import vector layer fix overwrite option and report provider errors
1 parent 30fb05a commit f8d5d43

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/core/qgsvectorlayerimport.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,14 @@ bool QgsVectorLayerImport::flushBuffer()
153153

154154
if ( !mProvider->addFeatures( mFeatureBuffer ) )
155155
{
156-
mErrorMessage = QObject::tr( "Creation error for features from #%1 to #%2" )
156+
QStringList errors = mProvider->errors();
157+
mProvider->clearErrors();
158+
159+
mErrorMessage = QObject::tr( "Creation error for features from #%1 to #%2. Provider errors was: \n%3" )
157160
.arg( mFeatureBuffer.first().id() )
158-
.arg( mFeatureBuffer.last().id() );
161+
.arg( mFeatureBuffer.last().id() )
162+
.arg( errors.join( "\n" ) );
163+
159164
mError = ErrFeatureWriteFailed;
160165
mErrorCount += mFeatureBuffer.count();
161166

@@ -210,8 +215,10 @@ QgsVectorLayerImport::importLayer( QgsVectorLayer* layer,
210215
}
211216
}
212217

218+
bool overwrite = options->take( "overwrite" ).toBool();
219+
213220
QgsVectorLayerImport * writer =
214-
new QgsVectorLayerImport( uri, providerKey, fields, layer->wkbType(), outputCRS, false, options );
221+
new QgsVectorLayerImport( uri, providerKey, fields, layer->wkbType(), outputCRS, overwrite, options );
215222

216223
// check whether file creation was successful
217224
ImportError err = writer->hasError();

0 commit comments

Comments
 (0)