Bugfix: wrong column used in JOIN clause when querying a reverse association

(Fixes #446) When querying a reverse association, one of the two columns used in the generated 'JOIN...ON' clause was not the right one. One of the columns being used was the table's primary key, whereas the expected one was the foreign key.