> > > > http://sqlobject.gcu.info/trac/ticket/294
> > >
> > >    If you replace the first join with (replace None with animal table)
> > > joins.append( LEFTJOINOn( animal, cage, animal.q.cageID==cage.q.id ) )
> > >    would it help?
> >
> > Hi Oleg, this thing would be of interest to me as well.
> >
> > After doing the change you advised the query runs without an exception
> > but prints 0 which is obviously incorrect. I'm on sqlite, maybe
> > somebody else could test with other backends?
>
> 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
>
>    The problem is that there is no table 'animal' in the FROM list. I am
> trying to put the table there:
>
> joins = [ ]
> joins.append( LEFTJOINOn( animal, 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( )
>
>    which leads to the query
>
> SELECT COUNT(*) FROM named, animal 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')))
>
>    The result is '0', though - no rows are found. Now I don't know what
> a query you expected.

The result should be 5 because that query should select the total
number of animals in the zoo 'myzoo'. Without inheritance the query
works and prints 5, hence my guess that there is a problem with
inheritance. The query should return the same result with or without
inheritance, or?

-------------------------------------------------------------------------
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