Skip to content

Commit f1b2893

Browse files
committedSep 28, 2018
Move table name variable to local
1 parent 9e9f0d6 commit f1b2893

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed
 

‎src/providers/spatialite/qgsspatialiteprovider.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4592,27 +4592,29 @@ bool QgsSpatiaLiteProvider::checkLayerType()
45924592
{
45934593
// Check if we can get use the ROWID from the table that provides the geometry
45944594
sqlite3_stmt *stmt = nullptr;
4595+
//! String containing the name of the table that provides the geometry if the layer data source is based on a query
4596+
QString queryGeomTableName;
45954597
// 1. find the table that provides geometry
45964598
if ( sqlite3_prepare_v2( mSqliteHandle, sql.toUtf8().constData(), -1, &stmt, nullptr ) == SQLITE_OK )
45974599
{
4598-
mQueryGeomTableName = sqlite3_column_table_name( stmt, 1 );
4600+
queryGeomTableName = sqlite3_column_table_name( stmt, 1 );
45994601
}
46004602
// 2. check if the table has a useable ROWID
4601-
if ( ! mQueryGeomTableName.isEmpty() )
4603+
if ( ! queryGeomTableName.isEmpty() )
46024604
{
4603-
sql = QStringLiteral( "SELECT ROWID FROM %1 WHERE ROWID IS NOT NULL LIMIT 1" ).arg( quotedIdentifier( mQueryGeomTableName ) );
4605+
sql = QStringLiteral( "SELECT ROWID FROM %1 WHERE ROWID IS NOT NULL LIMIT 1" ).arg( quotedIdentifier( queryGeomTableName ) );
46044606
ret = sqlite3_get_table( mSqliteHandle, sql.toUtf8().constData(), &results, &rows, &columns, &errMsg );
46054607
if ( ret != SQLITE_OK || rows != 1 )
46064608
{
4607-
mQueryGeomTableName = QString();
4609+
queryGeomTableName = QString();
46084610
}
46094611
}
46104612
// 3. check if ROWID injection works
4611-
if ( ! mQueryGeomTableName.isEmpty() )
4613+
if ( ! queryGeomTableName.isEmpty() )
46124614
{
46134615
QString newSql( mQuery.replace( QStringLiteral( "SELECT " ),
46144616
QStringLiteral( "SELECT %1.%2, " )
4615-
.arg( quotedIdentifier( mQueryGeomTableName ), QStringLiteral( "ROWID" ) ),
4617+
.arg( quotedIdentifier( queryGeomTableName ), QStringLiteral( "ROWID" ) ),
46164618
Qt::CaseInsensitive ) );
46174619
sql = QStringLiteral( "SELECT ROWID FROM %1 WHERE ROWID IS NOT NULL LIMIT 1" ).arg( newSql );
46184620
ret = sqlite3_get_table( mSqliteHandle, sql.toUtf8().constData(), &results, &rows, &columns, &errMsg );

‎src/providers/spatialite/qgsspatialiteprovider.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,6 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
230230
//! Flag indicating if the layer data source is based on a query
231231
bool mIsQuery = false;
232232

233-
//! String containing the name of the table that provides the geometry if the layer data source is based on a query
234-
QString mQueryGeomTableName;
235-
236233
//! Flag indicating if ROWID has been injected in the query
237234
bool mRowidInjectedInQuery = false;
238235

0 commit comments

Comments
 (0)
Please sign in to comment.