1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/arel/collectors/composite.rb
Ryuta Kamizono 6d06a657fc Fix binds logging for HomogeneousIn
Make bind attribute if the bind collector is used.

Before:

```
User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."id" IN (?, ?, ?, ?, ?)  [[nil, 1], [nil, 2], [nil, 3], [nil, 4], [nil, 5]]
```

After:

```
User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."id" IN (?, ?, ?, ?, ?)  [["id", 1], ["id", 2], ["id", 3], ["id", 4], ["id", 5]]
```

(cherry picked from commit cd1a3705c5f18e431e5311c5dc123ed765752ecf)
2021-02-25 20:37:20 -05:00

39 lines
747 B
Ruby

# frozen_string_literal: true
module Arel # :nodoc: all
module Collectors
class Composite
attr_accessor :preparable
def initialize(left, right)
@left = left
@right = right
end
def <<(str)
left << str
right << str
self
end
def add_bind(bind, &block)
left.add_bind bind, &block
right.add_bind bind, &block
self
end
def add_binds(binds, proc_for_binds = nil, &block)
left.add_binds(binds, proc_for_binds, &block)
right.add_binds(binds, proc_for_binds, &block)
self
end
def value
[left.value, right.value]
end
private
attr_reader :left, :right
end
end
end