I am generating select queries that include alias tables, literal columns, 
renamed columns via label, multiple joins etc. 

The queries can be somewhat complex and as a debugging feature, I'd like be 
able to know which columns came from which tables...but I don't want to store 
this information static and would like it to be derived from the query itself.

If the column is a literal column, constructed, or similar, then there is no 
original table. If the table is used as part of an == join key, then the column 
should be associated to each of the tables. So if doing three joins, a column 
could have three original parent tables, etc.

So I'd like a mapping from columns to a list of tables. Example: 

select a as aa, b, c, now() as d
from t1 inner join (select a, b, c from t3) t2
on t1.a == t2.a

This should say:

{aa : [t1, t3]
b : [t3]
c : [t3]
d : []}

But with proper sqlalchemy Column, Label, Table objects etc. Seems like this 
should be possible, but I'm not familiar enough with traversing the trees.

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

Reply via email to