On Dec 9, 2007, at 12:31 PM, Artur Siekielski wrote:
> > Hi again. > Thanks for hints on using "instances" method. But is there any method > to get Query object representing query result? > > I have spent more time on my problem. It's important for me if I can > use Query object as a proxy to instances fetched from DB, or if I must > fall back to raw list. Almost working solution (I'm using PostgreSQL) > is that: > > q = > dbSession > .query(DomainClass).select_from(compoundSelect.alias('myalias')) > > The problem is visible here: >>>> print q > SELECT <all columns of DomainClassTable> > FROM DomainClassTable, <compoundSelect contents> > > The problem is that "DomainClassTable" is always added to FROM clause, > even if I throw it away by hand from q._from_obj list... > hey there - sure, its in the ORM tutorial, and i just fixed that it had no docstring in the pydoc in r3901, and its called from_statement(). select_from() is for adding additional FROM clauses to the generated query. from_statement() is used to entirely replace the compiled statement with that of your own, i.e. dbSession.query(DomainClass).from_statement(myselect). this is the equivalent to query(DomainClass).instances(myselect.execute()). --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---