Hi,
I've two classes CourseSet and CanonicalCourse (with the same parent)
which need to be connected in a many-to-many relationship. But these
classes are mapped on the same table, thus definition of the
association table seems redondant:
assoc_course_set_canonical_table = Table(
'CM_COURSE_SET_CANON_ASSOC_T', Base.metadata,
Column('CANON_COURSE', Integer,
ForeignKey('CM_MEMBER_CONTAINER_T.MEMBER_CONTAINER_ID')),
Column('COURSE_SET', Integer,
ForeignKey('CM_MEMBER_CONTAINER_T.MEMBER_CONTAINER_ID'))
)
But i can't define the relationship between. I've the error:
Could not determine join condition between parent/child tables on
relationship CourseSet.canonicalCourses. Specify a 'primaryjoin'
expression. If 'secondary' is present, 'secondaryjoin' is needed as
well.
I must have miss something: i've tried several possibilities with
primaryjoin and secondaryjoin but nothing work. Is it because i'm
refering at the same foreign key in the associative table ?
Thank you.
Julien.
PS: The code for my two classes ('#' comments the two lines with the problem)
class CourseSet(AbstractContainer):
parent_id = Column('PARENT_COURSE_SET', Integer,
ForeignKey('CM_MEMBER_CONTAINER_T.ENTERPRISE_ID'))
children = relationship("CourseSet", backref=backref('parent',
remote_side=AbstractContainer.eid))
# canonicalCourses = relationship("CanonicalCourse",
# secondary="assoc_course_set_canonical_table")
@classproperty
def __mapper_args__(self):
args = dict()
args.update(AbstractContainer.__mapper_args__)
args.update({'polymorphic_identity':
'org.sakaiproject.coursemanagement.impl.CourseSetCmImpl'})
return args
class CanonicalCourse(AbstractContainer):
@classproperty
def __mapper_args__(self):
args = dict()
args.update(AbstractContainer.__mapper_args__)
args.update({'polymorphic_identity':
'org.sakaiproject.coursemanagement.impl.CanonicalCourseCmImpl'})
return args
PS: the parents of these classes:
class AbstractPersistent(object):
version = Column('VERSION', Integer)
last_modified_by = Column('LAST_MODIFIED_BY', String(255))
last_modified_date = Column('LAST_MODIFIED_DATE', Date)
created_by = Column('CREATED_BY', String(255))
created_date = Column('CREATED_DATE', Date)
class AbstractNamed(AbstractPersistent):
eid = Column('ENTERPRISE_ID', String(255))
title = Column('TITLE', String(255))
description = Column('DESCRIPTION', String(255))
class AbstractContainer(Base,AbstractNamed):
__tablename__ = 'CM_MEMBER_CONTAINER_T'
id = Column('MEMBER_CONTAINER_ID',Integer,primary_key=True)
discriminator = Column('CLASS_DISCR', String(100))
__mapper_args__ = {'polymorphic_on': discriminator }
--
"Trouble-a-cat limited"
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.