> > > > > > sqlobject.dberrors.OperationalError: no such column: animal.cage_id > > > > > > > > > > But there is "cage_id" columnm in the "animal" table > > > > > > > > Well, that's exactly the problem :) > > > > > > Are you sure this part of the problem is in SQLObject and not in > SQLite? > > > (There are probably other problems - inheritance was developed for > simple > > > use cases and hardly support joins and aggregates...) > > > > I only guess that the problem is with SQLObject since SQLite itself is > > pretty reliable. But I'm getting also more and more convinced that > > using inheritance is not a good idea, I ran into other similar > > troubles too. So probably it's best to stay away from them. > > I use inheritance a lot, but I don't usually do JOINs (I just do it the OO > way since I don't have very large sets of data) and it works very well.
Hi, can you please test the code below (if you have sqlite)? If you use a different db, can you please change the connectionForURI to use yours and test then? The correct output should be 5 of course. If you don't use joins, how would you select the total number of animals in a zoo in this example? Select (almost) everything and filter through them in python? Thanks a lot, Daniel ##################################################################### 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( ) #################################################################### ------------------------------------------------------------------------- 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