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

Key ambiguity #73

Open
Jwink3101 opened this issue Mar 7, 2018 · 7 comments · May be fixed by #74
Open

Key ambiguity #73

Jwink3101 opened this issue Mar 7, 2018 · 7 comments · May be fixed by #74

Comments

@Jwink3101
Copy link

When using integer keys, they are converted to strings. Therefore:

mysqlitedict['1'] = 'ONE'
mysqlitedict[1] = 1

all refer to the same thing.

@Jwink3101
Copy link
Author

Just to add, it also can't handle tuple keys

@menshikh-iv
Copy link
Contributor

@Jwink3101 thanks for the report & PR

CC: @piskvorky how this should work?

@piskvorky
Copy link
Owner

IIRC there was a long discussion about encoding keys, and in the end we decided against it.

I don't remember the arguments any more, let me search through the issue history.

@piskvorky
Copy link
Owner

piskvorky commented Mar 8, 2018

The thread starts with #19 and continues all the way through #25, #26, #30 to #31 (closed as abandoned).

@Jwink3101
Copy link
Author

In the changes of #74, byte/string keys are not modified. However, it appears as though the json encoding/decoding of the object may affect strings/bytes, especially on python2. I am not 100% sure of this behavior. But, it is worth noting again that this should not break any backwards compatibility as other keys are not touched.

As I mentioned also in #74, one remedy in general is to instead use the pickle of the object as the key but I think that is risky since, in my quick testing, while the unpickled object between py2.7 and 3.6 pass an equality check, they are not the same (even if you base64 encode them) and therefore would not be found.

@menshikh-iv
Copy link
Contributor

@piskvorky through?

@Jwink3101
Copy link
Author

Has anyone given this more consideration?

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

Successfully merging a pull request may close this issue.

3 participants