On Mon, Dec 22, 2008 at 17:06, Eoghan Murray <eoghanomur...@gmail.com> wrote:

> The following example uses an elixir class:
>
> class MyE(Entity):
>    id = Field(Integer, primary_key=True)
>    f_1 = ManyToOne('OtherE')
>    f_2 = ManyToOne('OtherE')
>    date = Field(Date)
>
> MyE.query.select_from(union(MyE.table.select(),
>                           select([MyE.id, MyE.f_1.label('f_2'),
> MyE.f_2.label('f_1')]))).\
>    order_by([MyE.date])

I'm not sure what you are trying to do, but MyE.f_1 and MyE.f_2 are
not column objects. f_1_id and f_2_id are.

The following *might* work:

MyE.query.select_from(
    union(MyE.table.select(),
                select([MyE.id, MyE.f_1_id.label('f_2_id'),
MyE.f_2_id.label('f_1_id')]))).\
   order_by([MyE.date])

> This produces the following SQL:
>
> SELECT anon_1.id AS anon_1_id, anon_1.f_1 AS anon_1_f_1, anon_1.date
> AS anon_1_date
> FROM (
> SELECT mye.id AS id, mye.f_1 AS f_1, mye.f_2 AS f_2, mye.date AS date
> FROM mye UNION ALL
> SELECT mye.id AS id, mye.f_2 AS f_1, mye.f_1 AS f_2, mye.date AS date
> FROM mye) AS anon_1 ORDER BY anon_1.date
>
> Which strangely omits the anon_1_f_2 column and so doesn't populate
> the mapper correctly (f_2 is populated with the contents of f_1)
> Is this a bug?
> I've upgraded SQLAlchemy to 0.5.0rc4 and also elixir to 0.6.1 but it
> still appears.

-- 
Gaƫtan de Menten
http://openhex.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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