Skip to content

Commit

Permalink
Fix relation reference constraint when identifying a feature
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 committed Feb 28, 2020
1 parent 7e531f1 commit ef6d95b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Expand Up @@ -788,9 +788,9 @@ void QgsRelationReferenceWidget::featureIdentified( const QgsFeature &feature )
}
mLineEdit->setText( title );
mForeignKeys.clear();
mFeature = feature;
for ( const QString &fieldName : qgis::as_const( mReferencedFields ) )
mForeignKeys << mFeature.attribute( fieldName );
mFeature = feature;
}
else
{
Expand Down
18 changes: 18 additions & 0 deletions tests/src/gui/testqgsrelationreferencewidget.cpp
Expand Up @@ -376,6 +376,24 @@ void TestQgsRelationReferenceWidget::testIdentifyOnMap()
w.featureIdentified( feature );
QCOMPARE( w.mComboBox->currentData( Qt::DisplayRole ).toInt(), 10 );

w.setReadOnlySelector( true );

mLayer2->getFeatures( QStringLiteral( "pk = %1" ).arg( 11 ) ).nextFeature( feature );
QVERIFY( feature.isValid() );
QCOMPARE( feature.attribute( QStringLiteral( "pk" ) ).toInt(), 11 );
w.featureIdentified( feature );
QCOMPARE( w.mLineEdit->text(), "11" );
QCOMPARE( w.mForeignKeys.count(), 1 );
QCOMPARE( w.mForeignKeys.at( 0 ), 11 );

mLayer2->getFeatures( QStringLiteral( "pk = %1" ).arg( 10 ) ).nextFeature( feature );
QVERIFY( feature.isValid() );
QCOMPARE( feature.attribute( QStringLiteral( "pk" ) ).toInt(), 10 );
w.featureIdentified( feature );
QCOMPARE( w.mLineEdit->text(), "10" );
QCOMPARE( w.mForeignKeys.count(), 1 );
QCOMPARE( w.mForeignKeys.at( 0 ), 10 );

mLayer1->rollBack();
}

Expand Down

0 comments on commit ef6d95b

Please sign in to comment.