Skip to content

Commit 441f6f8

Browse files
committedOct 20, 2015
postgres provider: allow detection of empty views (fixes #13638)
1 parent b20d316 commit 441f6f8

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed
 

‎src/providers/postgres/qgspostgresconn.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,6 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
588588
// catalog doesn't exist in postgresql so we ignore that, but we
589589
// do need to get the geometry type.
590590

591-
// Make the assumption that the geometry type for the first
592-
// row is the same as for all other rows.
593-
594591
QString tableName = result.PQgetvalue( i, 0 ); // relname
595592
QString schemaName = result.PQgetvalue( i, 1 ); // nspname
596593
QString column = result.PQgetvalue( i, 2 ); // attname
@@ -601,8 +598,8 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
601598

602599
//QgsDebugMsg( QString( "%1.%2.%3: %4" ).arg( schemaName ).arg( tableName ).arg( column ).arg( relkind ) );
603600

604-
layerProperty.types.clear();
605-
layerProperty.srids.clear();
601+
layerProperty.types = QList<QGis::WkbType>() << QGis::WKBUnknown;
602+
layerProperty.srids = QList<int>() << INT_MIN;
606603
layerProperty.schemaName = schemaName;
607604
layerProperty.tableName = tableName;
608605
layerProperty.geometryColName = column;

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ bool QgsPostgresProvider::uniqueData( QString query, QString quotedColNames )
13181318
{
13191319
Q_UNUSED( query );
13201320
// Check to see if the given columns contain unique data
1321-
QString sql = QString( "SELECT count(distinct (%1))=count((%1)) AND bool_and((%1) IS NOT NULL) FROM %2%3" )
1321+
QString sql = QString( "SELECT count(distinct (%1))=count((%1)) FROM %2%3" )
13221322
.arg( quotedColNames,
13231323
mQuery,
13241324
filterWhereClause() );

0 commit comments

Comments
 (0)
Failed to load comments.