This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the testing category.
Last Updated: 2024-12-03
Imagine you wanted an inner join but accidentally wrote a cross join (cartesian product). Testing your code with only one comment and one user (two records total) will give one row result, hiding the fact that it was a cartesian product.
If, instead, you had two comments, one of which did not belong to the user, then you would notice your mistake. (Also: there would be too many rows in the results)
Therefore, as with tests for index
actions in Restful controllers or arrays in
unit tests, your DB join queries should have a test case containing MANY
elements for extra rigor.