Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.keys() sometimes doesn't work after saving and reloading #4

Closed
talwrii opened this issue Aug 11, 2016 · 1 comment
Closed

.keys() sometimes doesn't work after saving and reloading #4

talwrii opened this issue Aug 11, 2016 · 1 comment

Comments

@talwrii
Copy link

talwrii commented Aug 11, 2016

Repro

ipython
Python 2.7.12 (default, Jun 29 2016, 08:18:26)
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
[TerminalIPythonApp] WARNING | File not found: '/home/tom/.pythonrc.py'

In [1]: import jsondb

In [2]: jsondb.create({}, url='/tmp/test.db')
Out[2]: <jsondb.JsonDB at 0x7f92c07bf1d0>

In [3]: d = _

In [4]: d.keys()
Out[4]: []

In [5]: d['a'] = 1

In [6]: d.keys()
Out[6]: ['a']

In [7]: d.close()

In [8]: d = jsondb.load(url='/tmp/test.db')

In [9]:

In [9]: d.keys()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-9-8bc560538296> in <module>()
----> 1 d.keys()

/home/tom/.local/lib/python2.7/site-packages/jsondb/core.pyc in __getattr__(self, name)
     90
     91     def __getattr__(self, name):
---> 92         cls = self.get_datatype()
     93         try:
     94             attr = getattr(cls, name)

/home/tom/.local/lib/python2.7/site-packages/jsondb/core.pyc in get_datatype(self)
    282
    283     def get_datatype(self):
--> 284         return get_datatype_class(self.datatype)
    285
    286     def data(self, update=False):

/home/tom/.local/lib/python2.7/site-packages/jsondb/datatypes.pyc in get_datatype_class(_type)
     47     if _type == NIL:
     48         return None
---> 49     cls = DATA_INITIAL[_type].__class__
     50     return cls
     51

KeyError: None

In [10]: d.items()
Out[10]: [('a', 1)]
@shaung shaung closed this as completed in b20d4bf Aug 23, 2016
@shaung
Copy link
Owner

shaung commented Aug 23, 2016

Fixed in trunk! Please reopen this issue If it's still broken.

shaung added a commit that referenced this issue Sep 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants