Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
PG: Silence warning when discovering relations on query layers
  • Loading branch information
elpaso authored and nyalldawson committed Oct 8, 2020
1 parent 43a181b commit 06de70e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -4901,12 +4901,21 @@ QList<QgsVectorLayer *> QgsPostgresProvider::searchLayers( const QList<QgsVector
QList<QgsRelation> QgsPostgresProvider::discoverRelations( const QgsVectorLayer *self, const QList<QgsVectorLayer *> &layers ) const
{
QList<QgsRelation> result;

// Silently skip if this is a query layer or for some obscure reason there are no table and schema name
if ( mIsQuery || mTableName.isEmpty() || mSchemaName.isEmpty() )
{
return result;
}

// Skip less silently if layer is not valid
if ( !mValid )
{
QgsLogger::warning( "Error getting the foreign keys of " + mTableName + ": invalid connection" );
QgsLogger::warning( QStringLiteral( "Error discovering relations of %1: invalid layer" ).arg( mQuery ) );
return result;
}


QString sql(
"WITH foreign_keys AS "
" ( SELECT c.conname, "
Expand Down

0 comments on commit 06de70e

Please sign in to comment.