Skip to content

find() does not work when object index contains either boolean or timedelta fields #580

Closed
@u3Izx9ql7vW4

Description

@u3Izx9ql7vW4

Hi,

Thanks for writing this library, it's made made my life a bit easier. I came across some unusual behavior while I was using this library, notably find() does not work on any field with my data model below. It wasn't until I removed the index on the four timedelta and bool fields did find() start to work again. The get() method worked throughout.

find() does not work with this data model:

from typing import Dict, Optional, List, Set
from redis_om import JsonModel, Field

class Example(JsonModel):
    id           : str       = Field(primary_key=True, index=True)
    members      : List[str] = Field(index=True, default=[])
    friends      : List[str] = Field(index=True, default=[])
    dependencies : List[str] = Field(index=True)
    textfieldA   : str       = Field(index=True)
    date_start   : date      = Field(index=True)
    date_end     : Optional[date]
    textfieldB   : str       = Field(index=True)
    timefieldA   : timedelta = Field(index=True)
    timefieldB   : timedelta = Field(index=True)
    boolfieldA   : bool      = Field(index=True)
    boolfieldB   : bool      = Field(index=True)
    last_updated : date      = Field(index=True, default=date(1990, 1,1))

find() does work after removing index on timedelta and bool fields. Removing either type doesn't not fix the issue, indices on both types need to be removed in order to find() to work again:

class Example(JsonModel):
    id           : str       = Field(primary_key=True, index=True)
    members      : List[str] = Field(index=True, default=[])
    friends      : List[str] = Field(index=True, default=[])
    dependencies : List[str] = Field(index=True)
    textfieldA   : str       = Field(index=True)
    date_start   : date      = Field(index=True)
    date_end     : Optional[date]
    textfieldB   : str       = Field(index=True)
    timefieldA   : timedelta
    timefieldB   : timedelta
    boolfieldA   : bool
    boolfieldB   : bool
    last_updated : date      = Field(index=True, default=date(1990, 1,1))

Version Information:
Python: 3.11.5
redis-om-python: 0.2.1
OS: macOS Sonoma 14.0 (Apple Silicon)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions