- Notifications
You must be signed in to change notification settings - Fork590
Closed
Description
The id of the element will change to a unicode string after JSON serialization/deserialization. This causes no way to get the element by integer eid.
Python2.7.6 (default,Sep92014,15:04:36)[GCC4.2.1CompatibleAppleLLVM6.0 (clang-600.0.39)]ondarwinType"help","copyright","credits"or"license"formoreinformation.>>>fromtinydbimportTinyDB>>>db=TinyDB('/tmp/test.json')>>>db.insert({'foo':'bar'})1>>>db.all()[{u'foo':u'bar'}]>>>element=db.all()[0]>>>element.eidu'1'>>>assertdb.get(eid=1)isnotNoneTraceback (mostrecentcalllast):File"<stdin>",line1,in<module>AssertionError>>>assertdb.get(eid='1')isnotNone>>>db.update({'foo':'blah'},eids=[1])Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>File"/Users/wolfg/.virtualenvs/opensource/lib/python2.7/site-packages/tinydb/database.py",line335,inupdatecond,eids)File"/Users/wolfg/.virtualenvs/opensource/lib/python2.7/site-packages/tinydb/database.py",line222,inprocess_elementsfunc(data,eid)File"/Users/wolfg/.virtualenvs/opensource/lib/python2.7/site-packages/tinydb/database.py",line334,in<lambda>self.process_elements(lambdadata,eid:data[eid].update(fields),KeyError:1>>>db.update({'foo':'blah'},eids=['1'])>>>db.all()[{u'foo':u'blah'}]>>>db.contains(eids=[1])False>>>db.contains(eids=['1'])True
Metadata
Metadata
Assignees
Labels
No labels