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

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

[Source]

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

[Validate]