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

### Methods

fetch merge op parse sql_literal_append unquoted_literal

### 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.
QUOTE | = | '"'.freeze
COMMA | = | ",".freeze
KV_SEP | = | "=>".freeze
NULL | = | "NULL".freeze
ESCAPE_RE | = | /("|\\)/.freeze
ESCAPE_REPLACE | = | '\\\\\1'.freeze
HSTORE_CAST | = | '::hstore'.freeze

### External Aliases

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

### Public Class methods

parse(str)

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 187
    187:       def self.parse(str)
    188:         new(Parser.new(str).parse)
    189:       end

### Public Instance methods

fetch(key, *args, &block)

Override to force the key argument to a string.

[Source]

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

merge(hash, &block)

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 219
    219:       def merge(hash, &block)
    220:         self.class.new(super(convert_hash(hash), &block))
    221:       end

op()

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 261
    261:         def op
    262:           HStoreOp.new(self)
    263:         end

sql_literal_append(ds, sql)

Append a literalize version of the hstore to the sql.

[Source]

         # File lib/sequel/extensions/pg_hstore.rb, line 227
    227:       def sql_literal_append(ds, sql)
    228:         ds.literal_append(sql, unquoted_literal)
    229:         sql << HSTORE_CAST
    230:       end

unquoted_literal()

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 235
    235:       def unquoted_literal
    236:         str = ''
    237:         comma = false
    238:         commas = COMMA
    239:         quote = QUOTE
    240:         kv_sep = KV_SEP
    241:         null = NULL
    242:         each do |k, v|
    243:           str << commas if comma
    244:           str << quote << escape_value(k) << quote
    245:           str << kv_sep
    246:           if v.nil?
    247:             str << null
    248:           else
    249:             str << quote << escape_value(v) << quote
    250:           end
    251:           comma = true
    252:         end
    253:         str
    254:       end

[Validate]