Hi,

I'm still experimenting SA features and, once again, I'm stucked with a 
relation definition problem.

This is the deal.

Considering this tables definition :

USERS = Table('users', metadata,
    Column('id', Integer, primary_key=True),
    Column('name', String(255), nullable=False),
    )

BASES = Table('bases', metadata,
    Column('id', Integer, primary_key=True),
    Column('owner_id', Integer, ForeignKey('users.id'), primary_key=True),
    Column('creation_date', DateTime),
    Column('modification_date', DateTime),
    Column('type', String(255), nullable=False),
    Column('title', String(255)),
    )

FOLDERS = Table('folders', metadata,
    Column('id', Integer, ForeignKey('bases.id'), primary_key=True),
    Column('description', String()),
    )

This class definitions :

#
# Class definition
#
class User(object):
    pass

class Base(object):
    pass

class Folder(Base):
    pass

And this mappers :

base_join = polymorphic_union(
    {
     'folder':BASES.join(FOLDERS),
     'base':BASES.select(BASES.c.type=='base'),
    }, None, 'pjoin')

base_mapper = mapper(Base, BASES, select_table=base_join, 
polymorphic_on=base_join.c.type, polymorphic_identity='base',
    properties={'owner': relation(User, 
primaryjoin=BASES.c.owner_id==USERS.c.id, backref='objects')})
mapper(Folder, FOLDERS, inherits=base_mapper, 
polymorphic_identity='folder',)
mapper(User, USERS)

I guess my relation defined in the base_mapper has something wrong 
because I'm not able to add an owner to my Bases objects.

Any idea ??

Regards,

Laurent.


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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