Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[afs] Ensure that null attributes are correctly mapped for PyQGIS
  • Loading branch information
nyalldawson committed Feb 20, 2018
1 parent 7d620e2 commit 7711f13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/providers/arcgisrest/qgsafsshareddata.cpp
Expand Up @@ -96,6 +96,11 @@ bool QgsAfsSharedData::getFeature( QgsFeatureId id, QgsFeature &f, const QgsRect
foreach ( int idx, fetchAttribIdx )
{
QVariant attribute = attributesData[mFields.at( idx ).name()];
if ( attribute.isNull() )
{
// ensure that null values are mapped correctly for PyQGIS
attribute = QVariant( QVariant::Int );
}
mFields.at( idx ).convertCompatible( attribute );
attributes[idx] = attribute;
if ( mFields.at( idx ).name() == QStringLiteral( "OBJECTID" ) )
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/providertestbase.py
Expand Up @@ -331,7 +331,7 @@ def testExtent(self):

def testUnique(self):
self.assertEqual(set(self.source.uniqueValues(self.source.fields().lookupField('cnt'))), set([-200, 100, 200, 300, 400]))
assert set(['Apple', 'Honey', 'Orange', 'Pear', NULL]) == set(self.source.uniqueValues(2)), 'Got {}'.format(set(self.source.uniqueValues(self.source.fields().lookupField('name'))))
assert set(['Apple', 'Honey', 'Orange', 'Pear', NULL]) == set(self.source.uniqueValues(self.source.fields().lookupField('name'))), 'Got {}'.format(set(self.source.uniqueValues(self.source.fields().lookupField('name'))))

if self.source.supportsSubsetString():
subset = self.getSubsetString2()
Expand Down

0 comments on commit 7711f13

Please sign in to comment.