On Sat, Apr 16, 2011 at 8:00 PM, Michael Bayer <[email protected]>wrote:

>
> On Apr 16, 2011, at 3:57 AM, monster jacker wrote:
>
> > query.union_all(query1, query2) is producing below select statement.As
> > i added label method to change labels of columns to refer in the code.
> > anonimous column names are giving reference errors while accesing
> > result set.
> >
> > SELECT
> >       anon_1.anon_2_row_num AS anon_1_anon_2_row_num,
> > anon_1.anon_2_test_msg AS anon_1_anon_2_test_msg,
> > anon_1.anon_2_date_created AS anon_1_anon_2_date_created,
> > anon_1.anon_2_name_file AS anon_1_anon_2_name_file
> >
> >
> > Here we  don't want to have top level select column name with alias
> > since i am refering in the code as row_num.
> >
> > Can any one suggest what changes to be made in the query.
>
> I'm assuming by "reference error" you're trying to say:
>
>        for row in query:
>                row.row_num
>
> this exact issue is resolved in 0.7 and is introduced at
> http://www.sqlalchemy.org/trac/wiki/07Migration#TuplelabelnamesinQueryImproved.
>    The actual query will still have the "anon" stuff going on, since it
> generates subqueries with names like "anon_1" and "anon_2" and then always
> uses the convention <selectablename>_<columnname> in order to identify
> columns, but the original name should be transferred up to the top.
>
>
>
>
> 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?

        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.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.

Thanks


>
>
>

>
>
>
> --
> 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.
>
>

-- 
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.

Reply via email to