Skip to content

Bool Field in Model combined with List[str] Field seems to break Model.find().all() after List update #299

Closed
@mpmX

Description

@mpmX

To reproduce:

class Base:
    class Meta:
        database = redis

class Entity(Base, JsonModel):
    name: str = Field(index=True)
    some_list: List[str] = Field(index=True, default=[])
    random_bool_field: bool = Field(index=True, default=0)

Migrator().run()

for i in range(100):
    entity = Entity(name=f"Entity{i}")
    entity.save()

entities = Entity.find().all()
assert len(entities) == 100 # <- OK

for i in range(100):
    entity = Entity.find(Entity.name == f"Entity{i}").first()
    entity.some_list.append("test")
    entity.save()

entities = Entity.find().all()
assert len(entities) == 100 # <- AssertionError!

The code works when the bool field is defined without the Field syntax, like random_bool_field: bool = 0 but then I cannot index it.
It also works when I update an integer field instead of the list append.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions