Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Describe the bug If the value of an optional property is None, storing a Model fails
None
Model
To Reproduce Running the following code:
import uuid from typing import Optional from pydantic import Field from pydantic_redis import Store, RedisConfig, Model class Child(Model): _primary_key_field = "id" id: str = Field( default_factory=lambda: uuid.uuid4().hex, ) name: str = Field() class Parent(Model): _primary_key_field = "id" id: str = Field( default_factory=lambda: uuid.uuid4().hex, ) name: str = Field() child: Optional[Child] = Field(default=None) store = Store( name="does_none_work", redis_config=RedisConfig(host='localhost', port=6379, db=6) ) store.register_model(Child) store.register_model(Parent) parent = Parent(name="bong bing") Parent.insert(parent) parents_retrieved = Parent.select(ids=[parent.id]) print(parents_retrieved)
Fails with the following exception:
AttributeError: type object 'NoneType' has no attribute 'get_primary_key_field'
Expected behavior One would expect the Parent object to be just stored into Redis with the Optional property left to None.
Optional
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
If the value of an optional property is
None
, storing aModel
failsTo Reproduce
Running the following code:
Fails with the following exception:
Expected behavior
One would expect the Parent object to be just stored into Redis with the
Optional
property left toNone
.The text was updated successfully, but these errors were encountered: