Skip to content

Commit

Permalink
Relationship creation requires some tables in a database
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 16, 2023
1 parent d7cc1c7 commit e6b137f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/browser/qgsinbuiltdataitemproviders.cpp
Expand Up @@ -2000,6 +2000,13 @@ void QgsFieldDomainItemGuiProvider::populateContextMenu( QgsDataItem *item, QMen
connect( createRelationshipAction, &QAction::triggered, this, [ = ]
{
std::unique_ptr<QgsAbstractDatabaseProviderConnection> conn { static_cast<QgsAbstractDatabaseProviderConnection *>( md->createConnection( connectionUri, {} ) ) };

if ( conn->tables().isEmpty() )
{
notify( QString(), QObject::tr( "Relationships cannot be created in an empty database" ), context, Qgis::MessageLevel::Warning );
return;
}

QgsDbRelationDialog dialog( conn.release(), QgisApp::instance() );
dialog.setWindowTitle( tr( "New Relationship" ) );
if ( dialog.exec() )
Expand Down

0 comments on commit e6b137f

Please sign in to comment.