Skip to content

Commit

Permalink
postgres provider fixes:
Browse files Browse the repository at this point in the history
- allow selection of rows with srid 0 (fixes #7889)
- fix geometry type assignment of geometry less tables
- filter out geometry columns with srids < 0 in browser
  • Loading branch information
jef-n committed May 25, 2013
1 parent a84f3a4 commit 925d317
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspgtablemodel.cpp
Expand Up @@ -56,7 +56,7 @@ void QgsPgTableModel::addTableEntry( QgsPostgresLayerProperty layerProperty )
wkbType = QGis::WKBNoGeometry;
}

bool selectable = wkbType == QGis::WKBNoGeometry || ( wkbType != QGis::WKBUnknown && srid > 0 );
bool selectable = wkbType == QGis::WKBNoGeometry || ( wkbType != QGis::WKBUnknown && srid >= 0 );

QStandardItem *schemaNameItem = new QStandardItem( layerProperty.schemaName );
QStandardItem *typeItem = new QStandardItem( iconForWkbType( wkbType ), wkbType == QGis::WKBUnknown ? tr( "Select..." ) : QgsPostgresConn::displayStringForWkbType( wkbType ) );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresconn.cpp
Expand Up @@ -571,7 +571,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP

QgsDebugMsg( QString( "%1.%2: %3" ).arg( schema ).arg( table ).arg( relkind ) );

layerProperty.types = QList<QGis::WkbType>() << QGis::WKBUnknown;
layerProperty.types = QList<QGis::WkbType>() << QGis::WKBNoGeometry;
layerProperty.srids = QList<int>() << -1;
layerProperty.schemaName = schema;
layerProperty.tableName = table;
Expand Down
3 changes: 2 additions & 1 deletion src/providers/postgres/qgspostgresdataitems.cpp
Expand Up @@ -123,7 +123,8 @@ void QgsPGConnectionItem::setLayerType( QgsPostgresLayerProperty layerProperties
{
QgsPostgresLayerProperty layerProperty = layerProperties.at( i );

if ( layerProperty.types[0] == QGis::WKBUnknown && !layerProperty.geometryColName.isEmpty() )
if ( layerProperty.types[0] == QGis::WKBUnknown ||
(!layerProperty.geometryColName.isEmpty() && layerProperty.srids[0] < 0 ) )
continue;

if ( !schemaItem )
Expand Down

1 comment on commit 925d317

@strk
Copy link
Contributor

@strk strk commented on 925d317 May 25, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the code converts SRID=-1 to SRID=0 when working with PostGIS < 2.0 ? Otherwise you still couldn't select this kind of tables with postgis-1.5

Please sign in to comment.