Added a test for getting a relation, with a fix for a bad SQL query.