I don't think there is a really good way to do this with relations.

You could do it with query.instances, though.  Something like this:

j = invasives.join(invasive_names.join(languages), isouter=True)
r = session.query(Invasive).instances(select([j],
j.c.iso_code=='en').execute(), class_mapper(InvasiveName))
for invasive, invasive_name in r:
  ...

On 1/12/07, Julien Cigar <[EMAIL PROTECTED]> wrote:
>
> In fact what I want to be able to do is :
>
> select a.id, (select b.name from invasive_names b, languages c where
> b.invasive_id=a.id and b.language_id=c.id and c.iso_code='en') as
> name_en from invasives a order by foo;
>
> where mappers are : a = Invasive, b = InvasiveName, c = Language
>
> Julien Cigar wrote:
> > Hello,
> >
> > I'm using SQLAlchemy 0.3.3.
> > I have 3 tables :
> > - "invasives" (mapped to class Invasive)
> > - "languages" (mapped to class Language)
> > - "invasive_names" (mapper to class InvasiveName)
> >
> > In other words, I have a table with species which could have a
> > scientific name, English name, etc
> > I'm using the active mapper extension and I have a problem when I sort
> > on the English name of the species with the following :
> >
> > Invasive.select(
> >  and_(
> >    Invasive.join_to('names'),    InvasiveName.join_to('language')
> >    Language.c.iso_code=='en',  )  order_by=InvasiveName.c.name)
> >
> > The problem I have is when a species has no English name, it is not
> > selected ...
> > In other words, I want to do a LEFT JOIN in place of a JOIN with the
> > mapper ...
> >
> > How can I do this ?
> >
> > In advance, thanks
> >
> > Julien
> >
>
>
> --
> Julien Cigar
> Belgian Biodiversity Platform
> http://www.biodiversity.be
> Université Libre de Bruxelles
> Campus de la Plaine CP 257
> Bâtiment NO, Bureau 4 N4 115C (Niveau 4)
> Boulevard du Triomphe, entrée ULB 2
> B-1050 Bruxelles
> office: [EMAIL PROTECTED]
> home: [EMAIL PROTECTED]
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to