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
ModelResource.obj_update calls full_hydrate twice #390
Comments
This can be fixed with a simple flag tracking whether the full_dehydrate was already called. I have a tentative patch here. Working on tests. Feel free to comment. tarequeh@6f95afb |
I've got the exact same problem. My hydrate process is being called twice. Since I'm converting some fields into an internal representation (and vice versa on the way out), it bombs out on the second call. |
Looking into this, it's a bit more complicated that tracking if If you simply run |
Having the same issue here when trying to b64decode an ImageField. |
Incidentally I worked around this like so:
'password_hashed'): On Sat, Aug 18, 2012 at 2:22 AM, jarcoal notifications@github.com wrote:
|
I did the same as @tolomea. I mark the bundle as processed (in my code) so that repeated calls to hydrate() know what's been done. hydrate() gets called from several different paths and if you're overriding methods (obj_create, for eg) and then calling super within your implementation, it's more than likely both you and the super will be performing a hydrate(). So marking the bundle is the easiest way to work around this. Once you do this, it becomes a non-issue. |
I ended up doing the same thing. However, the documentation should probably reflect the fact, that hydrate_% methods can be called multiple times... |
There is no need to call `full_hydrate` when we only want to convert identifiers into Python objects. This avoids side effects on `obj_update` and adds the possibility to flag `full_hydrate` as called, for avoiding performance hits. This needs tests proposed in django-tastypie#658 and helps closing django-tastypie#390
There is no need to call `full_hydrate` when we only want to convert identifiers into Python objects. This avoids side effects on `obj_update` and adds the possibility to flag `full_hydrate` as called, for avoiding performance hits. This needs tests proposed in django-tastypie#658 and helps closing django-tastypie#390
This should be either fixed or at least better as of SHA: 213d686. |
There is no need to call `full_hydrate` when we only want to convert identifiers into Python objects. This avoids side effects on `obj_update` and adds the possibility to flag `full_hydrate` as called, for avoiding performance hits. This needs tests proposed in django-tastypie#658 and helps closing django-tastypie#390
I am facing the same issue. And in the first call bundle.obj.pk is empty even though the request was an update on an existing resource. My hydrate method tries to use pk as an indicator if this is a create or update and want to do different hydrate in each case. But because of this bug, I'm screwed. |
I have same issue as sunshineo. Whenever i send PUT request, the hydrate process gets called twice, first time resulting in empty object, and only the second call have proper object loaded |
Could anyone reopen this issue? Seems like it isn't fixed and is referenced only from bunch of closed issues. |
same issue here. I work around it by first testing if bundle is None at the beginning of hydrate method, but this should be fixed. |
Please reopen, this issue is still here (v0.10.0) |
There is no need to call `full_hydrate` when we only want to convert identifiers into Python objects. This avoids side effects on `obj_update` and adds the possibility to flag `full_hydrate` as called, for avoiding performance hits. This needs tests proposed in django-tastypie#658 and helps closing django-tastypie#390
experiencing this problem in v0.11.0 |
We are also experiencing this on v0.11.0 with nested resources which are getting created twice if there is a child object created in a patch request. Has anyone figured out a workaround for this yet? |
Hello! I'm using 0.12.2 and I'm also experiencing this. |
Starting in this commit obj_update calls full_hydrate twice. This means that if non-idempotent transformations happen in a user's hydrate() functions it will result in an attribute that isn't in the expected state.
The text was updated successfully, but these errors were encountered: