Skip to content
Permalink
Browse files

Merge pull request #34757 from troopa81/backport_34329_to_release-3_12

[Backport 3.12] Fix relation reference constraint when identifying a feature
  • Loading branch information
m-kuhn committed Mar 13, 2020
2 parents 26f0539 + e153f12 commit af99e24f0822027cc12f2b589bfc5b2eba78d5e5
@@ -793,9 +793,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
{
@@ -403,6 +403,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(), QStringLiteral( "11" ) );
QCOMPARE( w.mForeignKeys.count(), 1 );
QCOMPARE( w.mForeignKeys.at( 0 ).toInt(), 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(), QStringLiteral( "10" ) );
QCOMPARE( w.mForeignKeys.count(), 1 );
QCOMPARE( w.mForeignKeys.at( 0 ).toInt(), 10 );

mLayer1->rollBack();
}

0 comments on commit af99e24

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