Skip to content
Permalink
Browse files

Merge pull request #37277 from elpaso/bugfix-29264-spatialite-wrong-f…

…eature-count

Fix spatialite wrong feature count
  • Loading branch information
elpaso committed Jun 19, 2020
2 parents f7bb4b8 + 5a64380 commit 359498091ed72eea2a9216b7a78c10123241af2d
Showing with 16 additions and 2 deletions.
  1. +16 −2 src/providers/spatialite/qgsspatialiteprovider.cpp
@@ -5742,7 +5742,21 @@ bool QgsSpatiaLiteProvider::getTableSummaryAbstractInterface( gaiaVectorLayerPtr
{
mLayerExtent.set( lyr->ExtentInfos->MinX, lyr->ExtentInfos->MinY,
lyr->ExtentInfos->MaxX, lyr->ExtentInfos->MaxY );
mNumberFeatures = lyr->ExtentInfos->Count;
// This can be wrong! see: GH #29264
// mNumberFeatures = lyr->ExtentInfos->Count;
// Note: the unique ptr here does not own the handle, it is just used for the convenience
// methods available within the class.
sqlite3_database_unique_ptr slPtr;
slPtr.reset( sqliteHandle() );
int resultCode;
sqlite3_statement_unique_ptr stmt { slPtr.prepare( QStringLiteral( "SELECT COUNT(1) FROM %2" ).arg( mQuery ), resultCode )};
if ( resultCode == SQLITE_OK )
{
stmt.step();
mNumberFeatures = sqlite3_column_int64( stmt.get(), 0 );
}
// Note: the pointer handle is owned by the provider, releasing it
slPtr.release();
}
else
{
@@ -5762,7 +5776,7 @@ bool QgsSpatiaLiteProvider::getTableSummary()
int columns;
char *errMsg = nullptr;

QString sql = QStringLiteral( "SELECT Count(*)%1 FROM %2" )
QString sql = QStringLiteral( "SELECT Count(1)%1 FROM %2" )
.arg( mGeometryColumn.isEmpty() ? QString() : QStringLiteral( ",Min(MbrMinX(%1)),Min(MbrMinY(%1)),Max(MbrMaxX(%1)),Max(MbrMaxY(%1))" ).arg( QgsSqliteUtils::quotedIdentifier( mGeometryColumn ) ),
mQuery );

0 comments on commit 3594980

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