Why does overriding the query in default search model stop my filter from working as it should

Lets say i have a search model called BooksSearch.php.

By default inside the BooksSearch.php i will have something like $query = Books::find();

But for some reasons i need to have a custom query which results in my $query = Books::find(); changing to something like $query = Books::findBySQL(“my custom query”);

the thing is the moment i switch to this $query = Books::findBySQL(“my custom query”); fine it gives me the right results meaning it displays the appropriate result in gridview but when i try using the search filter it doesn’t work. It just reloads and then shows the way it was without displaying the appropriate results.

Please share your BooksSearch model.

It’s by design.
The following is from the API reference of findBySql().