Reputation: 2842
I save 3 level dictionaries in postgresql with sqlalchemy as jsonb type:
{'result': {'key_0': {...}, 'key_1': {...}, None: {...}}
After querying row I have got None converted to string
{'result': {'key_0': {...}, 'key_1': {...}, u'null': {...}}
Is this sqlalchemy bug?
postgresql 9.4, sqlalchemy 1.0.8, ubuntu server 12.04.5
Upvotes: 2
Views: 977
Reputation: 22893
It looks about right to me.
In javascript (and hence json) I believe that dictionary indices get converted to strings. So - it generates something like:
myvar[null] = {...}
which becomes
myvar['null'] = {...}
In any case, seeing null used as a dictionary key would make me run for the hills. I would recommend against it.
Upvotes: 2