Skip to content

Commit 06de70e

Browse files
elpasonyalldawson
authored andcommittedOct 8, 2020
PG: Silence warning when discovering relations on query layers
1 parent 43a181b commit 06de70e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4901,12 +4901,21 @@ QList<QgsVectorLayer *> QgsPostgresProvider::searchLayers( const QList<QgsVector
49014901
QList<QgsRelation> QgsPostgresProvider::discoverRelations( const QgsVectorLayer *self, const QList<QgsVectorLayer *> &layers ) const
49024902
{
49034903
QList<QgsRelation> result;
4904+
4905+
// Silently skip if this is a query layer or for some obscure reason there are no table and schema name
4906+
if ( mIsQuery || mTableName.isEmpty() || mSchemaName.isEmpty() )
4907+
{
4908+
return result;
4909+
}
4910+
4911+
// Skip less silently if layer is not valid
49044912
if ( !mValid )
49054913
{
4906-
QgsLogger::warning( "Error getting the foreign keys of " + mTableName + ": invalid connection" );
4914+
QgsLogger::warning( QStringLiteral( "Error discovering relations of %1: invalid layer" ).arg( mQuery ) );
49074915
return result;
49084916
}
49094917

4918+
49104919
QString sql(
49114920
"WITH foreign_keys AS "
49124921
" ( SELECT c.conname, "

0 commit comments

Comments
 (0)
Please sign in to comment.