On 9/27/06, Michael Bayer <[EMAIL PROTECTED]> wrote: > this needed an adjustment to the EagerLoader's determination of what > table it should attach its outerjoin onto, which you can see in > changeset 1907 (and some more in 1909). I converted the test program > into a new unittest suite for eagerloading which is in rev 1908, and > also added a test that uses SelectResults, which seems to produce the > identical SQL to that of the "from_obj" version. the SelectResults > looks really nice: > > q=SelectResults(s.query(Test).options(eagerload('category'))) > l=q.select ( > and_(tests.c.owner_id==1,or_ > (options.c.someoption==None,options.c.someoption==False)) > ).outerjoin_to('owner_option') > > the test can be run from the distro directory for any kind of database: > > python test/orm/eagertest3.py --verbose --log-info=sqlalchemy.engine > --dburl "postgres://scott:tiger@/test" > >
I replied to this before the list was having problems but I don't know if that went through or not. The Query.select function now works quite well for my use case. I'm not sure if the count function is supposed to have the same api functionality as the select function, but it currently still has the old behaviour, where the table is appended to the from clause. Here is a little hack I put together to see if it could work: # TEMP hack def ctest(self,whereclause=None,params=None,**kwargs): from_obj=kwargs.pop('from_obj',[]) alltables = [] for l in [sql_util.TableFinder(x) for x in from_obj]: alltables += l if self.table not in alltables: from_obj.append(self.table) sel=select(['count(*)'],from_obj=from_obj) if whereclause: sel.append_whereclause(whereclause) return sel.scalar() Query.count=ctest ---- Mostly, I just copied the new alltables functionality from the other method, and then altered the select to do a count instead. It is working for my queries, but I'm pretty sure this probably isn't the best solution. Specifically, there is probably a better way to get the count that uses database specific logic instead of appending a text element for a column. Also, I don't know if group_by functionality should be supported at this level or not. Good job on everything so far! Dennis ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users