Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mpmX opened this issue Jul 7, 2022 · 2 comments

Comments

@mpmX
Copy link

mpmX commented Jul 7, 2022

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.

@sav-norem
Copy link

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

@slorello89
Copy link
Member

Should be resolved by #611

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants