The Daily WTF
Follow
Representative Line: Both Ways Bug Me
Debugging code often leads to peculiar and sometimes nonsensical expressions appearing in production environments. One such instance involves a SQL query containing an unusual conditional clause. The problematic section of the query is WHERE (some conditions) AND (1 = 0 OR (1 = 1 AND (other conditions))). This structure allows for toggling between always returning rows or returning rows based on the main conditions by manipulating the '1 = 0' part. It's also possible to configure it to never return rows, though its utility is questionable. The author suggests these are likely remnants of debugging flags that were never removed. Such lingering flags indicate a deficiency in code observability. Like many such flags, these are undocumented and seem to have been present since the code's release. The query likely originated as a temporary tool for an analyst before becoming a permanent stored procedure. The presence of these "dead" flags points to a broader issue in development and deployment practices.