Skip to content

Commit 13cbd8f

Browse files
committed
Merge pull request #2554 from vmora/order_pk_candidates
order postgres PK candidates by attnum
2 parents 9118050 + ab0736a commit 13cbd8f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/providers/postgres/qgspostgresconn.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void QgsPostgresConn::addColumnInfo( QgsPostgresLayerProperty& layerProperty, co
330330
// TODO: optimize this query when pk candidates aren't needed
331331
// could use array_agg() and count()
332332
// array output would look like this: "{One,tWo}"
333-
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') AND attnum>0" )
333+
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') AND attnum>0 ORDER BY attnum" )
334334
.arg( quotedIdentifier( schemaName ),
335335
quotedIdentifier( viewName ) );
336336
//QgsDebugMsg( sql );

0 commit comments

Comments
 (0)