Skip to content
Permalink
Browse files

[virtual layers] warn if unique identifier is not a valid field name

  • Loading branch information
m-kuhn authored and nyalldawson committed Nov 19, 2020
1 parent 6797118 commit 11b577ee2ec45084e381f9f1aa6e4ec36a9bd678
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/providers/virtual/qgsvirtuallayersourceselect.cpp
@@ -218,7 +218,18 @@ void QgsVirtualLayerSourceSelect::testQuery()
std::unique_ptr<QgsVectorLayer> vl( new QgsVectorLayer( def.toString(), QStringLiteral( "test" ), QStringLiteral( "virtual" ), options ) );
if ( vl->isValid() )
{
QMessageBox::information( nullptr, tr( "Virtual layer test" ), tr( "No error" ) );
const QStringList fieldNames = vl->fields().names();
if ( !mUIDField->text().isEmpty() && !vl->fields().names().contains( mUIDField->text() ) )
{
QStringList bulletedFieldNames;
for ( const QString &fieldName : fieldNames )
{
bulletedFieldNames.append( QStringLiteral( "<li>%1" ).arg( fieldName ) );
}
QMessageBox::warning( nullptr, tr( "Virtual layer test " ), tr( "The unique identifier field <b>%1</b> was not found in list of fields:<ul>%2</ul>" ).arg( mUIDField->text(), bulletedFieldNames.join( ' ' ) ) );
}
else
QMessageBox::information( nullptr, tr( "Virtual layer test" ), tr( "No error" ) );
}
else
{

0 comments on commit 11b577e

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