Skip to content
Permalink
Browse files

[processing]field calculator : allow creating field already present (…

…case insensitive equal)

Fixes #40701
  • Loading branch information
jdlom committed Jan 4, 2021
1 parent c7a9d5a commit 472b950a219639ee0bec139f102c6d55618abc54
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/analysis/processing/qgsalgorithmfieldcalculator.cpp
@@ -101,7 +101,7 @@ QgsFieldCalculatorAlgorithm *QgsFieldCalculatorAlgorithm::createInstance() const
}


bool QgsFieldCalculatorAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
bool QgsFieldCalculatorAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );

@@ -131,10 +131,16 @@ bool QgsFieldCalculatorAlgorithm::prepareAlgorithm( const QVariantMap &parameter

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

0 comments on commit 472b950

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