pony icon indicating copy to clipboard operation
pony copied to clipboard

AttributeError: 'NoneType' object has no attribute 'entity' when removing entities completely

Open Zahlii opened this issue 4 years ago • 1 comments

I was basically just attempting to remove an entity completely, as part of a one-to-many relation:

class Parent(db.Entity):
    children = Set(lambda: Children)

class Children(db.Entity):
   belongs_to_parent = Required(lambda: Parent)

-> Removed Children

class Parent(db.Entity):
    pass

class Children(db.Entity):
   pass

File "/Users/**/.pyenv/versions/tooka.ai/lib/python3.7/site-packages/pony/migrate/writer.py", line 251, in _get_ops if attr.entity is not entity: assert False, 'Not implemented' AttributeError: 'NoneType' object has no attribute 'entity'

Zahlii avatar Nov 25 '20 11:11 Zahlii

Temporary Solution: Manually adding the op inside the migration file. Temporary Solution 2: Keep the "children" attribute inside the Parent class, but replace it e.g. with Optional(int), then remove it from the migration file.

Zahlii avatar Nov 25 '20 11:11 Zahlii