Skip to content
Permalink
Browse files

Move sqlite/spatialite system tables to the QgsSqliteUtils class

  • Loading branch information
nirvn committed Mar 1, 2019
1 parent 09a4f6f commit 5cb673a8d0dc1813667c9a155ab095f36c7f3ed5
Showing with 29 additions and 16 deletions.
  1. +19 −0 src/core/qgssqliteutils.cpp
  2. +7 −0 src/core/qgssqliteutils.h
  3. +3 −16 src/providers/spatialite/qgsspatialiteconnection.cpp
@@ -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;
@@ -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();
};

/**
@@ -16,6 +16,7 @@
#include "qgssettings.h"
#include "qgslogger.h"
#include "qgsspatialiteutils.h"
#include "qgssqliteutils.h"

#include <QFileInfo>
#include <cstdlib> // atoi
@@ -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 )

0 comments on commit 5cb673a

Please sign in to comment.
You can’t perform that action at this time.