Skip to content

Commit

Permalink
[processing] Don't skip null parameter values when converting
Browse files Browse the repository at this point in the history
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 11, 2018
1 parent 123f2df commit 6ad50f7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/processing/qgsprocessingalgorithm.cpp
Expand Up @@ -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 ) );
Expand Down
3 changes: 1 addition & 2 deletions tests/src/analysis/testqgsprocessing.cpp
Expand Up @@ -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'})" ) );

Expand Down

0 comments on commit 6ad50f7

Please sign in to comment.