Skip to content

A principled Postgres HStore parser/deparser for Ruby.

License

Notifications You must be signed in to change notification settings

seamusabshere/pg-hstore

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Ruby 100.0%