-
Notifications
You must be signed in to change notification settings - Fork 30
get_query_set patching is very broken #29
Comments
By the way, I don't think there is a good way to fix this. But it would be better to remove the support for |
I am using django 1.7 with perfectly valid managers, and the monkey patch adds the warning " Disabling the monkey patch removes the warning, but doing the following also does !! : try:
Manager.get_query_set = Manager.get_queryset
Manager.get_queryset = Manager.get_queryset # yep !
except AttributeError:
Manager.get_queryset = Manager.get_query_set |
Can I point out that this issue is a major data loss bug? If you get This is shown by the failing tests in my branch: master...spookylukey:get_query_set_patch_bug In my example, Please fix this bug, by removing the |
Sure @spookylukey, we will remove the |
Great, thanks! I just didn't want this to get lost, since it is a potential data loss situation. |
The method included to patch get_query_set is very broken, and leads to some very bug code in circumstances where managers get subclassed - the behaviour of the subclass can be skipped. This is a very serious error for the case of Related managers, because it means that the limiting of the queryset that is added by the subclass get_query_set method gets skipped, so the related manager queries apply to all objects.
I've created a branch that demonstrates the problem, adding 4 tests, 2 of which fails with Django 1.8, one fails with Django 1.5:
https://github.com/spookylukey/django-compat/tree/get_query_set_patch_bug
I've created a PR so that you can see the tests failing.
The full details are explained in this blog post:
http://lukeplant.me.uk/blog/posts/handling-django's-get_query_set-rename-is-hard/
The text was updated successfully, but these errors were encountered: