what happens if you just ignore the warning?  i think it might work anyway:

from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class A(Base):
    __tablename__ = 'a'

    id = Column(Integer, primary_key=True)

    d = relationship("D")

class B(A):
    __tablename__ = 'b'

    id = Column(ForeignKey('a.id'), primary_key=True)

    d = relationship("D", collection_class=set)

class C(A):
    __tablename__ = 'C'

    id = Column(ForeignKey('a.id'), primary_key=True)

    d = relationship("D", collection_class=set)

class D(Base):
    __tablename__ = 'd'

    id = Column(Integer, primary_key=True)
    aid = Column(ForeignKey('a.id'))

e = create_engine("sqlite://", echo=True)
Base.metadata.create_all(e)

sess = Session(e)

b1 = B()
a1 = A()
a1.d.append(D())
b1.d.add(D())
sess.add_all([a1, b1])
sess.commit()

print a1.d
print b1.d



On Apr 10, 2014, at 8:41 AM, Konsta Vesterinen <[email protected]> 
wrote:

> Hi,
> 
> I have a situation where I have three classes A, B and C with B and C 
> inheriting class A. 
> 
> Now each of these classes also has a version class, lets call them AVersion, 
> BVersion and CVersion. The inheritance tree is the same: BVersion and 
> CVersion inherit AVersion. What I want to achieve is A having relationship to 
> AVersion, B having a relationship to BVersion and C having a relationship to 
> CVersion. I ran into problems when trying to name these relationships with 
> same name 'versions'.
> 
> The problem is this causes a naming collision:
> 
> SAWarning: Property A.versions on Mapper|B|b being replaced with new property 
> B.versions; the old property will be discarded
> 
> How can I achieve this with keeping the relationship names on all classes as 
> 'versions'? The relationship on all classes can be viewonly, hence this 
> shouldn't have any effect on session dependency processing. 
> 
> -- 
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to