domain: Fix Select.count() on tables with inheritance.
Merge branch 'master' into stable

* master:
  domain: Fix Select.count() on tables with inheritance.