2017-07-21 09:41:07 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-02-24 02:41:47 -05:00
|
|
|
module Arel # :nodoc: all
|
2017-07-21 09:41:07 -04:00
|
|
|
module Collectors
|
|
|
|
class Composite
|
2020-05-03 09:47:24 -04:00
|
|
|
attr_accessor :preparable
|
|
|
|
|
2017-07-21 09:41:07 -04:00
|
|
|
def initialize(left, right)
|
|
|
|
@left = left
|
|
|
|
@right = right
|
|
|
|
end
|
|
|
|
|
2018-02-24 01:45:50 -05:00
|
|
|
def <<(str)
|
2017-07-21 09:41:07 -04:00
|
|
|
left << str
|
|
|
|
right << str
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2018-02-24 01:45:50 -05:00
|
|
|
def add_bind(bind, &block)
|
2017-07-21 09:41:07 -04:00
|
|
|
left.add_bind bind, &block
|
|
|
|
right.add_bind bind, &block
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
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-23 01:55:57 -05:00
|
|
|
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)
|
2020-05-10 13:09:29 -04:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2017-07-21 09:41:07 -04:00
|
|
|
def value
|
|
|
|
[left.value, right.value]
|
|
|
|
end
|
|
|
|
|
2018-09-30 02:24:17 -04:00
|
|
|
private
|
2018-02-24 01:45:50 -05:00
|
|
|
attr_reader :left, :right
|
2017-07-21 09:41:07 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|