Skip to content

Commit

Permalink
Honour useEstimatedMetadata connection configuration from Browser
Browse files Browse the repository at this point in the history
Closes #32277
  • Loading branch information
strk committed Oct 22, 2019
1 parent e6a8a2f commit d09d6fe
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/providers/postgres/qgspostgresdataitems.cpp
Expand Up @@ -345,11 +345,20 @@ QString QgsPGLayerItem::createUri()

QgsDataSourceUri uri( QgsPostgresConn::connUri( connItem->name() ).connectionInfo( false ) );

QStringList defPk( QgsSettings().value(
QStringLiteral( "/PostgreSQL/connections/%1/keys/%2/%3" ).arg( connItem->name(), mLayerProperty.schemaName, mLayerProperty.tableName ),
const QgsSettings &settings = QgsSettings();
QString basekey = QStringLiteral( "/PostgreSQL/connections/%1" ).arg( connItem->name() );

QStringList defPk( settings.value(
QStringLiteral( "%1/keys/%2/%3" ).arg( basekey, mLayerProperty.schemaName, mLayerProperty.tableName ),
QVariant( !mLayerProperty.pkCols.isEmpty() ? QStringList( mLayerProperty.pkCols.at( 0 ) ) : QStringList() )
).toStringList() );

bool useEstimatedMetadata( settings.value(
QStringLiteral( "%1/estimatedMetadata" ).arg( basekey ),
false
).toBool() );
uri.setUseEstimatedMetadata( useEstimatedMetadata );

QStringList cols;
for ( const auto &col : defPk )
{
Expand All @@ -360,6 +369,7 @@ QString QgsPGLayerItem::createUri()
uri.setWkbType( mLayerProperty.types.at( 0 ) );
if ( uri.wkbType() != QgsWkbTypes::NoGeometry && mLayerProperty.srids.at( 0 ) != std::numeric_limits<int>::min() )
uri.setSrid( QString::number( mLayerProperty.srids.at( 0 ) ) );

QgsDebugMsg( QStringLiteral( "layer uri: %1" ).arg( uri.uri( false ) ) );
return uri.uri( false );
}
Expand Down

0 comments on commit d09d6fe

Please sign in to comment.