Skip to content
Permalink
Browse files

Fixes #34537 : Allow setting null in relation reference widget

  • Loading branch information
troopa81 committed Mar 9, 2020
1 parent 1a58083 commit 6af6e855e3c0ea291fe9b8b2ec9f2cdf82c9615b
@@ -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;
@@ -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\"" );
@@ -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()
@@ -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 );
}

0 comments on commit 6af6e85

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