domain: Fix joining to a subclass and querying the base class.
Merge branch 'master' into stable

* master:
  domain: Fix joining to a subclass and querying the base class.