1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/arel/collectors/sql_string.rb
Sean Griffin 590c784a30 Add order to BindParams in the ToSql collector
This removes the need for us to do the re-ordering by walking the AST in
ActiveRecord. We're using a block to communicate with the collector,
since the collector needs to be the thing which knows about the index,
while the visitor is the thing that needs to know the syntax. The
BindParam needs to know about neither of these things, so it's been
changed to stop being a subclass of SqlLiteral

I could also see an alternative implementation using format strings if
for some reason blocks cause a problem.
2014-11-17 14:52:38 -08:00

24 lines
370 B
Ruby

# encoding: utf-8
require 'arel/collectors/plain_string'
module Arel
module Collectors
class SQLString < PlainString
def initialize(*)
super
@bind_index = 1
end
def add_bind bind
self << yield(@bind_index)
@bind_index += 1
self
end
def compile bvs
value
end
end
end
end