Fixing Where clause construction. It was failling when seting a column on a join table