Skip to content

Commit c738bcf

Browse files
committedMay 10, 2018
[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
1 parent d05f95f commit c738bcf

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed
 

‎src/core/processing/qgsprocessingalgorithm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ QString QgsProcessingAlgorithm::asPythonCommand( const QVariantMap &parameters,
269269
if ( def->flags() & QgsProcessingParameterDefinition::FlagHidden )
270270
continue;
271271

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

275275
parts << QStringLiteral( "'%1':%2" ).arg( def->name(), def->valueAsPythonString( parameters.value( def->name() ), context ) );

‎tests/src/analysis/testqgsprocessing.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
291291
params.insert( "p1", "a" );
292292
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a'})" ) );
293293
params.insert( "p2", QVariant() );
294-
// not set, should be no change
295-
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a'})" ) );
294+
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a','p2':None})" ) );
296295
params.insert( "p2", "b" );
297296
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a','p2':'b'})" ) );
298297

0 commit comments

Comments
 (0)
Please sign in to comment.