@@ -446,7 +446,7 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
446
446
gaiaVectorLayersListPtr list = NULL ;
447
447
gaiaVectorLayerPtr lyr = NULL ;
448
448
bool specialCase = false ;
449
- if ( mGeometryColumn .isNull () )
449
+ if ( mGeometryColumn .isEmpty () )
450
450
specialCase = true ; // non-spatial table
451
451
if ( mQuery .startsWith ( " (" ) && mQuery .endsWith ( " )" ) )
452
452
specialCase = true ;
@@ -493,7 +493,8 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri )
493
493
{
494
494
// enabling editing only for Tables [excluding Views and VirtualShapes]
495
495
enabledCapabilities |= QgsVectorDataProvider::DeleteFeatures;
496
- enabledCapabilities |= QgsVectorDataProvider::ChangeGeometries;
496
+ if ( !mGeometryColumn .isEmpty () )
497
+ enabledCapabilities |= QgsVectorDataProvider::ChangeGeometries;
497
498
enabledCapabilities |= QgsVectorDataProvider::ChangeAttributeValues;
498
499
enabledCapabilities |= QgsVectorDataProvider::AddFeatures;
499
500
enabledCapabilities |= QgsVectorDataProvider::AddAttributes;
@@ -3523,7 +3524,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
3523
3524
values = QString ( " ) VALUES (" );
3524
3525
separator = " " ;
3525
3526
3526
- if ( !mGeometryColumn .isNull () )
3527
+ if ( !mGeometryColumn .isEmpty () )
3527
3528
{
3528
3529
sql += separator + quotedIdentifier ( mGeometryColumn );
3529
3530
values += separator + geomParam ();
@@ -3570,7 +3571,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
3570
3571
// initializing the column counter
3571
3572
ia = 0 ;
3572
3573
3573
- if ( !mGeometryColumn .isNull () )
3574
+ if ( !mGeometryColumn .isEmpty () )
3574
3575
{
3575
3576
// binding GEOMETRY to Prepared Statement
3576
3577
if ( !features->geometry () )
@@ -4202,7 +4203,7 @@ bool QgsSpatiaLiteProvider::checkLayerType()
4202
4203
4203
4204
QString sql;
4204
4205
4205
- if ( mGeometryColumn .isNull () )
4206
+ if ( mGeometryColumn .isEmpty () )
4206
4207
{
4207
4208
// checking if is a non-spatial table
4208
4209
sql = QString ( " SELECT type FROM sqlite_master "
@@ -4479,7 +4480,7 @@ void QgsSpatiaLiteProvider::getViewSpatialIndexName()
4479
4480
bool QgsSpatiaLiteProvider::getGeometryDetails ()
4480
4481
{
4481
4482
bool ret = false ;
4482
- if ( mGeometryColumn .isNull () )
4483
+ if ( mGeometryColumn .isEmpty () )
4483
4484
{
4484
4485
geomType = QGis::WKBNoGeometry;
4485
4486
return true ;
@@ -4936,9 +4937,8 @@ bool QgsSpatiaLiteProvider::getTableSummary()
4936
4937
int columns;
4937
4938
char *errMsg = NULL ;
4938
4939
4939
- QString sql = QString ( " SELECT Min(MbrMinX(%1)), Min(MbrMinY(%1)), "
4940
- " Max(MbrMaxX(%1)), Max(MbrMaxY(%1)), Count(*) " " FROM %2" )
4941
- .arg ( quotedIdentifier ( mGeometryColumn ) )
4940
+ QString sql = QString ( " SELECT Count(*)%1 FROM %2" )
4941
+ .arg ( mGeometryColumn .isEmpty () ? " " : QString ( " ,Min(MbrMinX(%1)),Min(MbrMinY(%1)),Max(MbrMaxX(%1)),Max(MbrMaxY(%1))" ).arg ( quotedIdentifier ( mGeometryColumn ) ) )
4942
4942
.arg ( mQuery );
4943
4943
4944
4944
if ( !mSubsetString .isEmpty () )
@@ -4955,14 +4955,22 @@ bool QgsSpatiaLiteProvider::getTableSummary()
4955
4955
{
4956
4956
for ( i = 1 ; i <= rows; i++ )
4957
4957
{
4958
- QString minX = results[( i * columns ) + 0 ];
4959
- QString minY = results[( i * columns ) + 1 ];
4960
- QString maxX = results[( i * columns ) + 2 ];
4961
- QString maxY = results[( i * columns ) + 3 ];
4962
- QString count = results[( i * columns ) + 4 ];
4963
-
4964
- layerExtent.set ( minX.toDouble (), minY.toDouble (), maxX.toDouble (), maxY.toDouble () );
4958
+ QString count = results[( i * columns ) + 0 ];
4965
4959
numberFeatures = count.toLong ();
4960
+
4961
+ if ( mGeometryColumn .isEmpty () )
4962
+ {
4963
+ layerExtent.setMinimal ();
4964
+ }
4965
+ else
4966
+ {
4967
+ QString minX = results[( i * columns ) + 1 ];
4968
+ QString minY = results[( i * columns ) + 2 ];
4969
+ QString maxX = results[( i * columns ) + 3 ];
4970
+ QString maxY = results[( i * columns ) + 4 ];
4971
+
4972
+ layerExtent.set ( minX.toDouble (), minY.toDouble (), maxX.toDouble (), maxY.toDouble () );
4973
+ }
4966
4974
}
4967
4975
}
4968
4976
sqlite3_free_table ( results );
0 commit comments