Object
representing json_table calls
Classes and Modules
Public Class methods
new(expr, path, opts=OPTS, &block)
See JSONBaseOp#table
for documentation on the options.
[show source]
# File lib/sequel/extensions/pg_json_ops.rb 1208 def initialize(expr, path, opts=OPTS, &block) 1209 @expr = expr 1210 @path = path 1211 @passing = opts[:passing] 1212 @on_error = opts[:on_error] 1213 @columns = opts[:_columns] || ColumnDSL.columns(&block) 1214 freeze 1215 end
Public Instance methods
sequel_ast_transform(transformer)
Support transforming of json_table expression
[show source]
# File lib/sequel/extensions/pg_json_ops.rb 1244 def sequel_ast_transform(transformer) 1245 opts = {:on_error=>@on_error, :_columns=>@columns} 1246 1247 if @passing 1248 passing = opts[:passing] = {} 1249 @passing.each do |k, v| 1250 passing[k] = transformer.call(v) 1251 end 1252 end 1253 1254 self.class.new(transformer.call(@expr), @path, opts) 1255 end
to_s_append(ds, sql)
Append the json_table function call expression to the SQL
[show source]
# File lib/sequel/extensions/pg_json_ops.rb 1218 def to_s_append(ds, sql) 1219 sql << 'json_table(' 1220 ds.literal_append(sql, @expr) 1221 sql << ', ' 1222 default_literal_append(ds, sql, @path) 1223 1224 if (passing = @passing) && !passing.empty? 1225 sql << ' PASSING ' 1226 comma = false 1227 passing.each do |k, v| 1228 if comma 1229 sql << ', ' 1230 else 1231 comma = true 1232 end 1233 ds.literal_append(sql, v) 1234 sql << " AS " << k.to_s 1235 end 1236 end 1237 1238 to_s_append_columns(ds, sql, @columns) 1239 sql << TABLE_ON_ERROR_SQL.fetch(@on_error) if @on_error 1240 sql << ')' 1241 end