Still not there, but another question/problem below: Werner F. Bruhin wrote: > I have a view in an FB db with basically does this > > CREATE VIEW VCBOOK( > CB_CELLARBOOKID, > CBV_CBVINTAGEID, > CBB_CBBOTTLEID > ) > AS > select cb.cellarbookid, cbv.cbvintageid, cbb.cbbottleid, > from cellarbook cb > left outer join cbvintage cbv on cb.cellarbookid = cbv.fk_cellarbookid > left outer join cbbottle cbb on cbv.cbvintageid = cbb.fk_cbvintageid > > The actual view has many more columns but I think the above is enough to > show what I would like to accomplish. > > In the application I then use it e.g. like this: > query(db.Vcbook).all() > > Now as the cbv_cbvintageid and cbb_cbbottleid can be Null I get "None" back. > > I thought lets get rid of this view and just use joins, but I can not > figure it out. > > Doing this: > wine = session.query(db.Cellarbook).outerjoin([db.Cbvintage, > db.Cbbottle]).all() > > Only gives me 5 rows, i.e. only the one from db.Cellarbook. > > Can anyone push me in the right direction on this? > > Werner > P.S. > I am on 0.5rc1 > j1 = sao.outerjoin(db.Cellarbook, db.Cbvintage) print j1
j2 = sao.outerjoin(db.Cbvintage, db.Cbbottle) print j2 j3 = sao.outerjoin(db.Cellarbook, db.Cbvintage).outerjoin(db.Cbvintage, db.Cbbottle) print j3 j1 and j2 produce a join clause, but on j3 I get the following exception: Traceback (most recent call last): File "saTest.py", line 66, in <module> print j3 File "c:\python25\lib\site-packages\sqlalchemy-0.5.0rc1-py2.5.egg\sqlalchemy\sql\expression.py", line 1157, in __str__ return unicode(self.compile()).encode('ascii', 'backslashreplace') File "c:\python25\lib\site-packages\sqlalchemy-0.5.0rc1-py2.5.egg\sqlalchemy\sql\expression.py", line 1153, in compile compiler.compile() File "c:\python25\lib\site-packages\sqlalchemy-0.5.0rc1-py2.5.egg\sqlalchemy\sql\compiler.py", line 175, in compile self.string = self.process(self.statement) File "c:\python25\lib\site-packages\sqlalchemy-0.5.0rc1-py2.5.egg\sqlalchemy\sql\compiler.py", line 183, in process return meth(obj, **kwargs) File "c:\python25\lib\site-packages\sqlalchemy-0.5.0rc1-py2.5.egg\sqlalchemy\sql\compiler.py", line 597, in visit_join self.process(join.right, asfrom=True) + " ON " + self.process(join.onclause)) File "c:\python25\lib\site-packages\sqlalchemy-0.5.0rc1-py2.5.egg\sqlalchemy\sql\compiler.py", line 181, in process meth = getattr(self, "visit_%s" % obj.__visit_name__, None) AttributeError: type object 'Cbbottle' has no attribute '__visit_name__' What is the best/most efficient way of doing multiple joins with SA.orm? Werner --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---