redisco icon indicating copy to clipboard operation
redisco copied to clipboard

Float precision issue in ranged queries

Open kreichgauer opened this issue 14 years ago • 0 comments

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.

kreichgauer avatar Dec 06 '10 22:12 kreichgauer