You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
QString sql = QString( "SELECT attname FROM pg_attribute JOIN pg_type ON atttypid=pg_type.oid WHERE attrelid=regclass('%1.%2')" )
278
-
.arg( quotedIdentifier( schemaName ) )
279
-
.arg( quotedIdentifier( viewName ) );
276
+
// TODO: optimize this query when pk candidates aren't needed
277
+
// could use array_agg() and count()
278
+
// array output would look like this: "{One,tWo}"
279
+
QString sql = QString( "SELECT attname, CASE WHEN typname = ANY(ARRAY['geometry','geography','topogeometry']) THEN 1 ELSE null END AS isSpatial FROM pg_attribute JOIN pg_type ON atttypid=pg_type.oid WHERE attrelid=regclass('%1.%2')" )
280
+
.arg( quotedIdentifier( schemaName ) )
281
+
.arg( quotedIdentifier( viewName ) );
280
282
QgsDebugMsg( sql );
281
283
QgsPostgresResult colRes = PQexec( sql );
282
284
285
+
layerProperty.nSpCols = 0;
286
+
283
287
if ( colRes.PQresultStatus() == PGRES_TUPLES_OK )
284
288
{
285
289
for ( int i = 0; i < colRes.PQntuples(); i++ )
286
290
{
287
-
QgsDebugMsg( colRes.PQgetvalue( i, 0 ) );
288
-
cols << colRes.PQgetvalue( i, 0 );
291
+
if ( fetchPkCandidates ) {
292
+
QgsDebugMsg( colRes.PQgetvalue( i, 0 ) );
293
+
layerProperty.pkCols << colRes.PQgetvalue( i, 0 );
0 commit comments