Skip to content

Indexing boolean fields breaks something #510

Closed
@ilyatovbin-pp

Description

@ilyatovbin-pp
class Something(JsonModel):    
    name: str
    should_do_something: bool = Field(index=True, default=True)

Migrator().run()

Something(name="test").save()

result:

Something(pk='01H0HYP3C4YFF1MR6JV9MEZSF4', name='test', should_do_something=True)

executing a basic get by pk works fine.

Something.get('01H0HYP3C4YFF1MR6JV9MEZSF4') 

result:

Something(pk='01H0HYP3C4YFF1MR6JV9MEZSF4', name='test', should_do_something=True)

when running find().all(), the result is empty:

In [22]: Something.find().all()
Out [22]: []

If I set the bool value to Index=False, the indexing starts working fine:

In [24]: class Something(JsonModel):
    ...:     class Meta:
    ...:         database = get_redis_instance()
    ...: 
    ...:     name: str
    ...:     should_do_something: bool = Field(index=False, default=True)
    ...: 

In [25]: Migrator().run()

In [26]: Something.find().all()
Out[26]: 
[Something(pk='01H0HYP3C4YFF1MR6JV9MEZSF4', name='test', should_do_something=True),
 Something(pk='01H0HYGDBJF50GFRYK9MSPA8DQ', name='test 2', should_do_something=True),
 Something(pk='01H0HYB0MKSMV4QWJ7BM5G2DGH', name='test', should_do_something=True)]

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