﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20300	Django 1.5.1, update sql trouble	hjcnbckfd@…	nobody	"Django 1.5.1

{{{
Comment.objects.filter(post_id__in=[1,2,3]).exclude(post_id__in=[4,5]) \
                .update(is_published=True)
}}}

Такой queryset дает для PostgeSQL запрос вида:

{{{
UPDATE ""message_comment"" SET ""is_published"" = true WHERE ""message_comment"".""post_id"" IN (1, 2, 3)
}}}

Для MySQL же выдается:

{{{
UPDATE `message_comment` SET `is_published` = 1 WHERE `message_comment`.`post_id` IN (SELECT U0.`post_id` FROM `message_comment` U0 WHERE U0.`post_id` IN (1, 2, 3)); args=(True, 1, 2, 3)
}}}

Конечно же MySQL  выдает ошибку ''''DatabaseError: (1093, ""You can't specify target table 'message_comment' for update in FROM clause"")''''"	Bug	closed	Database layer (models, ORM)	1.5	Normal	worksforme	update, orm, mysql, postgresql		Unreviewed	0	0	0	0	0	0
