On Dec 7, 2007, at 2:39 PM, Artur Siekielski wrote:

>
> I have a compound SELECT statement (of class CompoundSelect) that is
> composed of a few normal SELECTs combined by UNION. from_obj of this
> SELECT contains all columns of a table that is mapped to a class. I
> would like to get objects created using defined mapper, but selected
> using my compound SELECT statement.
>
> I have found a solution: mappers have method 'instances' that can be
> used like that:
>
> instancesList =
> someMapper.instances(dbSession.execute(compoundSelect), dbSession)

use "instances" on Query.   "instances" on mapper is long ago  
deprecated, added a warning in 3874.

> The problem is that I get normal Python list, which eats much
> resources when database is big. Much better would be Query object
> which supports lazy loading. Note that I cannot use
> Query.filter(compoundSelect._whereclause) because CompundSelect
> doesn't have _whereclause.

apply the appropriate LIMIT/OFFSET criterion to the select in order to  
limit rows.  The Query object doesnt have the option to fetch only  
part of a result sets since single instances may be comprised of many  
rows, the same object can appear many times in the same result set,  
and dependencies may exist between objects present in multiple rows;  
everything has to be held as unique against its identity across the  
full result set.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to