[sqlalchemy] Re: Accessing classes a table away in a mapper - why does this work?

2009-05-27 Thread Michael Bayer
On May 27, 2009, at 12:23 PM, Nathan Harmston wrote: Hi, I have been struggling with trying to create relations which reference objects a couple of tables away. e.g Sentence has many entities Entity has many NormalisedVersion NormalisedVersion has one Gene kind of thing and was

[sqlalchemy] Re: Accessing classes a table away in a mapper

2009-05-20 Thread Nathan Harmston
The problem was solved by using a join query and then specifying both foreign keys and the secondary argument to the relation. Many thanks, Nathan secondary = sentences_table.join(tag_table.join(processed_tags_table, processed_tags_table.c.tag_id == tag_table.c.tag_id),

[sqlalchemy] Re: Accessing classes a table away in a mapper

2009-05-20 Thread Nathan Harmston
I think I jumped the gun a bit this morning with my excitement. The results are wrong in that they return all of the identifiers in my names table. species_sentences_secondary = sentences_table.join(entities_table, and_(sentences_table.c.sentence_id == entities_table.c.sentence_id,

[sqlalchemy] Re: Accessing classes a table away in a mapper

2009-05-18 Thread Michael Bayer
On May 18, 2009, at 8:02 PM, Nathan Harmston wrote: Hi, I am trying to map a relation in class which allows it to access objects from a couple of tables away ie. class Zone(object): pass class Sentence(object): pass class RawTag(object): pass class ProcessedTag(RawTag):

[sqlalchemy] Re: Accessing classes a table away in a mapper

2009-05-18 Thread Michael Bayer
On May 18, 2009, at 8:06 PM, Michael Bayer wrote: if you want to make a chained join like that, use just primaryjoin(), dont use secondary, and set viewonly=True. I might be off on the dont use secondary advice. if you do use secondary, secondary is the middle table, so in this case it