> > joins = [ ]
> > joins.append( LEFTJOINOn( None, cage, animal.q.cageID==cage.q.id ) )
> > joins.append( LEFTJOINOn( None, zoo, cage.q.zooID==zoo.q.id ) )
> >
> > print animal.select( zoo.q.name=='myzoo', join=joins ).count( )
> >
> >    generates the query
> >
> > SELECT COUNT(*) FROM named LEFT JOIN cage ON ((animal.cage_id) =
> (cage.id)) LEFT JOIN zoo ON ((cage.zoo_id) = (zoo.id))
> > WHERE (((named.name) = ('myzoo')) AND ((named.child_name) = ('animal')))
> >
> >    for which SQLite returns the error:
> >
> > sqlobject.dberrors.OperationalError: no such column: animal.cage_id
>
>    In case of inheritance a call to .select() can produce a list of rows
> from the different tables (an instances of the different descendant of the
> parent class). This is both the strong point of the inheritance and its
> limitation. Inheritance works in two stages. At the first stage it selects
> IDs from the parent table (hence "FROM named" in the query above); at the
> second stage it draws the real objects from different tables. Because of
> these two stages inheritance cannot be used with complex queries. Joins
> with tables that lay lower in the hierarchy certainly confuses inheritance.

Yes, I understand that implementing inheritance is very tricky. The
question is if there was any way to select the number of animals from
zoo 'myzoo' in the above example (using inheritance) with a single
query. Apparently the above query is not gonna work but is there
another way? Of course one can do several queries but that might hurt
performance. If there is such a single query I'll continue using
inheritance if there is none then I'll just design my models such that
there is no inheritance at all.

Thanks a lot,
Daniel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to