Skip to content
Permalink
Browse files
Correctly handle null value coded values
  • Loading branch information
nyalldawson committed Apr 30, 2021
1 parent 4d24b6e commit 65ec930ed89afaa694830732b23e52c2d461882b
Showing with 5 additions and 2 deletions.
  1. +4 −1 src/core/providers/ogr/qgsogrprovider.cpp
  2. +1 −1 tests/src/python/test_provider_ogr.py
@@ -1390,7 +1390,10 @@ void QgsOgrProvider::loadFields()
while ( codedValue && codedValue->pszCode )
{
const QString code( codedValue->pszCode );
const QString value( codedValue->pszValue );
// if pszValue is null then it indicates we are working with a set of acceptable values which aren't
// coded. In this case we copy the code as the value so that QGIS exposes the domain as a choice of
// the valid code values.
const QString value( codedValue->pszValue ? codedValue->pszValue : codedValue->pszCode );

QVariantMap config;
config[ value ] = code;
@@ -1275,7 +1275,7 @@ def testFieldDomains(self):
enum_field = fields[fields.lookupField('with_enum_domain')]
enum_setup = enum_field.editorWidgetSetup()
self.assertEqual(enum_setup.type(), 'ValueMap')
self.assertTrue(enum_setup.config()['map'], [{'one': '1'}, {'': '2'}])
self.assertTrue(enum_setup.config()['map'], [{'one': '1'}, {'2': '2'}])


if __name__ == '__main__':

0 comments on commit 65ec930

Please sign in to comment.