Yep Michael, the "InvasiveName" object contains a "Language" object,
here is the complete definition of those tables:
languages = Table('languages', meta,
Column('id', Integer, primary_key=True),
Column('iso_code', String(2)),
Column('language', String(100)))
invasives = Table('invasives', meta,
Column('id', Integer, primary_key=True),
Column('added', DateTime, default=func.current_timestamp()),
Column('modified', DateTime, default=func.current_timestamp(),
onupdate=func.current_timestamp()),
Column('geographic_range', String(3)),
Column('trend', String(30)),
Column('black_lists_belg', String(3)),
Column('status', Integer),
Column('group_id', Integer, ForeignKey('taxonomies.id'),
nullable=False),
Column('subgroup_id', Integer, ForeignKey('taxonomies.id'),
nullable=False),
Column('added_by', Integer, ForeignKey('users.id')))
invasive_names = Table('invasive_names', meta,
Column('name', String(200)),
Column('language_id', Integer, ForeignKey('languages.id'),
primary_key=True),
Column('invasive_id', Integer, ForeignKey('invasives.id'),
primary_key=True))
In fact I don't understand very well the difference between a classic
many-to-many and the association object ..
As I understood, the Association object should be used when there is an
other column which add information how two items are linked (in my case
column "name" in invasive_names) ?
Thanks !
Julien
Michael Bayer wrote:
> this mapper setup would imply that the InvasiveName is mapped to the
> "languages" table. which im guessing is not the case. is there a
> Languages object ?
>
> it seems like youre looking for the "association object" pattern here
> instead of the straight many-to-many.
>
>
>
> On Jul 26, 2006, at 3:29 AM, Julien Cigar wrote:
>
>> Hello !
>>
>> I have three tables (not everything is shown, for legibility):
>>
>> invasives (pk: id)
>> languages (pk: id)
>> invasive_names (pk: (fk: invasive_id, fk: language_id), invasive_name)
>>
>> invasives contains specimens and invasives_names are the names for that
>> specimen (in french, dutch, german, latin, ...)
>>
>> The scientific name for the specimen is in 'latin', and I'd like to have
>> a property 'scientific_name' in the invasive mapper whit the latin name.
>> I tried :
>>
>> mapper(Invasive, invasives, properties = {
>> (...)
>> 'scientific_name' : relation(InvasiveName, secondary=invasive_names,
>> primaryjoin=invasives.c.id==invasive_names.c.invasive_id,
>> secondaryjoin=and_(invasive_names.c.language_id==languages.c.id,
>> languages.c.iso_code=='la')),
>> (...)
>> }
>> )
>>
>> ... but I got an error :
>>
>> ArgumentError: No syncrules generated for join criterion
>> invasive_names.language_id = languages.id AND languages.iso_code =
>> %(languages_iso_code)s
>>
>> Any idea what I did wrong ?
>>
>> Thanks !
>>
>> -------------------------------------------------------------------------
>>
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to
>> share your
>> opinions on IT & business topics through brief surveys -- and earn cash
>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>>
>> _______________________________________________
>> Sqlalchemy-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users