Re: [Sqlalchemy-tickets] [sqlalchemy] #2794: CircularDependencyError with jython because WeakSequen
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-08-02 15:58:13
|
#2794: CircularDependencyError with jython because WeakSequence doesn't preserve
order
----------------------------------+------------------------------------
Reporter: sayap | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: utils | Severity: no triage selected yet
Resolution: | Keywords:
Progress State: awaiting triage |
----------------------------------+------------------------------------
Comment (by sayap):
Here's some sample code that causes `CircularDependencyError` with Jython
2.7b1+ (current hg tip 7eb5574d023d):
{{{
from sqlalchemy.engine import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.schema import Column, ForeignKey
from sqlalchemy.types import Integer, String
url = 'postgresql+zxjdbc://postgres@localhost/test'
engine = create_engine(url)
Session = scoped_session(sessionmaker())
Session.configure(bind=engine)
Base = declarative_base()
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
discriminator = Column(String(10))
__mapper_args__ = {
'polymorphic_on': discriminator,
'polymorphic_identity': 'a',
}
class B(A):
__tablename__ = 'b'
__mapper_args__ = {
'polymorphic_identity': 'b',
}
id = Column(Integer, ForeignKey(A.id), primary_key=True)
class C(B):
__tablename__ = 'c'
__mapper_args__ = {
'polymorphic_identity': 'c',
}
id = Column(Integer, ForeignKey(B.id), primary_key=True)
Base.metadata.create_all(engine)
c = C()
Session.add(c)
Session.flush()
}}}
In this case, the random ordering would cause
`Mapper.self_and_descendants()` to return C first instead of A,
subsequently causing `table_to_mapper` to have table A -> mapper C, which
then causes the circular dependency.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2794#comment:2>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|