OK, I'm back again. Played with Elixir and was able to re-implement
your example - got the query desired.

However I've found a couple of strange parts of your code.

1. Why do you mix mapper(), Table and Elixir? Elixir creates tables
and maps everything for you, this is what it was designed for.
    If you want total control, use direct mapping from the previous
example. I think it can be the root cause.

2. using_options(shortnames=True)  - is not neccessary, this option is
ON by default

3. Elixir naming convention for relations  is : member name + parent
key name, so for 'Prosjekt',
   line  p_prosjektid = ManyToOne('Prosjekt') , gives you
p_prosjektid_prosjektid  key, what can be ok, however p_prosjektid
naming itself is confusing, since
   in your case  p_prosjektid - is a relation property, not an id as
reader thinks.



OK, and here is the working thing:

metadata.bind = app.session.connection()
metadata.bind.echo = True

class Prosjekt(Entity):
    using_options(shortnames=True)

    prosjektid = Field(Integer, primary_key=True)
    kundeid = Field(Integer)
    p_prosjekt = ManyToOne('Prosjekt')
    sak = OneToMany('Sak')


class Sak(Entity):
    using_options(shortnames=True)

    saksnr = Field(Integer, primary_key=True)
    prosjektid = ManyToOne('Prosjekt')


setup_all()
create_all()


session.query(Sak).join((Prosjekt,Sak.prosjektid)).filter(Prosjekt.kundeid==15000032).all()
#works

Hope this helps,
Alex
--~--~---------~--~----~------------~-------~--~----~
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