I have a database where multiple objects use the same sequence to
generate primary keys -
class ProjectInfo(Base, KVC):
__tablename__ = 'project_info'
object_id = Column("project_info_id", Integer,
Sequence('key_generator'),
primary_key=True)
project_id = Column("project_id",
ForeignKey('project.project_id'), )
...
class Project(Base, KVC):
""" An OpenGroupware Project object """
__tablename__ = 'project'
object_id = Column("project_id",
Sequence('key_generator'),
ForeignKey('project_info.project_id'),
...
Project.info = relation("ProjectInfo", uselist=False,
back_populates="project",
primaryjoin=(ProjectInfo.project_id==Project.object_id))
ProjectInfo.project = relation("Project", uselist=False, backref="info",
primaryjoin=(ProjectInfo.project_id==Project.object_id))
This works fine. But if I create a Project object I can't relate it to
a ProjectInfo object within the same transaction without calling flush()
first. Is there some way to encourage SQLalchemy to allocate a value
from the sequence when the object is created?
Basically a ProjectInfo should be created for every Project that is
created; this relationship is one-to-one.
--
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.