try specifying your foreign key as ForeignKey("jdu.subject.id") as a  
workaround for now.

On Jul 18, 2007, at 3:14 AM, jdu wrote:

>
> Hi all,
>
> Since 0.3.9, i have this error:
>
> ArgumentError: Error determining primary and/or secondary join for
> relationship 'Referer.subject (Subject)'. If the underlying error
> cannot be corrected, you should specify the 'primaryjoin' (and
> 'secondaryjoin', if there is an association table present) keyword
> arguments to the relation() function (or for backrefs, by specifying
> the backref using the backref() function with keyword arguments) to
> explicitly specify the join conditions. Nested error is "Can't find
> any foreign key relationships between 'referer' and 'subject'"
>
> Here's the code:
>
> from sqlalchemy import *
>
> metadata = MetaData("postgres://jdu:[EMAIL PROTECTED]:5432/test",
> echo=True)
> schema = "jdu"
>
> subject = Table("subject", metadata,
>                 Column("id", Integer, primary_key=True),
>                 schema=schema)
> referer = Table("referer", metadata,
>                 Column("id", Integer, primary_key=True),
>                 Column("ref", Integer, ForeignKey(subject.c.id)),
>                 schema=schema)
> metadata.create_all()
> metadata.clear()
>
> class Subject(object):pass
> class Referer(object):pass
>
> subject = Table("subject", metadata, schema=schema, autoload=True)
> mapper(Subject, subject)
>
> referer = Table("referer", metadata, schema=schema, autoload=True)
> mapper(Referer, referer, properties=dict(
>     subject=relation(Subject)
> ))
>
> s = create_session(bind=metadata.bind)
> r = s.query(Referer).get(1)  <== it raises error above
>
> It would be cool to not have to specify 'primaryjoin' and
> 'foreign_keys' for each FK for a non-default schema.
> Thanks for your help.
>
> jp
>
>
> >


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