Skip to content
Permalink
Browse files

Fix spatialite wrong feature count

Fixes #29264
  • Loading branch information
elpaso committed Jun 17, 2020
1 parent 0b92727 commit 9d040bb917407e3c936f3a04162eff2b1dcaaad1
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/providers/spatialite/qgsspatialiteprovider.cpp
@@ -5742,7 +5742,18 @@ 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;
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 );
}
slPtr.release();
}
else
{
@@ -5762,7 +5773,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 9d040bb

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