@@ -689,3 +689,25 @@ def test_distinct_on_field_field_in_ordering():
689689def test_distinct_on_field_field_not_in_ordering ():
690690 _ , qs = BooksFilterClass (book_qs ).apply_filters ('ordering(int_choice_field)' )
691691 assert not qs .query .distinct
692+
693+
694+ @pytest .mark .django_db
695+ @pytest .mark .parametrize (
696+ 'query' ,
697+ (
698+ '(not(ilike(title,*ermat*)))' ,
699+ '(not(ilike(title,*ermat*))¬(ilike(author__name,*Foo*)))' ,
700+ '(and(not(ilike(title,*ermat*)),not(ilike(author__name,*Foo*))))' ,
701+ ),
702+ )
703+ def test_complex_nested_queries (query ):
704+ publisher = [Publisher .objects .create () for _ in range (2 )]
705+
706+ author = Author .objects .create (name = 'Foo' , publisher = publisher [0 ], is_male = False )
707+ Book .objects .create (amazon_rating = 4.0 , author = author , title = 'Fermats last theorem' )
708+
709+ other_author = Author .objects .create (name = 'Bar' , publisher = publisher [0 ], is_male = False )
710+ other_book = Book .objects .create (amazon_rating = 4.5 , author = other_author , title = "Madame Bovary" )
711+ other_book2 = Book .objects .create (amazon_rating = 4.5 , author = other_author , title = "Madame Bovary" )
712+
713+ assert apply_filters (query ) == [other_book , other_book2 ]
0 commit comments