- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 95
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Property fields are not inherited by submodels:
class BaseFoo(ormar.Model):
class Meta:
abstract = True
name: str = ormar.String(max_length=100)
@ormar.property_field
def prefixed_name(self) -> str:
return "prefix_" + self.name
class Foo(BaseFoo):
class Meta:
metadata = metadata
database = database
id: int = ormar.Integer(primary_key=True)
foo = Foo(name="foo")
Expected behavior
>>> foo.prefixed_name
'prefix_foo'
foo.json()
'{"name": "foo", "id": null, "prefixed_name": "prefix_foo"}'
Actual behavior
>>> foo.prefixed_name
<bound method BaseFoo.prefixed_name of Foo({'name': 'foo', 'id': None})>
>>> foo.json()
'{"name": "foo", "id": null}' # "prefixed_name" is missing
Versions
- Database backend used: postgresql
- Python version: 3.8.10
ormar
version: 0.11.2pydantic
version: 1.8.2
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Projects
Milestone
Relationships
Development
Select code repository
Activity
Fix property_fields not being inherited. Fix for #774.
Fix property_fields not being inherited. Fix for #774. (#891)
collerek commentedon Oct 21, 2022
Fixed in 0.12.0, please update and check.