﻿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
8278	QueryDict.update eats data when other_dict is a MultiValueDict	Jeremy Dunck	nobody	"django.http.QueryDict supports .update, but it seems to assume that other_dict is a (builtin) dict.

This is dangerous when mixing two QueryDicts.  

{{{
>>> x = QueryDict('a=1&a=2')
>>> y = QueryDict('a=3&a=4')
>>> print x
<QueryDict: {u'a': [u'1', u'2']}>
>>> print y
<QueryDict: {u'a': [u'3', u'4']}>
>>> x._mutable = True
>>> x.update(y)
>>> x._mutable=False
>>> print x
<QueryDict: {u'a': [u'1', u'2', u'4']}>
}}}

Note that a=3 was lost.

As far as I can see, there's no really nice fix to this.  QueryDict.update doesn't just defer to MultiValueDict because it needs to force keys and values into unicode.

Defering to MultiValueDict first and then forcing means duplicate keys for items not yet coerced.
Forcing individual items results in lists from QueryDict becoming (single) items in MultiValueDict.

i.e.
{{{
dict([(f(k), f(v)) for k, v in other_dict.items()])
->
dict([(f(k), [f(v) for v in values]) for k, values in other_dict.lists()])
}}}

This seems to be a leaky abstraction here; I think QueryDict is not really a MultiValueDict, since MultiValueDict can have any (hashable) objects as keys and values, while QueryDict insists on unicode objects only.

No patch from me since the solution isn't obvious to me.  Marking as 1.0 since this is a bug, though."		closed	Core (Other)	dev		fixed			Accepted	1	0	0	1	0	0
