diff --git a/poetry.lock b/poetry.lock index 8e55f85..d2ae4f2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "asgiref" @@ -673,13 +673,13 @@ regex = ["regex"] [[package]] name = "lib-rql" -version = "2.0.0" +version = "2.0.1" description = "Python RQL Filtering" optional = false -python-versions = ">=3.8,<4" +python-versions = "<4,>=3.8" files = [ - {file = "lib_rql-2.0.0-py3-none-any.whl", hash = "sha256:c7f21a69a213665174879f68873b71a8f66765fc8c85517bfa2401e3b85b49cb"}, - {file = "lib_rql-2.0.0.tar.gz", hash = "sha256:94a0ad940e6bbb35afa09eb41b58880afaf80f25b39341fef3e0a9bba2b63564"}, + {file = "lib_rql-2.0.1-py3-none-any.whl", hash = "sha256:6d133f7e1b06bfd4999315e989c4703686924a5029a5e304caccccf0b4656885"}, + {file = "lib_rql-2.0.1.tar.gz", hash = "sha256:e667753dd6e15d28db74757c97205863cae62b7dab983d9d3d270e306bb272a6"}, ] [package.dependencies] diff --git a/tests/test_filter_cls/test_apply_filters.py b/tests/test_filter_cls/test_apply_filters.py index cbc2f44..99e66b7 100644 --- a/tests/test_filter_cls/test_apply_filters.py +++ b/tests/test_filter_cls/test_apply_filters.py @@ -689,3 +689,25 @@ def test_distinct_on_field_field_in_ordering(): def test_distinct_on_field_field_not_in_ordering(): _, qs = BooksFilterClass(book_qs).apply_filters('ordering(int_choice_field)') assert not qs.query.distinct + + +@pytest.mark.django_db +@pytest.mark.parametrize( + 'query', + ( + '(not(ilike(title,*ermat*)))', + '(not(ilike(title,*ermat*))¬(ilike(author__name,*Foo*)))', + '(and(not(ilike(title,*ermat*)),not(ilike(author__name,*Foo*))))', + ), +) +def test_complex_nested_queries(query): + publisher = [Publisher.objects.create() for _ in range(2)] + + author = Author.objects.create(name='Foo', publisher=publisher[0], is_male=False) + Book.objects.create(amazon_rating=4.0, author=author, title='Fermats last theorem') + + other_author = Author.objects.create(name='Bar', publisher=publisher[0], is_male=False) + other_book = Book.objects.create(amazon_rating=4.5, author=other_author, title="Madame Bovary") + other_book2 = Book.objects.create(amazon_rating=4.5, author=other_author, title="Madame Bovary") + + assert apply_filters(query) == [other_book, other_book2]