Thank you for the explanation / brief history overview. Now it makes perfect
sense why things are the way they are. Keep up the excellent work!

Hopefully one day my knowledge of SQL Alchemy will catch up too :-)

Ladislav Lenart


On 6.9.2012 16:23, Michael Bayer wrote:
> 
> On Sep 6, 2012, at 7:25 AM, Ladislav Lenart wrote:
> 
>> Hello.
>>
>>
>> On 6.9.2012 13:04, Michael Bayer wrote:
>>> On Sep 6, 2012, at 5:07 AM, Ladislav Lenart wrote:
>>>
>>>> It works! Thank you very much for such a quick response!
>>>>
>>>> It is a pity I was unable to find it on my own though. I spent several 
>>>> hours
>>>> searching and reading various parts of SA documentation and on 
>>>> stackoverflow - I
>>>> am a SQL / SA newbie and there is A LOT to read. But I've read select_from 
>>>> API
>>>> documentation now and still don't see any mention of this functionality 
>>>> there.
>>>> Is it somewhere? What should I have been googling for to find it quickly 
>>>> in the
>>>> first place?
>>>
>>>
>>> so, approach #1, q_cte_union.all(), didn't work ?  that would be the more 
>>> direct approach and follows the examples at 
>>> http://docs.sqlalchemy.org/en/rel_0_7/orm/query.html#sqlalchemy.orm.query.Query.union
>>>  .
>>> for approach #2 the select_from() docs don't have any examples right now to 
>>> suggest the kinds of things that can go in there (which is of course, 
>>> anything that represents rows).
>>
>> I guess I don't follow. q_cte_union.all() raises the following exception:
>>
>>    AttributeError: 'CTE' object has no attribute 'all'
> 
> oh, that's a CTE, sorry.   
> 
> this is a new feature which is based pretty much verbatim from Postgresql's 
> examples.     We'll probably add more examples to 
> http://docs.sqlalchemy.org/en/rel_0_7/orm/query.html?highlight=cte#sqlalchemy.orm.query.Query.cte
>  at some point.   I'm amazed how many people are actually using the CTE 
> feature.
> 
>>
>> My original query without select_from() works but it only returns named 
>> tuples,
>> not actual ORM instances. I need/want to work with ORM instances because of
>> their additional behaviour (methods).
> 
> the object returned by CTE is a Core "selectable" construct, that is, it's 
> like a Table or select() object (ultimately all known as FromClause objects). 
>  To take any FromClause and return ORM instances from it can be done using 
> query(entity).from_statement(fromclause.select()) or 
> query(entity).select_from(fromclause).   It's also a relatively recent 
> feature that a FromClause can be passed into select_from().
> 
> So these are all new usages stemming from the Query's ever improving 
> consistency with itself and with the Core, which is actually improving 
> further in 0.8.   Takes awhile for the docs to catch up.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to