Perfectly fine, but you want to create one extra system test which runs this on the database. The question is though if you want to cover this with an additional unit tests because the system test essentially verifies that the query is correct and run. You need to return dummy data though.