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)

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.

Another solution is to use a new, non_primary mapper defined on
compundSelect, but then I wouldn't have relations.

I hope some simple solution exists :).

Regards,
Artur

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