Class: Sequel::Postgres::JSONArray

Inherits:
Array show all
Includes:
SQL::AliasMethods
Defined in:
lib/sequel/extensions/pg_json.rb,
lib/sequel/extensions/pg_json_ops.rb

Overview

Class representating PostgreSQL JSON column array values.

Instance Method Summary collapse

Methods included from SQL::AliasMethods

#as

Methods inherited from Array

#case, #pg_array, #pg_json, #pg_row, #sql_expr, #sql_negate, #sql_or, #sql_string_join, #sql_value_list, #~

Instance Method Details

#opObject

Wrap the JSONHash instance in an JSONOp, allowing you to easily use the PostgreSQL json functions and operators with literal jsons.



210
211
212
# File 'lib/sequel/extensions/pg_json_ops.rb', line 210

def op
  JSONOp.new(self)
end

#sql_literal_append(ds, sql) ⇒ Object

Convert the array to a json string, append a literalized version of the string to the sql, and explicitly cast the string to json.



72
73
74
75
# File 'lib/sequel/extensions/pg_json.rb', line 72

def sql_literal_append(ds, sql)
  ds.literal_append(sql, Sequel.object_to_json(self))
  sql << CAST_JSON
end