diff --git a/src/providers/postgres/qgspgnewconnection.cpp b/src/providers/postgres/qgspgnewconnection.cpp index e241ffdb83d..98e765cff80 100644 --- a/src/providers/postgres/qgspgnewconnection.cpp +++ b/src/providers/postgres/qgspgnewconnection.cpp @@ -52,6 +52,7 @@ QgsPgNewConnection::QgsPgNewConnection( QWidget *parent, const QString& connName txtDatabase->setText( settings.value( key + "/database" ).toString() ); cb_publicSchemaOnly->setChecked( settings.value( key + "/publicOnly", false ).toBool() ); cb_geometryColumnsOnly->setChecked( settings.value( key + "/geometryColumnsOnly", true ).toBool() ); + cb_dontResolveType->setChecked( settings.value( key + "/dontResolveType", false ).toBool() ); cb_allowGeometrylessTables->setChecked( settings.value( key + "/allowGeometrylessTables", false ).toBool() ); // Ensure that cb_publicSchemaOnly is set correctly on_cb_geometryColumnsOnly_clicked(); @@ -131,6 +132,7 @@ void QgsPgNewConnection::accept() settings.setValue( baseKey + "/password", chkStorePassword->isChecked() ? txtPassword->text() : "" ); settings.setValue( baseKey + "/publicOnly", cb_publicSchemaOnly->isChecked() ); settings.setValue( baseKey + "/geometryColumnsOnly", cb_geometryColumnsOnly->isChecked() ); + settings.setValue( baseKey + "/dontResolveType", cb_dontResolveType->isChecked() ); settings.setValue( baseKey + "/allowGeometrylessTables", cb_allowGeometrylessTables->isChecked() ); settings.setValue( baseKey + "/sslmode", cbxSSLmode->itemData( cbxSSLmode->currentIndex() ).toInt() ); settings.setValue( baseKey + "/saveUsername", chkStoreUsername->isChecked() ? "true" : "false" ); diff --git a/src/providers/postgres/qgspgsourceselect.cpp b/src/providers/postgres/qgspgsourceselect.cpp index 4174e9c013b..681179e1db7 100644 --- a/src/providers/postgres/qgspgsourceselect.cpp +++ b/src/providers/postgres/qgspgsourceselect.cpp @@ -444,6 +444,7 @@ void QgsPgSourceSelect::on_btnConnect_clicked() bool searchPublicOnly = QgsPostgresConn::publicSchemaOnly( cmbConnections->currentText() ); bool searchGeometryColumnsOnly = QgsPostgresConn::geometryColumnsOnly( cmbConnections->currentText() ); + bool dontResolveType = QgsPostgresConn::dontResolveType( cmbConnections->currentText() ); bool allowGeometrylessTables = cbxAllowGeometrylessTables->isChecked(); QVector layers; @@ -458,6 +459,12 @@ void QgsPgSourceSelect::on_btnConnect_clicked() { if ( QgsPostgresConn::wkbTypeFromPostgis( type ) == QGis::WKBUnknown || srid.isEmpty() ) { + if ( dontResolveType ) + { + QgsDebugMsg( QString( "skipping column %1.%2 without type constraint" ).arg( layer.schemaName ).arg( layer.tableName ) ); + continue; + } + addSearchGeometryColumn( layer ); type = ""; srid = ""; diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp index f3fd8685777..41aaf1f91fe 100644 --- a/src/providers/postgres/qgspostgresconn.cpp +++ b/src/providers/postgres/qgspostgresconn.cpp @@ -1484,6 +1484,13 @@ bool QgsPostgresConn::geometryColumnsOnly( QString theConnName ) return settings.value( "/PostgreSQL/connections/" + theConnName + "/geometryColumnsOnly", false ).toBool(); } +bool QgsPostgresConn::dontResolveType( QString theConnName ) +{ + QSettings settings; + + return settings.value( "/PostgreSQL/connections/" + theConnName + "/dontResolveType", false ).toBool(); +} + bool QgsPostgresConn::allowGeometrylessTables( QString theConnName ) { QSettings settings; diff --git a/src/providers/postgres/qgspostgresconn.h b/src/providers/postgres/qgspostgresconn.h index 73372832297..8cb686e387f 100644 --- a/src/providers/postgres/qgspostgresconn.h +++ b/src/providers/postgres/qgspostgresconn.h @@ -195,6 +195,7 @@ class QgsPostgresConn : public QObject static QgsDataSourceURI connUri( QString theConnName ); static bool publicSchemaOnly( QString theConnName ); static bool geometryColumnsOnly( QString theConnName ); + static bool dontResolveType( QString theConnName ); static bool allowGeometrylessTables( QString theConnName ); static void deleteConnection( QString theConnName ); diff --git a/src/providers/postgres/qgspostgresdataitems.cpp b/src/providers/postgres/qgspostgresdataitems.cpp index 3db77676533..799e132d374 100644 --- a/src/providers/postgres/qgspostgresdataitems.cpp +++ b/src/providers/postgres/qgspostgresdataitems.cpp @@ -100,6 +100,8 @@ QVector QgsPGConnectionItem::createChildren() stop(); + bool dontResolveType = QgsPostgresConn::dontResolveType( mName ); + foreach ( QgsPostgresLayerProperty layerProperty, layerProperties ) { QgsPGSchemaItem *schemaItem = mSchemaMap.value( layerProperty.schemaName, 0 ); @@ -112,6 +114,12 @@ QVector QgsPGConnectionItem::createChildren() if ( QgsPostgresConn::wkbTypeFromPostgis( layerProperty.type ) == QGis::WKBUnknown ) { + if ( !dontResolveType ) + { + QgsDebugMsg( QString( "Skip column %1.%2 without type constraint" ).arg( layerProperty.schemaName ).arg( layerProperty.tableName ).arg( layerProperty.geometryColName ) ); + continue; + } + if ( !mColumnTypeThread ) { QgsPostgresConn *conn = QgsPostgresConn::connectDb( uri.connectionInfo(), true /* readonly */ ); diff --git a/src/ui/qgspgnewconnectionbase.ui b/src/ui/qgspgnewconnectionbase.ui index 1f3e536b0f9..812507a3525 100644 --- a/src/ui/qgspgnewconnectionbase.ui +++ b/src/ui/qgspgnewconnectionbase.ui @@ -6,8 +6,8 @@ 0 0 - 352 - 500 + 408 + 556 @@ -203,7 +203,7 @@ - + Restrict the search to the public schema for spatial tables not in the geometry_columns table @@ -244,7 +244,7 @@ - + Use estimated table statistics for the layer metadata. @@ -265,7 +265,7 @@ - + Also list tables with no geometry @@ -275,6 +275,19 @@ + + + + Restrict the displayed tables to those that are in the layer registries. + + + Restricts the displayed tables to those that are found in the layer registries (geometry_columns, geography_columns, topology.layer). This can speed up the initial display of spatial tables. + + + Don't resolve type of unrestricted columns (GEOMETRY) + + +