> > if the model is changed slightly to use inheritance: > > then the exact same query stops working. > > In what way?
Here is a full traceback: 37/QueryOne: 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'))) 37/QueryR : 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'))) Traceback (most recent call last): File "dbtest.py", line 50, in <module> print animal.select( zoo.q.name=='myzoo', join=joins ).count( ) File "/usr/local/lib/python2.5/site-packages/SQLObject-0.10dev_r2716-py2.5.egg/sqlobject/sresults.py", line 222, in count count = self.accumulate('COUNT(*)') File "/usr/local/lib/python2.5/site-packages/SQLObject-0.10dev_r2716-py2.5.egg/sqlobject/sresults.py", line 207, in accumulate return conn.accumulateSelect(self, *exprs) File "/usr/local/lib/python2.5/site-packages/SQLObject-0.10dev_r2716-py2.5.egg/sqlobject/dbconnection.py", line 408, in accumulateSelect val = self.queryOne(q) File "/usr/local/lib/python2.5/site-packages/SQLObject-0.10dev_r2716-py2.5.egg/sqlobject/dbconnection.py", line 385, in queryOne return self._runWithConnection(self._queryOne, s) File "/usr/local/lib/python2.5/site-packages/SQLObject-0.10dev_r2716-py2.5.egg/sqlobject/dbconnection.py", line 255, in _runWithConnection val = meth(conn, *args) File "/usr/local/lib/python2.5/site-packages/SQLObject-0.10dev_r2716-py2.5.egg/sqlobject/dbconnection.py", line 378, in _queryOne self._executeRetry(conn, c, s) File "/usr/local/lib/python2.5/site-packages/SQLObject-0.10dev_r2716-py2.5.egg/sqlobject/sqlite/sqliteconnection.py", line 183, in _executeRetry raise OperationalError(ErrorMessage(e)) sqlobject.dberrors.OperationalError: no such column: animal.cage_id You can reproduce the problem with the following: ##################################################################### from sqlobject import * from sqlobject.inheritance import InheritableSQLObject from sqlobject.sqlbuilder import LEFTJOINOn from sqlobject import connectionForURI sqlhub.processConnection = connectionForURI( 'sqlite:///:memory:', debug=True ) class named( InheritableSQLObject ): name = StringCol( ) class zoo( named ): # class zoo( SQLObject ): # name = StringCol( ) cages = MultipleJoin( 'cage' ) class cage( named ): # class cage( SQLObject ): # name = StringCol( ) animals = MultipleJoin( 'animal' ) zoo = ForeignKey( 'zoo' ) class animal( named ): # class animal( SQLObject ): # name = StringCol( ) cage = ForeignKey( 'cage' ) named.createTable( ) zoo.createTable( ) cage.createTable( ) animal.createTable( ) z = zoo( name='myzoo' ) c1 = cage( name='firstcage', zoo=z ) c2 = cage( name='secondcage', zoo=z ) a11 = animal( name='tiger', cage=c1 ) a12 = animal( name='lion', cage=c1 ) a21 = animal( name='croc', cage=c2 ) a22 = animal( name='hypo', cage=c2 ) a23 = animal( name='fish', cage=c2 ) print '-'*80 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( ) #################################################################### If you comment out all references to 'named' and subclass from SQLObject instead, the query works as expected and prints 5, the correct number. Cheers, Daniel ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss