Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[processing]field calculator : allow creating field already present (…
…case insensitive equal)
Fixes #40701
- Loading branch information
Showing
with
8 additions
and
3 deletions.
-
+8
−3
src/analysis/processing/qgsalgorithmfieldcalculator.cpp
|
@@ -101,7 +101,7 @@ QgsFieldCalculatorAlgorithm *QgsFieldCalculatorAlgorithm::createInstance() const |
|
|
} |
|
|
|
|
|
|
|
|
bool QgsFieldCalculatorAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback * ) |
|
|
bool QgsFieldCalculatorAlgorithm::prepareAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) |
|
|
{ |
|
|
std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) ); |
|
|
|
|
@@ -131,10 +131,16 @@ bool QgsFieldCalculatorAlgorithm::prepareAlgorithm( const QVariantMap ¶meter |
|
|
|
|
|
mFields = source->fields(); |
|
|
|
|
|
int fieldIdx = mFields.lookupField( field.name() ); |
|
|
int fieldIdx = mFields.indexFromName( field.name() ); |
|
|
|
|
|
if ( fieldIdx < 0 ) |
|
|
{ |
|
|
mFields.append( field ); |
|
|
} |
|
|
else |
|
|
{ |
|
|
feedback->pushWarning( QObject::tr( "Field name %1 already exists and will be replaced" ).arg( field.name() ) ); |
|
|
} |
|
|
|
|
|
QString dest; |
|
|
|
|
@@ -205,4 +211,3 @@ bool QgsFieldCalculatorAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) |
|
|
} |
|
|
|
|
|
///@endcond |
|
|
|