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

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

Closed
u3Izx9ql7vW4 opened this issue Dec 7, 2023 · 0 comments · Fixed by #611
Closed
Labels
enhancement New feature or request

Comments

@u3Izx9ql7vW4
Copy link

u3Izx9ql7vW4 commented Dec 7, 2023

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)

@slorello89 slorello89 added the enhancement New feature or request label Apr 5, 2024
@slorello89 slorello89 linked a pull request May 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants