Skip to content
This repository has been archived by the owner on Jul 20, 2018. It is now read-only.

Float precision issue in ranged queries #8

Open
kreichgauer opened this issue Dec 6, 2010 · 0 comments
Open

Float precision issue in ranged queries #8

kreichgauer opened this issue Dec 6, 2010 · 0 comments

Comments

@kreichgauer
Copy link
Contributor

The current implementation of ranged queries does not work correctly in some cases due to the way redis-py handles floats.

The implementations of lt, gt, etc. in SortedSet, all call redis-py's zrangebyscore with a float as one of the arguments (_min_score or _max_score). redis-py calls convert on these to convert them to strings, using str(), which results in a loss of float precision. This means, that ranged queries like FooModel.objects.zfilter(some_attr__lt=10.009) return wrong results. I'd suggest converting float arguments to a string using "%f" % value before passing them to a redis-py query.

jeloou referenced this issue in jeloou/redisco Feb 11, 2013
Using transactions in Mutex.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant