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

TypeErrors on db.search(where('value')) #232

Closed
BlackHoleFox opened this issue Sep 8, 2018 · 3 comments

Comments

@BlackHoleFox
Copy link

@BlackHoleFox BlackHoleFox commented Sep 8, 2018

I have been running into TypeErrors whenever I try and run db.search(where("valuehere)). I thought it was just my code so I launched a Python shell and followed exactly the "Basic Usage" and then "Getting Data" steps on https://tinydb.readthedocs.io/en/v1.3.0/usage.html , only to still get the error. Below is the commands and outputs from my terminal:

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from tinydb import TinyDB, where
>>> from tinydb.storages import MemoryStorage
>>> db = TinyDB(storage=MemoryStorage)
>>> db.insert({'int': 1, 'char': 'a'})
1
>>> db.insert({'int': 1, 'char': 'b'})
2
>>> db.insert({'int': 1, 'value': 5.0})
3
>>> db.all()
[{'int': 1, 'char': 'a'}, {'int': 1, 'char': 'b'}, {'int': 1, 'value': 5.0}]
>>> len(db)
3
>>> db.search(where('value'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tinydb\database.py", line 567, in search
    if cond in self._query_cache:
TypeError: unhashable type: 'Query'

PIP tells me that I am running the latest package version as well. Could you have a look?

Thanks!

@msiemens

This comment has been minimized.

Copy link
Owner

@msiemens msiemens commented Sep 13, 2018

Whoopsie!! Seems like this was broken for quite some time and we didn't have test cases for this 🙈 Anyway, this is fixed as of 9722ece, I'll release a new version with the fix soon 🙃

@msiemens

This comment has been minimized.

Copy link
Owner

@msiemens msiemens commented Sep 13, 2018

This is now fixed in TinyDB v3.11.1 🙂

@msiemens msiemens closed this Sep 13, 2018
@BlackHoleFox

This comment has been minimized.

Copy link
Author

@BlackHoleFox BlackHoleFox commented Sep 13, 2018

Very much appreciated. Thanks for the quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.