.count() does not work with single-table polymorphic inheritance

Issue #1008 resolved
Former user created an issue

As asked by Michael Bayer on the mailinglist I'm posting this ticket about {{{.count()}}} returning a wrong count. Original message as follows:

I've created a single table inheritance hierarchy where SpecialThing inherits from BasicThing.

When I {{{session.query(BasicThing).count()}}} the correct count is returned, but {{{session.query(SpecialThing).count()}}} returns the count for BasicThing. In other words, when issuing {{{.count()}}} the {{{'WHERE discriminatorfield='something'}}} clause disappears from the query.

I've attached the small test program showing the problem:

there are 4 basic things:
        1 B first basicthing
        2 B second basicthing
        3 S first specialthing
        4 S second specialthing

there are 4 special things:
        3 S first specialthing
        4 S second specialthing

Am I missing something, or is this a bug, or...? Oh, all this on sqlalchemy-0.4.4.

Thanks, Dieter

Comments (7)

  1. Log in to comment