﻿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
19531	Surprising impact of defer()	Vlada Macek	nobody	"I have Counter model with a few fields. When I call:
{{{
>>> cnt=Counter.objects.only('logs').get(id=2349497)
}}}

it results in SQL (Postgres):
{{{
SELECT ""visits_counter"".""id"", ""visits_counter"".""logs"" FROM ""visits_counter"" WHERE ""visits_counter"".""id"" = 2349497
}}}

That's fine. When I want to directly update the logs field in the database like this:
{{{
cnt._default_manager.filter(pk=cnt.pk).update(logs=4)
}}}

it results in SQL (Postgres):
{{{
SELECT U0.""id"" FROM ""visits_counter"" U0 WHERE U0.""id"" = 2349497
UPDATE ""visits_counter"" SET ""logs"" = 4 WHERE ""visits_counter"".""id"" IN (2349497)
}}}

which looks strange to me (1. the unnecessary first query, 2. IN in the second). I finally get expected behavior by doing
{{{
cnt._meta.concrete_model._default_manager.filter(pk=cnt.pk).update(logs=4)
}}}

SQL:
{{{
UPDATE ""visits_counter"" SET ""logs"" = 4 WHERE ""visits_counter"".""id"" = 2349497
}}}

Is it a bug or feature? Am I getting something really wrong?
"	Cleanup/optimization	closed	Database layer (models, ORM)	1.4	Normal	fixed	defer only		Accepted	0	0	0	0	0	0
