Skip to content
Permalink
Browse files

fix #5883

  • Loading branch information
jef-n committed Oct 4, 2012
1 parent b121a2f commit 6aa7524482f176aaf603ff47b171a1c3e3c2fc62
Showing with 25 additions and 16 deletions.
  1. +15 −14 src/providers/postgres/qgspostgresconn.cpp
  2. +10 −2 src/providers/postgres/qgspostgresprovider.cpp
@@ -1021,28 +1021,29 @@ void QgsPostgresConn::retrieveLayerTypes( QgsPostgresLayerProperty &layerPropert
{
QString table;

if ( !layerProperty.schemaName.isEmpty() )
{
table = QString("%1.%2").arg( quotedIdentifier( layerProperty.schemaName ) ).arg( layerProperty.tableName );
}
else
{
// Query
table = layerProperty.tableName;
}


// it is possible that the where clause restricts the feature type or srid
if ( useEstimatedMetadata )
{
table = QString( "(SELECT %1 FROM %2.%3 WHERE %1 IS NOT NULL%4 LIMIT %5) AS t" )
table = QString( "(SELECT %1 FROM %2 WHERE %1 IS NOT NULL%3 LIMIT %4) AS t" )
.arg( quotedIdentifier( layerProperty.geometryColName ) )
.arg( quotedIdentifier( layerProperty.schemaName ) )
.arg( quotedIdentifier( layerProperty.tableName ) )
.arg( table )
.arg( layerProperty.sql.isEmpty() ? "" : QString( " AND (%1)" ).arg( layerProperty.sql ) )
.arg( sGeomTypeSelectLimit );
}
else if ( !layerProperty.schemaName.isEmpty() )
{
table = QString( "%1.%2%3" )
.arg( quotedIdentifier( layerProperty.schemaName ) )
.arg( quotedIdentifier( layerProperty.tableName ) )
.arg( layerProperty.sql.isEmpty() ? "" : QString( " WHERE %1" ).arg( layerProperty.sql ) );
}
else
else if( !layerProperty.sql.isEmpty() )
{
table = QString( "%1%2" )
.arg( layerProperty.tableName )
.arg( layerProperty.sql.isEmpty() ? "" : QString( " WHERE %1" ).arg( layerProperty.sql ) );
table += QString( " WHERE %1" ).arg( layerProperty.sql );
}

QString query = QString( "SELECT DISTINCT"
@@ -2778,8 +2778,16 @@ bool QgsPostgresProvider::getGeometryDetails()
if ( QgsPostgresConn::wkbTypeFromPostgis( detectedType ) == QGis::WKBUnknown )
{
QgsPostgresLayerProperty layerProperty;
layerProperty.schemaName = schemaName;
layerProperty.tableName = tableName;
if( !mIsQuery )
{
layerProperty.schemaName = schemaName;
layerProperty.tableName = tableName;
}
else
{
layerProperty.schemaName = "";
layerProperty.tableName = mQuery;
}
layerProperty.geometryColName = mGeometryColumn;
layerProperty.isGeography = mIsGeography;

0 comments on commit 6aa7524

Please sign in to comment.
You can’t perform that action at this time.