Open louking opened 5 years ago
This monkey patch seems to take care of the problem for me. Not sure the best term to use rather than float('inf')
. sys.maxsize
seemed to be recommended in some of the searches I've done, and is portable to python 3. I also tried sys.float_info.max
but this caused error in mysql.
# monkey patch yadcf_range_number search method
def alt_yadcf_range_number(expr, value):
v_from, v_to = value.split('-yadcf_delim-')
v_from = float(v_from) if v_from != '' else -sys.maxsize+1 # was float('-inf')
v_to = float(v_to) if v_to != '' else sys.maxsize # was float('inf')
# logger.debug('yadcf_range_number: between %f and %f', v_from, v_to)
return expr.between(v_from, v_to)
from datatables.search_methods import SEARCH_METHODS
SEARCH_METHODS['yadcf_range_number'] = alt_yadcf_range_number
When I do a yadcf_range_number search with the filter only specifying one side, an error is generated. I am not sure if this is an issue with mysql or with python 2.7 use of float('inf'). The response to the browser has
so seems
float('inf')
at https://github.com/Pegase745/sqlalchemy-datatables/blob/049ab5f98f20ad37926fe86d5528da0c91cd462d/datatables/search_methods.py#L57 results withinf
as the second parameter for the between clause of the query.I see this is tested at https://github.com/Pegase745/sqlalchemy-datatables/blob/049ab5f98f20ad37926fe86d5528da0c91cd462d/tests/test_searching.py#L76 so not sure if this is an issue because I'm using python 2.7 or if mysql doesn't support inf.