← Back to team overview

maas-devel team mailing list archive

Re: ProgrammingError: can't adapt type 'dict'

 

Hi John,

On 06/05/14 14:41, John Meinel wrote:
> From looking at the bottom of the stack, you are passing the dict
> {'power_address': '10.0.0.108', ...} in for the SQL snippet:
>  "power_parameters" = %s

Hmmm, I thought it was a string getting passed but now you mention it
there's no "u" prefix.  I'm guessing it's a dict repr rather than a string.

The MAAS code here hasn't changed in a while, but we did get a new
Django release in trusty.  I wonder if it has a bug.  Although having
said that, this only seems to fail in the shell rather than any real
code running in the appserver threads.  I suspect some initialiser needs
calling.

> I'm guessing you need to actually have the dict serialized into some
> form that is acceptable as SQL. I'm not sure what the type of
> "power_parameters" actually is, though I would guess it is some sort of
> string/blob.

It's a json field where the underlying data type is a string but it gets
encoded/decoded in our custom field type.  So all that's already sorted.

> I don't quite see why setting distro_series is affecting this, but it
> sounds like power_parameters are being read and deserialized but not
> serialized again when trying to write them back to the DB.

Django likes to update all the fields at once it seems, so it's reading
and re-sending everything in the UPDATE.



References