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 101
101:         def arg(v=(no_arg_given = true; @argn+=1))
102:           unless no_arg_given
103:             @argn = v if @argn < v
104:           end
105:           Argument.new(self, v)
106:         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 79
79:         def loader(dataset)
80:           @argn = -1
81:           @args = []
82:           ds = yield self, dataset
83:           sql = ds.clone(:placeholder_literalizer=>self).sql
84: 
85:           last_offset = 0
86:           fragments = @args.map do |used_sql, offset, arg, t|
87:             raise Error, "placeholder literalizer argument literalized into different string than dataset returned" unless used_sql.equal?(sql)
88:             a = [sql[last_offset...offset], arg, t]
89:             last_offset = offset
90:             a
91:           end
92:           final_sql = sql[last_offset..-1]
93: 
94:           arity = @argn+1
95:           PlaceholderLiteralizer.new(ds.clone, fragments, final_sql, arity)
96:         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 110
110:         def use(sql, arg, transformer)
111:           @args << [sql, sql.length, arg, transformer]
112:         end

[Validate]