On Nov 3, 2011, at 3:12 PM, thatsanicehatyouh...@mac.com wrote:

> Hi,
> 
> I'm getting the following error with SQLAlchemy 0.7.3:
> 
> sqlalchemy.exc.ArgumentError: Could not determine join condition between 
> parent/child tables on relationship Survey.bossSpectrumHeaders.  Specify a 
> 'primaryjoin' expression.  If 'secondary' is present, 'secondaryjoin' is 
> needed as well.
> 
> I am relating two tables named "Survey" and "BOSSSpectrumHeader". The former 
> is in a schema called "platedb" and the latter in another schema called 
> "boss". The latter table has numerous foreign keys from the platedb schema, 
> but and each fail if I comment out the previous one. The search path is 
> "platedb, shared, boss, photofield, twomass, public". The python code is:

two things I notice, first why using "extend_existing" - suggests theres more 
going on here.  Also are you certain the foreign key from boss.spectrum_header 
points to the "platedb.schema" table and not another "schema" table elsewhere ? 
  Yet another thing, when you reflect the foreign key from spectrum_header, it 
may not be coming back with "platedb" as the schema since you appear to be 
referring to the remote table using the implicit search path.  SQLAlchemy may 
not be matching that up like you expect.  There was an issue regarding this 
which was fixed in 0.7.3, another user relying upon a long search path.   Do 
you get different results using 0.7.2 ?  can you try defining your foreign key 
constraints in PG consistently with regards to how you're using schemas in your 
model ?  (i.e. either the FK is to platedb.schema in PG, or remove the 
"platedb" schema from Survey).




> 
> class BOSSSpectrumHeader(Base):
>    __tablename__ = 'spectrum_header'
>    __table_args__ = {'autoload' : True, 'schema' : 'boss', 'extend_existing' 
> : True}
> 
> class Survey(Base):
>       __tablename__ = 'survey'
>       __table_args__ = {'autoload' : True, 'schema' : 'platedb'}
> 
> Survey.bossSpectrumHeaders = relationship(BOSSSpectrumHeader, 
> backref="survey")
> 
> Finally, the SQL definitions of the tables are pasted below. Is there 
> something I am missing? Why is the foreign key not being retrieved via 
> reflection? Virtually everything else (including cross-schema relationships) 
> is working fine.
> 
> Thanks for any help!
> 
> Cheers,
> Demitri
> 
> ---
> 
> CREATE TABLE boss.spectrum_header
> (
>  pk integer NOT NULL DEFAULT nextval('spectrum_header_pk_seq'::regclass),
> ...
>  survey_pk integer NOT NULL,
>  CONSTRAINT boss_spectrum_header_pk PRIMARY KEY (pk ),
>  CONSTRAINT survey_fk FOREIGN KEY (survey_pk)
>      REFERENCES survey (pk) MATCH SIMPLE
>      ON UPDATE CASCADE ON DELETE RESTRICT
> )
> 
> CREATE TABLE survey
> (
>  pk serial NOT NULL,
>  label text,
>  CONSTRAINT survey_pk PRIMARY KEY (pk ),
>  CONSTRAINT survey_label_uniq UNIQUE (label )
> )
> 
> -- 
> 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.
> 

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