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

fixing None types in hashes #616

Merged
merged 3 commits into from
May 7, 2024
Merged

fixing None types in hashes #616

merged 3 commits into from
May 7, 2024

Conversation

slorello89
Copy link
Member

Was investigating #562 when I discovered to my dismay that HashModels now fail if they encounter a None. The genesis of this is thedict method in pydantic which produced '' as the default value if the value for a string field was None, changed in pydantic 2.x, now it simply returns None if no default is specified. Now this wouldn't be a problem except for the fact that redis-py cannot handle a None value in HSET (fair enough).

Altering the behavior to exclude None type from HSET command, while still allowing you to define a default value for the field.

redis-om-py 0.2.x behavior: None types in a hash default to ''

redis-om-py 0.3.0 behavior: None type fails in a hash

new behavior: None is just None

@slorello89 slorello89 linked an issue May 7, 2024 that may be closed by this pull request
@slorello89 slorello89 added the bug Something isn't working label May 7, 2024
Copy link

@bsbodden bsbodden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@slorello89 slorello89 merged commit a243582 into main May 7, 2024
3 checks passed
@slorello89 slorello89 deleted the bugfix/none-in-hash branch May 7, 2024 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handling optional fields and None values for HashModels
2 participants