Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Last active December 16, 2015 03:08
Show Gist options
  • Save springmeyer/5367262 to your computer and use it in GitHub Desktop.
Save springmeyer/5367262 to your computer and use it in GitHub Desktop.
is null empty string regression in mapnik 2.2-pre
'' != null: False
0 != null: False
null != null: False
----------
'' = null: False
0 = null: False
null = null: False
----------
'' != '': False
0 != '': True
null != '': True
----------
'' = '': True
0 = '': False
null = '': False
import mapnik
def make(val):
context = mapnik.Context()
f = mapnik.Feature(context,0)
f["prop"] = val
return f
as_string = {
None:'null',
'':'\'\'',
0:'0'
}
def debug(expr,val):
val_string = as_string[val]
print "%s: " % (expr.replace('[prop]',val_string)), mapnik.Expression(expr).evaluate(make(val))
print
debug("[prop] != null",'')
debug("[prop] != null",0)
debug("[prop] != null",None)
print '-'*10
debug("[prop] = null",'')
debug("[prop] = null",0)
debug("[prop] = null",None)
print '-'*10
debug("[prop] != ''",'')
debug("[prop] != ''",0)
debug("[prop] != ''",None)
print '-'*10
debug("[prop] = ''",'')
debug("[prop] = ''",0)
debug("[prop] = ''",None)
'' != null: True
0 != null: True
null != null: False
----------
'' = null: False
0 = null: False
null = null: True
----------
'' != '': False
0 != '': True
null != '': True
----------
'' = '': True
0 = '': False
null = '': False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment