Skip to content

Commit 6ad50f7

Browse files
committed
[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)
1 parent 123f2df commit 6ad50f7

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
@@ -258,7 +258,7 @@ QString QgsProcessingAlgorithm::asPythonCommand( const QVariantMap &parameters,
258258
if ( def->flags() & QgsProcessingParameterDefinition::FlagHidden )
259259
continue;
260260

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

264264
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
@@ -290,8 +290,7 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
290290
params.insert( "p1", "a" );
291291
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a'})" ) );
292292
params.insert( "p2", QVariant() );
293-
// not set, should be no change
294-
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a'})" ) );
293+
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a','p2':None})" ) );
295294
params.insert( "p2", "b" );
296295
QCOMPARE( asPythonCommand( params, context ), QStringLiteral( "processing.run(\"test\", {'p1':'a','p2':'b'})" ) );
297296

0 commit comments

Comments
 (0)