- attached polymorphic_count.py
.count() does not work with single-table polymorphic inheritance
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)
-
Account Deleted -
repo owner -
repo owner - changed title to .count() does not work with single-table polymorphic inheritance
-
repo owner - marked as critical
-
repo owner - marked as major
fixed for 0.5 in e525aee01556e59ff9fc02dd68fd6a38532fe45a. Still unclear if we want to try making this work for 0.4 as well.
-
repo owner - changed status to resolved
a minimal 0.4 version in aa3679794da096f4f758556ad5adf32922173d06.
-
repo owner - removed milestone
Removing milestone: 0.4.xx (automated comment)
- Log in to comment
test program showing the problem