josiahcarlson/rom

Linked-list type OneToOne causes recursion error

doc-hex opened this issue · 1 comments

class Card(rom.Model):
    # ...
    # in a chain of related objects
    next_card = rom.OneToOne('Card', on_delete='restrict')
    prev_card = rom.OneToOne('Card', on_delete='restrict')
  • once an instance is created with non-zero next/prev links, cannot load the instance anymore
  • hits RecursionError: maximum recursion depth exceeded while calling a Python object
  • path is:
    out[i] = cls(_loading=True, **data)
  File "site-packages/rom/model.py", line 259, in __init__
    setattr(self, attr, data)
  File "site-packages/rom/columns.py", line 339, in __set__
    self._init_(obj, *value)
  File "site-packages/rom/columns.py", line 329, in _init_
    value = self._from_redis(value)
  File "site-packages/rom/columns.py", line 798, in _from_redis
    return model.get(value)
  File "site-packages/rom/model.py", line 568, in get
    out[i] = cls(_loading=True, **data)

I am working-around using integer column instead, but wanted to report.