On Wed, Oct 1, 2008 at 11:01 PM, esvist <[EMAIL PROTECTED]> wrote:
>
> Is this what you ment?
>
> from sqlalchemy import *
> from sqlalchemy.orm import *
>
> db = create_engine('CONNECT STRING HERE')
> db.echo = True
>
> meta = MetaData()
> meta.bind = db
>
> user = Table('USER_', meta, autoload=True)
> case = Table('CASE', meta, autoload=True)
> case2user = Table('CASE2USER', meta, autoload=True)
>
> class Case(object):
> pass
> class User(object):
> pass
>
> mapper(Case, case, properties={
> 'users':relation(User, secondary=case2user)
> })
>
> mapper(User, user)
>
> Here
>
> Case.users.select()
>
> gives me the same exception
>
> <class 'sqlalchemy.exc.ArgumentError'>: Could not determine join
> condition between parent/child tables on relation Case.users. Specify
> a 'primaryjoin' expression. If this is a many-to-many relation,
> 'secondaryjoin' is needed as well.
>
> , but I'm not sure if the sample is equivalent and correct...
Yes, this is what I meant. It would help if you provided a way to
create those tables, so that the test case can be run as-is. It seems
correct to me, except the last line:
> Case.users.select()
seem incorrect (though that might be a new usage of SA I'm not aware
of). In any case, it certainly not the equivalent of
"User.query.all()"
The correct equivalent would be:
session = sessionmaker()()
session.query(User).all()
The last step is to create a ticket on SA's trac with your script attached.
--
Gaƫtan de Menten
http://openhex.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---