mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
[FEATURE] postgres provider: optionally skip columns without geometry type constraint
This commit is contained in:
parent
1c2b025a69
commit
9768b13c76
@ -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" );
|
||||
|
@ -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<QgsPostgresLayerProperty> 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 = "";
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -100,6 +100,8 @@ QVector<QgsDataItem*> QgsPGConnectionItem::createChildren()
|
||||
|
||||
stop();
|
||||
|
||||
bool dontResolveType = QgsPostgresConn::dontResolveType( mName );
|
||||
|
||||
foreach ( QgsPostgresLayerProperty layerProperty, layerProperties )
|
||||
{
|
||||
QgsPGSchemaItem *schemaItem = mSchemaMap.value( layerProperty.schemaName, 0 );
|
||||
@ -112,6 +114,12 @@ QVector<QgsDataItem*> 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 */ );
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>352</width>
|
||||
<height>500</height>
|
||||
<width>408</width>
|
||||
<height>556</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -203,7 +203,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="cb_publicSchemaOnly">
|
||||
<property name="toolTip">
|
||||
<string>Restrict the search to the public schema for spatial tables not in the geometry_columns table</string>
|
||||
@ -244,7 +244,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="cb_useEstimatedMetadata">
|
||||
<property name="toolTip">
|
||||
<string>Use estimated table statistics for the layer metadata.</string>
|
||||
@ -265,7 +265,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="cb_allowGeometrylessTables">
|
||||
<property name="text">
|
||||
<string>Also list tables with no geometry</string>
|
||||
@ -275,6 +275,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="cb_dontResolveType">
|
||||
<property name="toolTip">
|
||||
<string>Restrict the displayed tables to those that are in the layer registries.</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't resolve type of unrestricted columns (GEOMETRY)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user