you'd need to organize things differently for the column grabbing to work out.

I'd advise producing the query using ORM-level Query in the first place so that 
you don't need to use from_statement(), which is really a last resort system.


On Apr 25, 2013, at 10:27 AM, Richard Gerd Kuesters <rich...@humantech.com.br> 
wrote:

> Well, not the desired result ... Now things justs blows :-) 
> 
> sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column 
> 'anon_1.level'"
> 
> 
> Cheers,
> Richard.
> 
> 
> On 04/25/2013 11:03 AM, Michael Bayer wrote:
>> why not just say session.query(MyObj, q.alias()) ?        creating ad-hoc 
>> mappers is relatively expensive.
>> 
>> 
>> 
>> On Apr 25, 2013, at 8:56 AM, Richard Gerd Kuesters 
>> <rich...@humantech.com.br> wrote:
>> 
>>> Well, probably nevermind because I made a workaround that satisfies me (may 
>>> not be elegant, but that's OK).
>>> 
>>> Basically, I created the "o" type a little different: "o = type('MyObjExt', 
>>> (Base,), {'__table__':q.alias('q')})" and append it to the query like: 
>>> "session.query(MyObj, o).from_statement(q).all()"
>>> 
>>> Okay, now it returns a typle, but at least I don't have to make a second 
>>> query :)
>>> 
>>> 
>>> Cheers,
>>> Richard.
>>> 
>>> On 04/25/2013 09:41 AM, Richard Gerd Kuesters wrote:
>>>> Hi all,
>>>> 
>>>> I've been playing with "sqla_hierarchy" from 
>>>> https://github.com/marplatense/sqla_hierarchy .
>>>> 
>>>> The problem is: the returned query appends 3 columns: level (Integer), 
>>>> is_leaf (Boolean) and connect_path (pg ARRAY).
>>>> 
>>>> So far, so good. If I execute the query using 
>>>> "session.execute(q).fetchall()", it works like a charm. But, as we know, 
>>>> "session.execute" returns a RowProxy, not objects. Using 
>>>> "session.query(MyObj).from_statement(q).all()", I'm able to get my mapped 
>>>> objects, but without the extra columns that would make me very pleased 
>>>> (level, is_leaf, connect_path). Is there a way to get around this?
>>>> 
>>>> I have done testings using "o = type('MyObjExt', (MyObj,), {'__table__': 
>>>> q}" and them use it on the session.query, *but* it looses foreign key 
>>>> references - or, well, I don't know how to "explain" this to the mapper 
>>>> (?), since MyObj is polymorphic (probably the pitfall?).
>>>> 
>>>> 
>>>> Thanks for your time and help.
>>>> 
>>>> Best regards,
>>>> Richard.
>>>> -- 
>>>> You received this message because you are subscribed to the Google Groups 
>>>> "sqlalchemy" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>> email to sqlalchemy+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to sqlalchemy@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>  
>>>>  
>>> 
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "sqlalchemy" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to sqlalchemy+unsubscr...@googlegroups.com.
>>> To post to this group, send email to sqlalchemy@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sqlalchemy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to sqlalchemy+unsubscr...@googlegroups.com.
>> To post to this group, send email to sqlalchemy@googlegroups.com.
>> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to