redis-om-python
redis-om-python copied to clipboard
[WIP] Support null values for optional fields
Related to #261 & #254
The query is working, the only issue is that the await model.save()
call returns the values stored in Redis, i also need to apply this workaround to this method that i am currently trying to find out how.
The string zero "0" is the null value rather than the empty string cause it is a valid int and float, not sure if someone want to store "0" in the database as a string value, highly unlikely.
Test case example:
actual = await (m.Member.find(m.Member.bio % "great").all()) # Notice the None values.
[Member(pk='01GA23KQ9SSGK1TNVZD202C9RM', id=0, first_name='Andrew', last_name='Brookins', email='[email protected]', join_date=datetime.date(2022, 8, 9), height=None, weight=None, age=38, bio='This is member 1 whose greatness makes him the life and soul of any party he goes to.')]
member1 = m.Member(
id=0,
first_name="Andrew, the Michael",
last_name="St. Brookins-on-Pier",
email="a|[email protected]", # NOTE: This string uses the TAG field separator.
age=38,
join_date=today,
bio="This is a test user on our system.",
)
await member1.save()
# returns zeros rather than Nones
[Member(pk='01GA23KQ9SSGK1TNVZD202C9RM', id=0, first_name='Andrew', last_name='Brookins', email='[email protected]', join_date=datetime.date(2022, 8, 9), height=0, weight=0.0, age=38, bio='This is member 1 whose greatness makes him the life and soul of any party he goes to.')]
I think the only solution is to override self
or construct a new object with these values(None in place of "0").
@wiseaidev It doesn't seem to have solved the problem, the tests are failing.
Hey @dvora-h, sorry, i was AFK. Working on it, not finished yet! Marking it as a work in progress!
Wanted to add a comment - seems like you're aware based on the tests only being for the HashModel, but to call it out, issues #254 and #261 work if you swap the HashModel for a JsonModel - not a fix, but something to note and call out.