Skip to content

Commit

Permalink
Fix calculation of spatialite SelectAtId capability
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 15, 2015
1 parent 4fbf4cf commit 6ddcae2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -588,8 +588,23 @@ QgsAbstractFeatureSource* QgsSpatiaLiteProvider::featureSource() const
return new QgsSpatiaLiteFeatureSource( this );
}

void QgsSpatiaLiteProvider::updatePrimaryKeyCapabilities()
{
if ( mPrimaryKey.isEmpty() )
{
enabledCapabilities &= ~QgsVectorDataProvider::SelectAtId;
enabledCapabilities &= ~QgsVectorDataProvider::SelectGeometryAtId;
}
else
{
enabledCapabilities |= QgsVectorDataProvider::SelectAtId;
enabledCapabilities |= QgsVectorDataProvider::SelectGeometryAtId;
}
}

#ifdef SPATIALITE_VERSION_GE_4_0_0
// only if libspatialite version is >= 4.0.0

void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr )
{
if ( lyr == nullptr )
Expand Down Expand Up @@ -657,6 +672,9 @@ void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr
mPrimaryKeyAttrs << i - 1;
}
}

updatePrimaryKeyCapabilities();

sqlite3_free_table( results );
}
#endif
Expand Down Expand Up @@ -849,6 +867,8 @@ void QgsSpatiaLiteProvider::loadFields()
mPrimaryKey = pkName;
}

updatePrimaryKeyCapabilities();

return;

error:
Expand Down
3 changes: 3 additions & 0 deletions src/providers/spatialite/qgsspatialiteprovider.h
Expand Up @@ -426,6 +426,8 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
static int computeMultiWKB3Dsize( const unsigned char *p_in, int little_endian,
int endian_arch );
private:
void updatePrimaryKeyCapabilities();

int computeSizeFromMultiWKB2D( const unsigned char *p_in, int nDims,
int little_endian,
int endian_arch );
Expand Down Expand Up @@ -496,6 +498,7 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
QgsSqliteHandle *handle;

friend class QgsSpatiaLiteFeatureSource;

};

#endif

0 comments on commit 6ddcae2

Please sign in to comment.