Skip to content
Permalink
Browse files
postgres provider: fix handling of queries in QgsPostgresConn::retrie…
…veLayerTypes
  • Loading branch information
jef-n committed Jun 24, 2021
1 parent 8cb816f commit 93fe5b0d5e94362da9ac839a92cf0a25d883a732
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/providers/postgres/qgspostgresconn.cpp
@@ -1889,7 +1889,7 @@ void QgsPostgresConn::retrieveLayerTypes( QVector<QgsPostgresLayerProperty *> &l
else
{
// Query
table = quotedIdentifier( layerProperty.tableName );
table = QStringLiteral( "%1 AS t" ).arg( layerProperty.tableName );
}

if ( layerProperty.geometryColName.isEmpty() )
@@ -1912,7 +1912,7 @@ void QgsPostgresConn::retrieveLayerTypes( QVector<QgsPostgresLayerProperty *> &l
if ( useEstimatedMetadata )
{
sql = QStringLiteral( "SELECT %1, "
"array_agg( srid || ':RASTER:-1') "
"array_agg(srid || ':RASTER:-1') "
"FROM raster_columns "
"WHERE r_raster_column = %2 AND r_table_schema = %3 AND r_table_name = %4" )
.arg( i - 1 )
@@ -1923,10 +1923,10 @@ void QgsPostgresConn::retrieveLayerTypes( QVector<QgsPostgresLayerProperty *> &l
else
{
sql = QStringLiteral( "SELECT %1, "
"array_agg( DISTINCT ST_SRID( %2 ) || ':RASTER:-1' ) "
"array_agg(DISTINCT st_srid(%2) || ':RASTER:-1') "
"FROM %3 "
"%2 IS NOT NULL "
"%4 " // SQL clause
"%4" // SQL clause
"%5" )
.arg( i - 1 )
.arg( quotedIdentifier( layerProperty.geometryColName ) )
@@ -1944,7 +1944,7 @@ void QgsPostgresConn::retrieveLayerTypes( QVector<QgsPostgresLayerProperty *> &l
// our estimation ignores that a where clause might restrict the feature type or srid
if ( useEstimatedMetadata )
{
table = QStringLiteral( "(SELECT %1 FROM %2 WHERE %3%1 IS NOT NULL %4) AS t" )
table = QStringLiteral( "(SELECT %1 FROM %2 WHERE %3%1 IS NOT NULL%4) AS t" )
.arg( quotedIdentifier( layerProperty.geometryColName ),
table,
layerProperty.sql.isEmpty() ? QString() : QStringLiteral( " (%1) AND " ).arg( layerProperty.sql ) )
@@ -2002,7 +2002,7 @@ void QgsPostgresConn::retrieveLayerTypes( QVector<QgsPostgresLayerProperty *> &l
if ( type == QgsWkbTypes::Unknown )
{
// Subselect to limit the "array_agg(DISTINCT", see previous comment.
sql += QStringLiteral( " FROM (SELECT %1 from %2 %3) as _unused" )
sql += QStringLiteral( " FROM (SELECT %1 FROM %2%3) AS _unused" )
.arg( quotedIdentifier( layerProperty.geometryColName ) )
.arg( table )
.arg( tableScanLimit );

0 comments on commit 93fe5b0

Please sign in to comment.