I've done many many-to-one relationships with SQLAlchemy, but there
must be something obvious I'm doing wrong here:

class Directory(Base):
    __tablename__ = "directories"

    id = Column(Integer, primary_key=True)
    name = Column(String, unique=True)
    subdirs = relation('Directory', backref="parentdir")
    parent_id = Column(Integer, ForeignKey('directories.id'))

    def __str__(self):
        return "Dir: %s" % (self.name)


"Base" is standard declarative Base.

The odd behavior that I'm seeing is that on a newly created Directory
instance, both subdirs and parentdir are lists when I would expect
parentdir to just be null or a Directory.

This is using SQLAlchemy 0.5.2.

I do hope there's something obvious that I missed...

Thanks,
Kevin

-- 
Kevin Dangoor

email: [email protected]
blog: http://www.BlueSkyOnMars.com

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

Reply via email to