On Apr 18, 2011, at 1:50 AM, monster jacker wrote:
> Hi Micheal,
> As per your comment you want to say this issue whatever i am facing
> is resolved in 0.7 version of sqlalchemy?
> If i use the 0.7beta version this issue can be resolved?
that is the case
>
> What i actually want to say is since i am refering in the code the
> column names as "row_num " but the query after the union is aliasing it as
> anon_1.anon_2_row_num so we are not getting any result set.
I dont understand what "not getting any result set means". Here is the
structure you showed me:
select * from
(
select * from table1
union all
select * from table3
) as anon2
union all
select * from table4
) as anon1
this looks kind of like you're saying
query.union_all(query2).union_all(query3). UNION ALL is entirely commutative
and associative. The above returns the equivalent rows as:
select * from table1 union all select * from table3 union all select * from
table4
so you should get the same number of result rows as if no aliasing were used.
> if i change the code with "anon_1.anon_2_row_num" at that time if there are
> more than 2 unions at that time i wil get "anon_1.anon_2_anon_3_row_num" at
> that time will get the same issue what i am facing.so i want to know is there
> any way so that i can avoid aliasing as "anon_1_anon_2_row_num" for all the
> columns at the top level query.
The Query should return to you tuples that have names like "row_num" and
"test_msg", which are linked to the "anon" names that it generates:
for row in myquery:
print row.row_num, row.test_msg
that is, the "anon_x" names do not matter. they are an artifact of how the
Query does its work and the result rows are translated back to the constructs
you gave it originally.
If you'd like a SQL string that is constructed to an exact specification, use
the SQL expression language instead of the ORM Query object.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.