Skip to content

Commit

Permalink
Move sqlite/spatialite system tables to the QgsSqliteUtils class
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Mar 1, 2019
1 parent 09a4f6f commit 5cb673a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
19 changes: 19 additions & 0 deletions src/core/qgssqliteutils.cpp
Expand Up @@ -151,6 +151,25 @@ QString QgsSqliteUtils::quotedValue( const QVariant &value )
}
}

QStringList QgsSqliteUtils::systemTables()
{
return QStringList() << QStringLiteral( "SpatialIndex" ) << QStringLiteral( "geom_cols_ref_sys" ) << QStringLiteral( "geometry_columns" )
<< QStringLiteral( "geometry_columns_auth" ) << QStringLiteral( "views_geometry_columns" ) << QStringLiteral( "virts_geometry_columns" )
<< QStringLiteral( "spatial_ref_sys" ) << QStringLiteral( "spatial_ref_sys_all" ) << QStringLiteral( "spatial_ref_sys_aux" )
<< QStringLiteral( "sqlite_sequence" ) << QStringLiteral( "tableprefix_metadata" ) << QStringLiteral( "tableprefix_rasters" )
<< QStringLiteral( "layer_params" ) << QStringLiteral( "layer_statistics" ) << QStringLiteral( "layer_sub_classes" )
<< QStringLiteral( "layer_table_layout" ) << QStringLiteral( "pattern_bitmaps" ) << QStringLiteral( "symbol_bitmaps" )
<< QStringLiteral( "project_defs" ) << QStringLiteral( "raster_pyramids" ) << QStringLiteral( "sqlite_stat1" ) << QStringLiteral( "sqlite_stat2" )
<< QStringLiteral( "spatialite_history" ) << QStringLiteral( "geometry_columns_field_infos" ) << QStringLiteral( "geometry_columns_statistics" )
<< QStringLiteral( "geometry_columns_time" ) << QStringLiteral( "sql_statements_log" ) << QStringLiteral( "vector_layers" )
<< QStringLiteral( "vector_layers_auth" ) << QStringLiteral( "vector_layers_field_infos" ) << QStringLiteral( "vector_layers_statistics" )
<< QStringLiteral( "views_geometry_columns_auth" ) << QStringLiteral( "views_geometry_columns_field_infos" )
<< QStringLiteral( "views_geometry_columns_statistics" ) << QStringLiteral( "virts_geometry_columns_auth" )
<< QStringLiteral( "virts_geometry_columns_field_infos" ) << QStringLiteral( "virts_geometry_columns_statistics" )
<< QStringLiteral( "virts_layer_statistics" ) << QStringLiteral( "views_layer_statistics" )
<< QStringLiteral( "ElementaryGeometries" );
}

QString QgsSqlite3Mprintf( const char *format, ... )
{
va_list ap;
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgssqliteutils.h
Expand Up @@ -180,6 +180,13 @@ class CORE_EXPORT QgsSqliteUtils
* \since QGIS 3.6
*/
static QString quotedValue( const QVariant &value );

/**
* Returns a string list of SQLite (and spatialite) system tables
*
* \since QGIS 3.8
*/
static QStringList systemTables();
};

/**
Expand Down
19 changes: 3 additions & 16 deletions src/providers/spatialite/qgsspatialiteconnection.cpp
Expand Up @@ -16,6 +16,7 @@
#include "qgssettings.h"
#include "qgslogger.h"
#include "qgsspatialiteutils.h"
#include "qgssqliteutils.h"

#include <QFileInfo>
#include <cstdlib> // atoi
Expand Down Expand Up @@ -239,22 +240,8 @@ bool QgsSpatiaLiteConnection::getTableInfoAbstractInterface( sqlite3 *handle, bo
}

// List of system tables not to be shown if geometryless tables are requested
QStringList ignoreTableNames;
ignoreTableNames << QStringLiteral( "SpatialIndex" ) << QStringLiteral( "geom_cols_ref_sys" ) << QStringLiteral( "geometry_columns" )
<< QStringLiteral( "geometry_columns_auth" ) << QStringLiteral( "views_geometry_columns" ) << QStringLiteral( "virts_geometry_columns" )
<< QStringLiteral( "spatial_ref_sys" ) << QStringLiteral( "spatial_ref_sys_all" ) << QStringLiteral( "spatial_ref_sys_aux" )
<< QStringLiteral( "sqlite_sequence" ) << QStringLiteral( "tableprefix_metadata" ) << QStringLiteral( "tableprefix_rasters" )
<< QStringLiteral( "layer_params" ) << QStringLiteral( "layer_statistics" ) << QStringLiteral( "layer_sub_classes" )
<< QStringLiteral( "layer_table_layout" ) << QStringLiteral( "pattern_bitmaps" ) << QStringLiteral( "symbol_bitmaps" )
<< QStringLiteral( "project_defs" ) << QStringLiteral( "raster_pyramids" ) << QStringLiteral( "sqlite_stat1" ) << QStringLiteral( "sqlite_stat2" )
<< QStringLiteral( "spatialite_history" ) << QStringLiteral( "geometry_columns_field_infos" ) << QStringLiteral( "geometry_columns_statistics" )
<< QStringLiteral( "geometry_columns_time" ) << QStringLiteral( "sql_statements_log" ) << QStringLiteral( "vector_layers" )
<< QStringLiteral( "vector_layers_auth" ) << QStringLiteral( "vector_layers_field_infos" ) << QStringLiteral( "vector_layers_statistics" )
<< QStringLiteral( "views_geometry_columns_auth" ) << QStringLiteral( "views_geometry_columns_field_infos" )
<< QStringLiteral( "views_geometry_columns_statistics" ) << QStringLiteral( "virts_geometry_columns_auth" )
<< QStringLiteral( "virts_geometry_columns_field_infos" ) << QStringLiteral( "virts_geometry_columns_statistics" )
<< QStringLiteral( "virts_layer_statistics" ) << QStringLiteral( "views_layer_statistics" )
<< QStringLiteral( "ElementaryGeometries" );
QStringList ignoreTableNames = QgsSqliteUtils::systemTables();

// attempting to load the VectorLayersList
list = gaiaGetVectorLayersList( handle, nullptr, nullptr, GAIA_VECTORS_LIST_FAST );
if ( list )
Expand Down

0 comments on commit 5cb673a

Please sign in to comment.