Skip to content
Permalink
Browse files

QPyNullVariant() equals to QPyNullVariant(), qgis.core.NULL

>>>> from qgis.core import NULL
>>>> lyr.getFeatures().next().attributes()[0] == NULL
True
  • Loading branch information
m-kuhn committed Aug 29, 2013
1 parent f7b05ff commit dcd17fdf8ff64dd809e8227368ccc86f137072ad
Showing with 10 additions and 0 deletions.
  1. +10 −0 python/__init__.py
@@ -46,7 +46,17 @@ def __nonzero__(self):
def __repr__(self):
return 'NULL'

def __eq__(self, other):
return isinstance(other, QPyNullVariant) or other is None

QPyNullVariant.__nonzero__ = MethodType(__nonzero__, None, QPyNullVariant)
QPyNullVariant.__repr__ = MethodType(__repr__, None, QPyNullVariant)
QPyNullVariant.__eq__= MethodType(__eq__, None, QPyNullVariant)

# define a dummy QPyNullVariant instance NULL in qgis.core
# this is mainly used to compare against
# so one can write if feat['attr'] == NULL:
from qgis import core
core.NULL = QPyNullVariant( int )
except ImportError:
pass

0 comments on commit dcd17fd

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