Class | Sequel::Postgres::HStore |
In: |
lib/sequel/extensions/pg_hstore_ops.rb
lib/sequel/extensions/pg_hstore.rb |
Parent: | Object |
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 |
__getobj__ | -> | to_hash |
Return the underlying hash used by this HStore instance. |
Use custom marshal loading, since underlying hash uses a default proc.
# File lib/sequel/extensions/pg_hstore.rb, line 208 208: def self._load(args) 209: new(Hash[Marshal.load(args)]) 210: end
Use custom marshal dumping, since underlying hash uses a default proc.
# File lib/sequel/extensions/pg_hstore.rb, line 240 240: def _dump(*) 241: Marshal.dump(to_a) 242: end
Override to force the key argument to a string.
# File lib/sequel/extensions/pg_hstore.rb, line 245 245: def fetch(key, *args, &block) 246: super(key.to_s, *args, &block) 247: end
Append a literalize version of the hstore to the sql.
# File lib/sequel/extensions/pg_hstore.rb, line 259 259: def sql_literal_append(ds, sql) 260: ds.literal_append(sql, unquoted_literal) 261: sql << HSTORE_CAST 262: end
Return a string containing the unquoted, unstring-escaped literal version of the hstore. Separated out for use by the bound argument code.
# File lib/sequel/extensions/pg_hstore.rb, line 267 267: def unquoted_literal 268: str = String.new 269: comma = false 270: commas = COMMA 271: quote = QUOTE 272: kv_sep = KV_SEP 273: null = NULL 274: each do |k, v| 275: str << commas if comma 276: str << quote << escape_value(k) << quote 277: str << kv_sep 278: if v.nil? 279: str << null 280: else 281: str << quote << escape_value(v) << quote 282: end 283: comma = true 284: end 285: str 286: end