Thanks! Is there any plan for a 1.2 release in the near future? On Mon, 16 Jan 2017 12:54:05 -0500 mike bayer <[email protected]> wrote:
> issue > > https://bitbucket.org/zzzeek/sqlalchemy/issues/3891/single-inh-criteria-should-be-added-for > > is added. Targeted at 1.2 as it will break applications unknowingly > relying upon the bug right now. > > For now say func.count(Manager.employee_id), e.g. put the entity in > the columns clause. > > > > On 01/16/2017 12:23 PM, Michael Williamson wrote: > > Hello! > > > > I have a use case where I want to select from a polymorphic table, > > but without selecting any columns from that table. As a simple > > example, consider selecting the count of all rows. When I write > > something like: > > > > sess.query(func.count(1)).select_from(Manager).all() > > > > It seems to be equivalent to: > > > > sess.query(func.count(1)).select_from(Employee).all() > > > > (where Manager inherits from Employee). > > > > Is this intended, or is this a bug? If the former, what's the > > suggested approach to writing such queries? To filter on the > > discriminator explicitly? > > > > For reference, I was able to reproduce the issue with a test case in > > test/orm/inheritance/test_single.py: > > > > def test_select_from_inherited_tables(self): > > Manager, Engineer, Employee = (self.classes.Manager, > > self.classes.Engineer, self.classes.Employee) > > > > sess = create_session() > > m1 = Manager(name='Tom', manager_data='data1') > > e1 = Engineer(name='Kurt', engineer_info='knows how to > > hack') sess.add_all([m1, e1]) > > sess.flush() > > > > eq_( > > sess.query(func.count(1)).select_from(Manager).all(), > > [(1, )] > > ) > > > > Thanks > > > > Michael > > > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
