#10790: Too many joins in a comparison for NULL. --------------------------------------+------------------------------------- Reporter: mtredinnick | Owner: mtredinnick Status: new | Milestone: Component: ORM aggregation | Version: SVN Resolution: | Keywords: Stage: Accepted | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | --------------------------------------+------------------------------------- Changes (by wallenfe):
* cc: walle...@gmail.com (added) Comment: This becomes a more severe problem when it is combined with an update. Due to the JOIN in the query, the update becomes two SQL statements rather than one. This opens the door to potential race conditions if the web server processes that are executing these statements end up interleaving them. To continue your example: {{{ s=Student.objects.get(pk=1) Message.objects.filter(student=None).update(student=s) }}} We get this: {{{ SELECT `outer_message`.`id`, `outer_message`.`title`, `outer_message`.`student_id` FROM `outer_message` LEFT OUTER JOIN `outer_student` ON (`outer_message`.`student_id` = `outer_student`.`id`) WHERE `outer_student`.`id` IS NULL UPDATE `outer_message` SET `student_id` = 1 WHERE `outer_message`.`id` IN (1)' }}} when ideally we should get: {{{ UPDATE `outer_message` SET `student_id` = 1 WHERE `outer_message`.`student_id` IS_NULL' }}} -- Ticket URL: <http://code.djangoproject.com/ticket/10790#comment:2> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---