morlandi / django-ajax-datatable

A Django app which provides the integration of a Django project with the jQuery Javascript library DataTables.net
MIT License
204 stars 64 forks source link

Multiple search values seems to be broken #63

Closed PetrDlouhy closed 2 years ago

PetrDlouhy commented 2 years ago

When I set search_values_separator = '+' and try to search for term with + in it, I have got following error:

  File "/home/petr/.cache/pypoetry/virtualenvs/blenderkit-server-eqrfB9dY-py3.9/lib/python3.9/site-packages/ajax_datatable/views.py", line 817, in filter_queryset
    qs = self.filter_queryset_all_columns(params['search_value'], qs)
  File "/home/petr/.cache/pypoetry/virtualenvs/blenderkit-server-eqrfB9dY-py3.9/lib/python3.9/site-packages/ajax_datatable/views.py", line 883, in filter_queryset_all_columns
    return self._filter_queryset(searchable_columns, search_value, qs, True)
  File "/home/petr/.cache/pypoetry/virtualenvs/blenderkit-server-eqrfB9dY-py3.9/lib/python3.9/site-packages/ajax_datatable/views.py", line 866, in _filter_queryset
    column_filter = build_column_filter(column_name, column_obj, column_spec, search_value, global_filtering)
  File "/home/petr/.cache/pypoetry/virtualenvs/blenderkit-server-eqrfB9dY-py3.9/lib/python3.9/site-packages/ajax_datatable/filters.py", line 26, in build_column_filter
    values = column_obj.search_in_choices(search_value)
  File "/home/petr/.cache/pypoetry/virtualenvs/blenderkit-server-eqrfB9dY-py3.9/lib/python3.9/site-packages/ajax_datatable/columns.py", line 119, in search_in_choices
    pattern = pattern.lower()
AttributeError: 'list' object has no attribute 'lower'
morlandi commented 2 years ago

Thank you for reporting this. Thank you for supplying a PR on this. Thank you for providing (finally) usefull unit tests 👏 👏 👏

morlandi commented 2 years ago

Thank you @PetrDlouhy for your great contribution. I was unable to reproduce the problem reported in this issue and fixed by your PR, but never mind.

I still have some problems when running the unit tests, and some questions. I will open a new Isser for that