Checks to see if the record contains the foreign_key to set the inverse automatically

Fixes #12866: if the record attributes do not contain the foreign_key as a consequence of a limited select, it should not automatically set the inverse relation.