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

Mutating array relationships directly does not work #40

Closed
boydgreenfield opened this issue Jan 17, 2017 · 1 comment
Closed

Mutating array relationships directly does not work #40

boydgreenfield opened this issue Jan 17, 2017 · 1 comment

Comments

@boydgreenfield
Copy link
Contributor

Currently, sample.tags.append(new_tag) counterintuitively fails, and does not include new_tag. This is because we're creating the tags attribute on the fly and wrapping the underlying potion-client resource, i.e., creating a new list with each __getattr__ call.

The TODO here is to update how we handle arrays in the API so that the above operations (as well as pop, etc.) work properly.

In the meantime, users should use the following workaround:

tag_list = sample.tags
tag_list.append(new_tag)
sample.tags = tag_list
tag_list.save()
@polyatail
Copy link
Contributor

I think there's a not-too-difficult path to fixing this, by creating a new ResourceList object that emulates a list. Well, it mostly just is a list, but it passes actions down the line to the underlying _resource object that, in the example given by @boydgreenfield, doesn't get updated.

polyatail added a commit that referenced this issue Nov 16, 2018
* Explicitly disallow unsupported comparisons between API models
* Added tests for ResourceLists, and comparison between models
polyatail added a commit that referenced this issue Nov 16, 2018
* Explicitly disallow unsupported comparisons between API models
* Added tests for ResourceLists, and comparison between models
polyatail added a commit that referenced this issue Nov 16, 2018
* Explicitly disallow unsupported comparisons between API models
* Added tests for ResourceLists, and comparison between models
polyatail added a commit that referenced this issue Nov 16, 2018
* Explicitly disallow unsupported comparisons between API models
* Added tests for ResourceLists, and comparison between models
polyatail added a commit that referenced this issue Nov 17, 2018
* Explicitly disallow unsupported comparisons between API models
* Added tests for ResourceLists, and comparison between models
boydgreenfield pushed a commit that referenced this issue Nov 17, 2018
* Add ResourceList to fix API list access (#40)
* Explicitly disallow unsupported comparisons between API models
* Added tests for ResourceLists, and comparison between models

* Style tweak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants