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. |
Override to force the key argument to a string.
# File lib/sequel/extensions/pg_hstore.rb, line 213 213: def fetch(key, *args, &block) 214: super(key.to_s, *args, &block) 215: end
Append a literalize version of the hstore to the sql.
# 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
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 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