Class Sequel::Dataset::PlaceholderLiteralizer::Recorder
In: lib/sequel/dataset/placeholder_literalizer.rb
Parent: Object

Records the offsets at which the placeholder arguments are used in the SQL query.

Methods

arg   loader   use  

Public Instance methods

Return an Argument with the specified position, or the next position. In general you shouldn‘t mix calls with an argument and calls without an argument for the same receiver.

[Source]

     # File lib/sequel/dataset/placeholder_literalizer.rb, line 99
 99:         def arg(v=(no_arg_given = true; @argn+=1))
100:           unless no_arg_given
101:             @argn = v if @argn < v
102:           end
103:           Argument.new(self, v)
104:         end

Yields the receiver and the dataset to the block, which should call arg on the receiver for each placeholder argument, and return the dataset that you want to load.

[Source]

    # File lib/sequel/dataset/placeholder_literalizer.rb, line 77
77:         def loader(dataset)
78:           @argn = -1
79:           @args = []
80:           ds = yield self, dataset
81:           sql = ds.clone(:placeholder_literalizer=>self).sql
82: 
83:           last_offset = 0
84:           fragments = @args.map do |used_sql, offset, arg, t|
85:             raise Error, "placeholder literalizer argument literalized into different string than dataset returned" unless used_sql.equal?(sql)
86:             a = [sql[last_offset...offset], arg, t]
87:             last_offset = offset
88:             a
89:           end
90:           final_sql = sql[last_offset..-1]
91: 
92:           arity = @argn+1
93:           PlaceholderLiteralizer.new(ds.clone, fragments, final_sql, arity)
94:         end

Record the offset at which the argument is used in the SQL query, and any transforming

[Source]

     # File lib/sequel/dataset/placeholder_literalizer.rb, line 108
108:         def use(sql, arg, transformer)
109:           @args << [sql, sql.length, arg, transformer]
110:         end

[Validate]