Class: Sequel::Postgres::JSONHash
- Includes:
- SQL::AliasMethods
- Defined in:
- lib/sequel/extensions/pg_json.rb,
lib/sequel/extensions/pg_json_ops.rb
Overview
Class representating PostgreSQL JSON column hash/object values.
Instance Method Summary collapse
-
#op ⇒ Object
Wrap the JSONHash instance in an JSONOp, allowing you to easily use the PostgreSQL json functions and operators with literal jsons.
-
#sql_literal_append(ds, sql) ⇒ Object
Convert the hash to a json string, append a literalized version of the string to the sql, and explicitly cast the string to json.
Methods included from SQL::AliasMethods
Methods inherited from Hash
#&, #case, #hstore, #pg_json, #sql_expr, #sql_negate, #sql_or, #|, #~
Instance Method Details
#op ⇒ Object
Wrap the JSONHash instance in an JSONOp, allowing you to easily use the PostgreSQL json functions and operators with literal jsons.
223 224 225 |
# File 'lib/sequel/extensions/pg_json_ops.rb', line 223 def op JSONOp.new(self) end |
#sql_literal_append(ds, sql) ⇒ Object
Convert the hash to a json string, append a literalized version of the string to the sql, and explicitly cast the string to json.
88 89 90 91 |
# File 'lib/sequel/extensions/pg_json.rb', line 88 def sql_literal_append(ds, sql) ds.literal_append(sql, Sequel.object_to_json(self)) sql << CAST_JSON end |