Due to the use of the dataclasses mixin on the SQLAlchemy types, a back_populates creates a RecursiveError when comparing two types. This occurs because the dataclass will overwrite the __eq__ operator, and it doesn't know when to stop comparing relationships. Removing the dataclasses isn't the best approach, since then __init__, __eq__ and __repr__ methods would have to be added to all types. Thus the solution was to remove the relationship on the child (on a one-to-one relationship) from the __eq__ operation, with the use of the compare parameter. Took the opportunity to define more logical __init__ methods on the `Rule` and child classes. Also revised the parameter options on some DB types.
13 lines
327 B
Python
13 lines
327 B
Python
from decimal import Decimal
|
|
|
|
from pfbudget.db.model import Category, CategoryRule, Tag, TagRule
|
|
|
|
category_null = Category("null")
|
|
|
|
category1 = Category(
|
|
"cat#1",
|
|
rules={CategoryRule("cat#1", description="desc#1", max=Decimal(0))},
|
|
)
|
|
|
|
tag_1 = Tag("tag#1", rules={TagRule("tag#1", description="desc#1", max=Decimal(0))})
|