Hello,

I'm using 'SQLAlchemy-0.4.7' and I want to realize a join between two
tables over a mediate table. So I have written following code:

---------------------------------------
class MSanctionEntity(Mapper):

    class_name = 'hapo.common.entity.SanctionEntity'
    table_name = 'ent_entity'

      //table 'ent_entity' = parent-table
      //table 'cou2ent' = mediate table
      //'hapo.common.countries.Country' is mapped on table
''cou_country' (child)

 
@mapper_property('hapo.common.countries.Country',secondary_table='cou2ent')
    def citizens(self, mapper, cou_mapper, metadata, username,
cou2ent):
        return sqlalchemy.orm.relation(
            cou_mapper,
            uselist=True,
            secondary= cou2ent
        )
---------------------------------------

But I get this error message:

  File "/home/kikr/buildout-eggs/SQLAlchemy-0.4.7p1-py2.4.egg/
sqlalchemy/orm/properties.py", line 542, in __determine_joins
    raise exceptions.ArgumentError("Could not determine join condition
between parent/child tables on relation %s.  "
ArgumentError: Could not determine join condition between parent/child
tables on relation SanctionEntity.citizens (Country).  Specify a
'primaryjoin' expression.  If this is a many-to-many relation,
'secondaryjoin' is needed as well.

---------------------------------------

debug informations:

(Pdb) self.parent.local_table
Table('ent_entity', MetaData(XXX)), Column(u'ent_origin_id',
PGBigInteger(), table=<ent_entity>, nullable=False), Column('lis_key',
Integer(),
ForeignKey('_portalUserGroup.asl_allowed_sanction_list_view.lis_id'),
table=<ent_entity>), Column(u'ent_id', PGBigInteger(),
table=<ent_entity>, primary_key=True, nullable=False),
Column(u'reg_key', PGBigInteger(),
ForeignKey(u'productiv.reg_regulation.reg_id'), table=<ent_entity>,
nullable=False), schema='productiv')


(Pdb) self.secondary
Table('cou2ent', MetaData(TLEngine(XXX)), Column(u'ent_key',
PGBigInteger(), ForeignKey(u'productiv.ent_entity.ent_id'),
table=<cou2ent>, nullable=False), Column(u'cou_key', PGChar(length=2,
convert_unicode=False, assert_unicode=None),
ForeignKey(u'cou_country.cou_iso2'), table=<cou2ent>, nullable=False),
Column(u'origin_id', PGBigInteger(), table=<cou2ent>, nullable=False),
Column(u'reg_key', PGBigInteger(),
ForeignKey(u'productiv.reg_regulation.reg_id'), table=<cou2ent>,
nullable=False), schema='productiv')


(Pdb) self.mapper.local_table
Table('cou_country', MetaData(TLEngine(XXX)), Column(u'cou_iso2',
PGChar(length=2, convert_unicode=False, assert_unicode=None),
table=<cou_country>, primary_key=True, nullable=False),
Column(u'cou_name', PGString(length=80, convert_unicode=False,
assert_unicode=None), table=<cou_country>, nullable=False),
Column(u'cou_printable_name', PGString(length=80,
convert_unicode=False, assert_unicode=None), table=<cou_country>,
nullable=False), Column(u'cou_iso3', PGChar(length=3,
convert_unicode=False, assert_unicode=None), table=<cou_country>),
Column(u'cou_numcode', PGSmallInteger(), table=<cou_country>),
Column(u'cou_cctld', PGChar(length=2, convert_unicode=False,
assert_unicode=None), table=<cou_country>), schema='public')

---------------------------------------

I don't see the bug in debug informations. Please help me.

Thanks,
Kai.

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