softa/activerecord-postgres-hstore — pull request #10 by joelhoffman (2011-10-12 18:37:20+00:00)
Title: Improved hstore parser and generator

Hey, I've added a lot of functionality to the to_hstore and from_hstore functions following the postgres documentation and the hstore tests. The changes in app/ probably are wrong but they made it easier to use the new lib code in tests.

The from_hstore function should be able to parse anything Postgres can parse, even though Postgres doesn't actually emit some of it, someone might use this code for another purpose, so it should handle unquoted strings.

The to_hstore function now only quotes strings when necessary, following the postgres docs, and it doesn't generate single quoted strings.

NULL/nil values are sent to and from the database correctly except when they're hash keys.

What do you think? It might also be worthwhile to throw an exception from to_hstore when a hash has any non-string keys or non-string-or-null values.