Linked-list type OneToOne causes recursion error
doc-hex opened this issue · 1 comments
doc-hex commented
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.
josiahcarlson commented
If you use a ManyToOne and a OneToMany, with proper column reference on
your OneToMany to the other field, this should work.
I'll try to test in January when I'm at a computer.
…On Wed, May 11, 2022, 8:14 AM doc-hex ***@***.***> wrote:
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.
—
Reply to this email directly, view it on GitHub
<#156>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABTDQV7SQPH5IK3K6I53YTVJOXCFANCNFSM5VU4VE2Q>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>