I have a special kind of relation.
Relation = Table("relations", metadata,
Column('src_id',Unicode(50)),
Column('dest_id',Unicode(50)),
Column('relation',Unicode(50))
)
class Node(DeclarativeBase):
__tablename__ = 'nodes'
name = Column(Unicode(50), nullable=False)
node_id = Column(Unicode(50), primary_key=True)
children=relation('Node',secondary=Relation,\
primaryjoin=and_
(node_id==Relation.c.src_id,Relation.c.relation==u'Children'),\
foreign_keys=[Relation.c.src_id,Relation.c.dest_id],\
secondaryjoin=and_(Relation.c.dest_id==node_id),\
backref=backref('parent'))
this relation can be anything...children,friend,sibling....
the query executed when i say node.children seems to be correct.
but my problem is when i add an object to this collection
only src_id and dest_id is populated.
i.e if i say node.children.append(xx) , i expect the relations table
to get
populated as
src_id=node.id ,
dest_id=xx.id
relation=u'Children'
but the relation column has value None.
how can i make SA to populate the relation column also?
PS:I checked Association Object, but couldn't figure out a way.
thnx for any help
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---