This feels like handing some prospective code monkey an example from the Underhanded C contest without warning them first. Very few people are going to pass that test.
This feels like handing some prospective code monkey an example from the Underhanded C contest without warning them first. Very few people are going to pass that test.
Agree that this isn't a reasonable "normal" programming mistake to run into, but I think the question may be used for seeing how candidates approach a problem that they don't know how to solve.
I doubt the interviewers are looking for someone to get this question 100%, and more likely looking for how candidates would deal with a problem they haven't been confronted with before that seems unsolvable. Does the candidate just say it's impossible or a trick? Or do they double down and try to think of what could possibly cause this and offer up some possibilities?
And you are right, it can easily lead to mistakes; if you use logical operators by mistake when building a query, you will probably get 'True' instead of a query object.