Merge lp:~ack/storm/postgres-json-support into lp:storm
Proposed by
Alberto Donato
Status: | Merged |
---|---|
Merged at revision: | 482 |
Proposed branch: | lp:~ack/storm/postgres-json-support |
Merge into: | lp:storm |
Diff against target: |
109 lines (+56/-3) 2 files modified
storm/databases/postgres.py (+27/-1) tests/databases/postgres.py (+29/-2) |
To merge this branch: | bzr merge lp:~ack/storm/postgres-json-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stuart Bishop (community) | Approve | ||
Free Ekanayaka (community) | Approve | ||
Review via email: mp+293255@code.launchpad.net |
Description of the change
This adds a Postgres-specific version of the JSON property (and JSONVariable).
It's supposed to be used with the Postgres "json" type.
Note that psycopg2 >= 2.5 automatically decodes json values to python objects, while previous versions return a plain string.
To post a comment you must log in.
This looks good, but seems to be only half of the picture. You can pull JSON out of the DB and it is correctly deserialized into the relevant Python object. However, you can't store a Python object and have it automatically serialized to JSON - you need to do that yourself (and by choosing this approach, it can't really be added in later).
Can we also add a _dumps() method (or whatever it needs to be called) to serialize the value to JSON (or raise an exception if it is unserializable)?