redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.12k stars 112 forks source link

Find by optional field returns documents with None #247

Closed DennyD17 closed 5 months ago

DennyD17 commented 2 years ago

Hi! I have model with Optional[int] indexed field and I want to query via that field. In results I see documents with None in that field. Why? How to avoid it?

class Page(JsonModel):
    id: int = Field(index=True)
    base_id: Optional[int] = Field(index=True)

Migrator().run()
pages = Page.find(Page.base_id == 1).all()

In results I see docs with base_id = None

sav-norem commented 2 years ago

Thanks for bringing this up! Seems like right now the easiest way to get around this is to add a default value that would never exist in your data. I'll take a look through the source code and see what's going on!

DennyD17 commented 5 months ago

Has it already been fixed? Can't reproduce it

redis-om = "^0.1.2"

slorello89 commented 5 months ago

@DennyD17 - I agree, can't reproduce on my end, will close, if this recurs feel free to reopen.