class Sequel::Postgres::JSONQueryOp

Object representing json_query calls

Constants

ON_SQL
WRAPPER

Attributes

wrapper[R]

How to handle wrapping of results

Public Class Methods

new(expr, path, opts=OPTS) click to toggle source

See JSONBaseOp#query for documentation of the options.

Calls superclass method Sequel::Postgres::JSONValueOp::new
     # File lib/sequel/extensions/pg_json_ops.rb
1116 def initialize(expr, path, opts=OPTS)
1117   @wrapper = opts[:wrapper]
1118   super
1119 end

Private Instance Methods

on_sql_value(value) click to toggle source
     # File lib/sequel/extensions/pg_json_ops.rb
1142 def on_sql_value(value)
1143   ON_SQL[value]
1144 end
to_s_append_args_passing(ds, sql) click to toggle source

Also append the optional WRAPPER/OMIT QUOTES fragment

     # File lib/sequel/extensions/pg_json_ops.rb
1134 def to_s_append_args_passing(ds, sql)
1135   super
1136 
1137   if @wrapper
1138     sql << WRAPPER.fetch(@wrapper)
1139   end
1140 end
to_s_append_function_name(ds, sql) click to toggle source
     # File lib/sequel/extensions/pg_json_ops.rb
1129 def to_s_append_function_name(ds, sql)
1130   sql << 'json_query('
1131 end
transform_opts(transformer, opts) click to toggle source

Also handle transforming the wrapper option

     # File lib/sequel/extensions/pg_json_ops.rb
1124 def transform_opts(transformer, opts)
1125   super
1126   opts[:wrapper] = @wrapper
1127 end