Skip to content

Commit

Permalink
Fixes #34537 : Allow setting null in relation reference widget
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 authored and 3nids committed Mar 25, 2020
1 parent b1d7c94 commit 54e5974
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsfeaturefiltermodel.cpp
Expand Up @@ -623,7 +623,7 @@ QVariantList QgsFeatureFilterModel::extraIdentifierValues() const
{
QVariantList nullValues;
for ( int i = 0; i < mIdentifierFields.count(); i++ )
nullValues << QVariant();
nullValues << QVariant( QVariant::Int );
return nullValues;
}
return mExtraIdentifierValues;
Expand Down
6 changes: 3 additions & 3 deletions tests/src/gui/testqgsfeaturelistcombobox.cpp
Expand Up @@ -163,14 +163,14 @@ void TestQgsFeatureListComboBox::testMultipleForeignKeys()

cb->setIdentifierValuesToNull();
QCOMPARE( cb->identifierValues().count(), 3 );
QCOMPARE( cb->identifierValues(), QVariantList() << QVariant() << QVariant() << QVariant() );
QCOMPARE( cb->identifierValues(), QVariantList() << QVariant( QVariant::Int ) << QVariant( QVariant::Int ) << QVariant( QVariant::Int ) );

cb->setIdentifierValues( QVariantList() << "silver" << 888 << "fish" );
QCOMPARE( cb->identifierValues(), QVariantList() << "silver" << 888 << "fish" );

cb->setIdentifierValuesToNull();
QCOMPARE( cb->identifierValues().count(), 3 );
QCOMPARE( cb->identifierValues(), QVariantList() << QVariant() << QVariant() << QVariant() );
QCOMPARE( cb->identifierValues(), QVariantList() << QVariant( QVariant::Int ) << QVariant( QVariant::Int ) << QVariant( QVariant::Int ) );

cb->setIdentifierFields( QStringList() << "material" << "raccord" );
cb->setDisplayExpression( "\"material\" || ' ' || \"raccord\"" );
Expand All @@ -182,7 +182,7 @@ void TestQgsFeatureListComboBox::testMultipleForeignKeys()

cb->setIdentifierValuesToNull();
QCOMPARE( cb->identifierValues().count(), 2 );
QCOMPARE( cb->identifierValues(), QVariantList() << QVariant() << QVariant() );
QCOMPARE( cb->identifierValues(), QVariantList() << QVariant( QVariant::Int ) << QVariant( QVariant::Int ) );
}

void TestQgsFeatureListComboBox::testAllowNull()
Expand Down
5 changes: 3 additions & 2 deletions tests/src/gui/testqgsrelationreferencewidget.cpp
Expand Up @@ -528,8 +528,9 @@ void TestQgsRelationReferenceWidget::testSetGetForeignKey()
QCOMPARE( w.mComboBox->currentText(), QStringLiteral( "(12)" ) );
QCOMPARE( spy.count(), 2 );

w.setForeignKeys( QVariantList() << QVariant( QVariant::Int ) );
Q_ASSERT( w.foreignKeys().at( 0 ).isNull() );
w.setForeignKeys( QVariantList() << QVariant() );
QVERIFY( w.foreignKeys().at( 0 ).isNull() );
QVERIFY( w.foreignKeys().at( 0 ).isValid() );
QCOMPARE( spy.count(), 3 );
}

Expand Down

0 comments on commit 54e5974

Please sign in to comment.