pony
pony copied to clipboard
TypeError in `issubclass` call in Index._init_ if component of composite key or index is redefined
Malformed schema:
# test.py
class A(db.Entity):
foo = Required(int)
bar = Required(int)
PrimaryKey(foo, bar) # Also true for composite_key and composite_index
bar = Required(int)
Error:
Traceback (most recent call last):
File "test.py", line 16, in <module>
class A(db.Entity):
File "<string>", line 2, in __init__
File "pony/utils/utils.py", line 78, in cut_traceback
reraise(exc_type, exc, full_tb)
File "pony/utils/utils.py", line 95, in reraise
try: raise exc.with_traceback(tb)
File "pony/utils/utils.py", line 61, in cut_traceback
try: return func(*args, **kwargs)
File "pony/orm/core.py", line 3792, in __init__
for index in indexes: index._init_(entity)
File "pony/orm/core.py", line 2644, in _init_
if not issubclass(entity, attr.entity): throw(ERDiagramError,
TypeError: issubclass() arg 2 must be a class or tuple of classes
Adding a print
before that line:
core.py L2644:
entity: <class 'test.A'>
type(attr): <class `pony.orm.core.Required`>
attr: ?.?
attr.entity: None