We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When defining a OneToOne relationship, we cache the result into the other_inst variable here.
other_inst
However, other_inst remains the same for the entire Model, not the individual object of the Model.
Example:
from dynamorm import DynaModel, OneToOne from marshmallow.fields import String class Device(DynaModel): class Table: name = 'Device' hash_key = 'device_id' class Schema: device_id = String(required=True) device_name = String() device_location = String() class User(DynaModel): class Table: name = 'User' hash_key = 'user_id' class Schema: user_id = String(required=True) device_id = String(required=True) device = OneToOne( Device, query=lambda user: dict(device_id=user.device_id), ) Device(device_id='Device_1').save() Device(device_id='Device_2').save() User(user_id='Alice', device_id='Device_1').save() User(user_id='Bob', device_id='Device_2').save() alice = User.get(user_id='Alice') assert alice.device.device_id == 'Device_1' bob = User.get(user_id='Bob') assert bob.device.device_id == 'Device_2'
The text was updated successfully, but these errors were encountered:
This is another solution
https://gist.github.com/frdteknikelektro/771f191013ad3e34c3521b8bec11e0fb
This code solve the issue, the problem is on python Descriptor itself. Descriptor is attach to Class not Instance.
Or any other solution is in Descriptor class do not use any cache like other_inst
Sorry, something went wrong.
No branches or pull requests
When defining a OneToOne relationship, we cache the result into the
other_inst
variable here.However,
other_inst
remains the same for the entire Model, not the individual object of the Model.Example:
The text was updated successfully, but these errors were encountered: