Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm sure something like that will be added. One of the issues there facing is that hstore is a string => string map, so a conversion from json to that will be lossy (i.e. 'that "true" in hstore, is that the string "true" or a converted boolean true from json?').

What you can do right now though is use PL/V8 to query the JSON fields. Then you can use functional indexes to still being able to speed up queries. Yes. You could that before but now there's a guarantee that a field of type json contains just that, meaning that your application logic will get simpler.



> One of the issues there facing is that hstore is a string => string map, so a conversion from json to that will be lossy

Or the insertion/conversion routine can assert that the JSON object is a string:string mapping only.


Why would that be helpful? I'd want arrays, hashes, integers, etc.


You won't get them in an hstore[0] column, which was the context of my reply. Of course in a JSON column you want full JSON support, but my and my parent's post were about converting back and forth between hstore and json.

Since hstore only handles string:string mapping, the choice is either to silently corrupt data by stringifying all values in the json->hstore encoding, or erroring out if the input data is anything other than string:string.

The latter would be what I'd prefer, and more in line with usual Postgres behavior.

[0] http://www.postgresql.org/docs/9.2/static/hstore.html




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: