fastpencil / pg-hstore

A principled Postgres HStore parser/deparser for Ruby.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pg-hstore

The gem is called pg-hstore, but you should require pg_hstore (sorry):

>> require 'pg_hstore'
=> true

Dump a hash to an hstore string:

>> hstore = PgHstore.dump(hello: %{world, you're "GREAT!"})
=> "'\"hello\" => \"world, you''re \\\"GREAT!\\\"\"'"

Load an hstore string into a hash:

>> hash = PgHstore.load(hstore)
=> {:hello=>"world, you're \"GREAT!\""}

Dump a hash for use as a bind parameter/variable (i.e., we won't be needing single quotes):

>> hstore = PgHstore.dump({hello: %{world, you're "GREAT!"}}, true)
=> "\"hello\" => \"world, you're \\\"GREAT!\\\"\""

Load an hstore string but don't symbolize keys:

>> hash = PgHstore.load(hstore, false)
=> {"hello"=>"world, you're \"GREAT!\""}

Authors

Copyright

Copyright (c) 2013 the authors. See LICENSE for details.

About

A principled Postgres HStore parser/deparser for Ruby.

License:MIT License