Skip to content

Commit

Permalink
Merge pull request #2554 from vmora/order_pk_candidates
Browse files Browse the repository at this point in the history
order postgres PK candidates by attnum
  • Loading branch information
jef-n committed Dec 8, 2015
2 parents 9118050 + ab0736a commit 13cbd8f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresconn.cpp
Expand Up @@ -330,7 +330,7 @@ void QgsPostgresConn::addColumnInfo( QgsPostgresLayerProperty& layerProperty, co
// TODO: optimize this query when pk candidates aren't needed
// could use array_agg() and count()
// array output would look like this: "{One,tWo}"
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" )
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" )
.arg( quotedIdentifier( schemaName ),
quotedIdentifier( viewName ) );
//QgsDebugMsg( sql );
Expand Down

0 comments on commit 13cbd8f

Please sign in to comment.