add new kv pair with empty value check

This commit is contained in:
NIC619 2017-12-09 01:29:38 +08:00
parent f51e06f453
commit 2149282638
1 changed files with 3 additions and 0 deletions

View File

@ -128,6 +128,9 @@ def _update(db, node, keypath, val):
# viii (CHILD, (k[1:], NEWCHILD)) # viii (CHILD, (k[1:], NEWCHILD))
else: else:
cf = common_prefix_length(L, keypath[:len(L)]) cf = common_prefix_length(L, keypath[:len(L)])
# New key-value pair can not contain empty value
if not val:
return node
# valnode: the child node that has the new value we are adding # valnode: the child node that has the new value we are adding
# Case 1: keypath prefixes almost match, so we are in case (i), (ii), (v), (vi) # Case 1: keypath prefixes almost match, so we are in case (i), (ii), (v), (vi)
if len(keypath) == cf + 1: if len(keypath) == cf + 1: