Class Sequel::Postgres::HStore
In: lib/sequel/extensions/pg_hstore_ops.rb
lib/sequel/extensions/pg_hstore.rb
Parent: Object

Methods

_dump   _load   fetch   merge   op   parse   sql_literal_append   unquoted_literal  

Included Modules

Sequel::SQL::AliasMethods

Classes and Modules

Module Sequel::Postgres::HStore::DatabaseMethods
Class Sequel::Postgres::HStore::Parser

Constants

DEFAULT_PROC = lambda{|h, k| h[k.to_s] unless k.is_a?(String)}   Default proc used for all underlying HStore hashes, so that even if you grab the underlying hash, it will still convert non-string keys to strings during lookup.

External Aliases

__getobj__ -> to_hash
  Return the underlying hash used by this HStore instance.

Public Class methods

Use custom marshal loading, since underlying hash uses a default proc.

[Source]

     # File lib/sequel/extensions/pg_hstore.rb, line 187
187:       def self._load(args)
188:         new(Hash[Marshal.load(args)])
189:       end

Parse the given string into an HStore, assuming the str is in PostgreSQL hstore output format.

[Source]

     # File lib/sequel/extensions/pg_hstore.rb, line 193
193:       def self.parse(str)
194:         new(Parser.new(str).parse)
195:       end

Public Instance methods

Use custom marshal dumping, since underlying hash uses a default proc.

[Source]

     # File lib/sequel/extensions/pg_hstore.rb, line 219
219:       def _dump(*)
220:         Marshal.dump(to_a)
221:       end

Override to force the key argument to a string.

[Source]

     # File lib/sequel/extensions/pg_hstore.rb, line 224
224:       def fetch(key, *args, &block)
225:         super(key.to_s, *args, &block)
226:       end

Convert the input hash to string keys and values before merging, and return a new HStore instance with the merged hash.

[Source]

     # File lib/sequel/extensions/pg_hstore.rb, line 230
230:       def merge(hash, &block)
231:         self.class.new(super(convert_hash(hash), &block))
232:       end

Wrap the receiver in an HStoreOp so you can easily use the PostgreSQL hstore functions and operators with it.

[Source]

     # File lib/sequel/extensions/pg_hstore_ops.rb, line 319
319:         def op
320:           HStoreOp.new(self)
321:         end

Append a literalize version of the hstore to the sql.

[Source]

     # File lib/sequel/extensions/pg_hstore.rb, line 238
238:       def sql_literal_append(ds, sql)
239:         ds.literal_append(sql, unquoted_literal)
240:         sql << '::hstore'
241:       end

Return a string containing the unquoted, unstring-escaped literal version of the hstore. Separated out for use by the bound argument code.

[Source]

     # File lib/sequel/extensions/pg_hstore.rb, line 246
246:       def unquoted_literal
247:         str = String.new
248:         comma = false
249:         commas = ","
250:         quote = '"'
251:         kv_sep = "=>"
252:         null = "NULL"
253:         each do |k, v|
254:           str << commas if comma
255:           str << quote << escape_value(k) << quote
256:           str << kv_sep
257:           if v.nil?
258:             str << null
259:           else
260:             str << quote << escape_value(v) << quote
261:           end
262:           comma = true
263:         end
264:         str
265:       end

[Validate]