Class | Sequel::Postgres::HStore |
In: |
lib/sequel/extensions/pg_hstore.rb
lib/sequel/extensions/pg_hstore_ops.rb |
Parent: | DelegateClass(Hash) |
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. |
Override to force the key argument to a string.
# File lib/sequel/extensions/pg_hstore.rb, line 215 215: def fetch(key, *args, &block) 216: super(key.to_s, *args, &block) 217: end
Append a literalize version of the hstore to the sql.
# File lib/sequel/extensions/pg_hstore.rb, line 229 229: def sql_literal_append(ds, sql) 230: ds.literal_append(sql, unquoted_literal) 231: sql << HSTORE_CAST 232: 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 237 237: def unquoted_literal 238: str = '' 239: comma = false 240: commas = COMMA 241: quote = QUOTE 242: kv_sep = KV_SEP 243: null = NULL 244: each do |k, v| 245: str << commas if comma 246: str << quote << escape_value(k) << quote 247: str << kv_sep 248: if v.nil? 249: str << null 250: else 251: str << quote << escape_value(v) << quote 252: end 253: comma = true 254: end 255: str 256: end