I see. I probably have to go back to the drawing board and revise how the 
whole thing works. Thanks anyway for the insight. At least I know that 
there isn't much I can do this way (the query actually consists of many 
joins). Handy to know how to access the from clause (unrelated to my post, 
but is there more documentation on this and other parts of the query?)...

Many thanks for the swift response (and SQLAlchemy for that matter :)).

On Thursday, August 29, 2013 9:46:02 PM UTC+10, Michael Bayer wrote:
>
>
> On Aug 28, 2013, at 11:48 PM, gbr <doub...@directbox.com <javascript:>> 
> wrote:
>
> to compile the WHERE clause of "query" means we look at "query.c.id" 
>> which means we must render the table "query" which is how it cycles.    
>
>
> Why does it need to compile the whole query when I just want to use than 
> column name of the query?
>  
>
>> What it seems like you're looking to do is where(location.c.id < 100).
>>
>
> Correct. Unfortunately, I don't have access to `location.c.id`. The query 
> is generated and just returned as an object. All I can do to alter it, is 
> by using attributes of `query`. Is there any way of using the columns 
> without triggering a complete compilation of `query`?
>
>
>
> OK well "compilation" means, "we turn it into a string when you pass it to 
> execute()", and obviously that has to go completely.  the issue isn't that 
> we need to skip anything, it's that query.c.id is not the Column object 
> you're looking for.
>
> if you really wanted to get at that location.c.id and you really don't 
> have the table or anything being passed, well it would be a lot better to 
> alter that, but otherwise you could perhaps dig into froms like this:
>
> my_table = s.froms[0]
> s.append_whereclause(my_table.c.id)
>
> that will work, it's just brittle, if your select() is against more than 
> one Table, or a join, or something like that, your target table would 
> probably no longer be as easy as s.froms[0].
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to