Add an attribute check to the belongs_to resolution chain
Merge branch 'query_improvement'
Revert "Merge branch 'query_improvement'"

This reverts commit 180b7efc7b9ee44f5a219903b708d48526c87de7, reversing
changes made to 4834560e5848e019b2a1872d63610c5dda8c8f0e.
Undo a change to keep master in sync with parent repository master
Delegate the primary_key to the superclass if it doesn't exist