You're absolutely correct, it was the relationship declaration that was my 
issue. Removing the lazy='joined' from the code removed the outer joins. 

I really appreciate the speedy and concise answer. Thank you very much!

On Monday, September 17, 2012 11:06:10 AM UTC-7, Michael Bayer wrote:
>
>
> On Sep 17, 2012, at 1:38 PM, mjallday wrote:
>
> I also tried
>
>     Ledger.query.from_statement(union.select()) 
>
> I would expect this to be fast since it's mapping the original columns in 
> the query to what the object expects. However, I'm having trouble with this 
> syntax and getting this error:
>
>      ** NoSuchColumnError: "Could not locate column in row for column 
> 'ledger.guid'"
>
>
> OK, try out tip, since there was a bug exactly in this area, that is 
> from_statement(union), that is fixed for 0.7.9.  there's also a bunch of 
> CTE-related fixes.
>
>
> This appears to be because the table is aliased as reference_ledger.
>
> So my questions are:
>
> 1. Am I writing the CTE in the wrong way to be the select_from method?
>
>
> Those LEFT OUTER JOINs look like you have lazy=False set up, or something, 
> since I don't see you otherwise specifying any joins.  I usually leave 
> joined-loads off at the relationship() level.  Especially if you're 
> self-referential, and dealing with CTEs and stuff, you don't want any 
> complexity enabled by default on your mappings.    That will probably fix 
> this issue.
>
> 2. How can I use the from_statement method to work with an aliased table?
>
>
> see above tip recommendation.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/3s1Mq3_kUvIJ.
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