redis-om-python icon indicating copy to clipboard operation
redis-om-python copied to clipboard

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

Open mpmX opened this issue 2 years ago • 1 comments

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.

mpmX avatar Jul 07 '22 08:07 mpmX

Checking this out! What a good/weird bug find!

sav-norem avatar Aug 30 '22 16:08 sav-norem

Should be resolved by #611

slorello89 avatar May 08 '24 14:05 slorello89