Skip to content
Permalink
Browse files

Fix calculation of spatialite SelectAtId capability

  • Loading branch information
nyalldawson committed Dec 15, 2015
1 parent 4fbf4cf commit 6ddcae2936b98e750b1c07905094dbd4f43e4a83
@@ -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 )
@@ -657,6 +672,9 @@ void QgsSpatiaLiteProvider::loadFieldsAbstractInterface( gaiaVectorLayerPtr lyr
mPrimaryKeyAttrs << i - 1;
}
}

updatePrimaryKeyCapabilities();

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

updatePrimaryKeyCapabilities();

return;

error:
@@ -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 );
@@ -496,6 +498,7 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
QgsSqliteHandle *handle;

friend class QgsSpatiaLiteFeatureSource;

};

#endif

0 comments on commit 6ddcae2

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