Skip to content
Permalink
Browse files

[processing] Don't skip null parameter values when converting

parameters to pythong strings

We need to include these, in order to differentiate unspecified
parameters from parameters set to null values

(cherry-picked from c738bcf)
  • Loading branch information
nyalldawson committed May 10, 2018
1 parent 123f2df commit 6ad50f7e16b1d3e78c3a4a63075f284ff3689319
Showing with 2 additions and 3 deletions.
  1. +1 −1 src/core/processing/qgsprocessingalgorithm.cpp
  2. +1 −2 tests/src/analysis/testqgsprocessing.cpp
@@ -258,7 +258,7 @@ QString QgsProcessingAlgorithm::asPythonCommand( const QVariantMap &parameters,
if ( def->flags() & QgsProcessingParameterDefinition::FlagHidden )
continue;

if ( !parameters.contains( def->name() ) || !parameters.value( def->name() ).isValid() )
if ( !parameters.contains( def->name() ) )
continue;

parts << QStringLiteral( "'%1':%2" ).arg( def->name(), def->valueAsPythonString( parameters.value( def->name() ), context ) );
@@ -290,8 +290,7 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
params.insert( "p1", "a" );
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a'})" ) );
params.insert( "p2", QVariant() );
// not set, should be no change
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a'})" ) );
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a','p2':None})" ) );
params.insert( "p2", "b" );
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a','p2':'b'})" ) );

0 comments on commit 6ad50f7

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