Hi,

Could someone please explain what the following error means?  I assume I am 
expecting too much magic from SQLAlchemy, but I can't see why it doesn't 
"just work".

I am trying to define a directed graph of related (music) artists.  So I 
have an Artist class (nodes) and a Link class (directed arcs).

The full code is available 
at 
https://github.com/andrewcooke/uykfg/blob/master/src/uykfg/music/db/network.py 
and 
https://github.com/andrewcooke/uykfg/blob/master/src/uykfg/music/db/catalogue.py
 
but I think the essential information is below:

    class Link(TableBase):
        __tablename__ = 'music_links'
        src_id = Column(Integer, ForeignKey(Artist.id), primary_key=True, 
nullable=False)
        src = relationship(Artist, backref='srcs', 
primaryjoin=src_id==Artist.id)
        dst_id = Column(Integer, ForeignKey(Artist.id), primary_key=True, 
nullable=False)
        dst = relationship(Artist, backref='dsts', 
primaryjoin=dst_id==Artist.id)

and then I ran this test:

        alice = Artist(name='alice')
        session.add(alice)
        bob = Artist(name='bob')
        session.add(bob)
        bob.srcs.append(alice)
        assert len(alice.dsts) == 1, alice.dsts

where the "append" gives the error:

  File 
"/home/andrew/project/uykfg/git/env/lib/python3.2/site-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/orm/attributes.py",
 
line 1066, in emit_backref_from_collection_append_event
    child_impl = child_state.manager[key].impl
KeyError: "'src'

Please - why?

Thanks for reading,
Andrew

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to