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 Bind
|
|
|
|
def initialize
|
|
|
|
@binds = []
|
|
|
|
end
|
|
|
|
|
2018-02-24 01:45:50 -05:00
|
|
|
def <<(str)
|
2017-07-21 09:41:07 -04:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2018-02-24 01:45:50 -05:00
|
|
|
def add_bind(bind)
|
2017-07-21 09:41:07 -04:00
|
|
|
@binds << bind
|
|
|
|
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)
|
|
|
|
@binds.concat proc_for_binds ? binds.map(&proc_for_binds) : binds
|
2020-05-10 13:09:29 -04:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2017-07-21 09:41:07 -04:00
|
|
|
def value
|
|
|
|
@binds
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|