theres a "bug" in that the error message is misleading, but in fact a  
composite property owns the columns within it which cannot be mapped  
separately, so to make that "work" you'd need  to say:

class User(Base):

     __tablename__ = 'user'

     house_address_id = Column('house_address', Integer,  
ForeignKey('address.id'))
     office_address_id = Column('office_address', Integer,  
ForeignKey('address.id'))
     house_address = relation(Address,  
primaryjoin=house_address_id==Address.id)
     office_address = relation(Address,  
primaryjoin=office_address_id==Address.id)
     comp = composite(Comp, Column('id', Integer, primary_key=True,  
autoincrement=True), Column('name', CHAR))

but the way you're using Comp isn't going to work in any case;  you're  
actually looking for comparable_property() here:

class MyComparator(sqlalchemy.orm.interfaces.PropComparator):
     def __eq__(self, other):
         return self.comp == other.comp

class User(Base):

     __tablename__ = 'user'

     id = Column('id', Integer, primary_key=True, autoincrement=True)
     name = Column('name', CHAR)
     house_address_id = Column('house_address', Integer,  
ForeignKey('address.id'))
     office_address_id = Column('office_address', Integer,  
ForeignKey('address.id'))
     house_address = relation(Address,  
primaryjoin=house_address_id==Address.id)
     office_address = relation(Address,  
primaryjoin=office_address_id==Address.id)

     @property
     def comp(self):
         return self.id + self.name

     comp = comparable_property(MyComparator)


On Oct 27, 2008, at 9:22 AM, riteshn wrote:

>
> Hello all
>
> New to SQLAlchemy and ORM and loving it. I am trying to use the
> declarative base extension with composite column.
>
> I have two very simple tables - user and address.
>
> My code at: http://python.pastebin.com/m6e032164 works without any
> problem.
>
> I am trying to put the same thing using declarative base:
> http://python.pastebin.com/m1a05e5c0 and it throws me the error.
>
> Any ideas?
>
> >


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