fixed primary key lookup for many to many relations