Add custom key support for hasMany relationships

Turns out using a custom embedded key for polymorphic hasMany relationships wasn't working. Fixed this, and added a test for the functionality.