forked from rails/rails
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Concise logging format for the binds of casted values
Related issue rails#41133. In rails#39106, I've allowed binds of casted values as an alternative of the legacy binds (an array of `[column || nil, value]`) to deprecate and remove the legacy binds support in a future version of Rails. At that time, I've respected the existing logging format for binds. i.e. ```ruby # legacy binds conn.select_all("SELECT * FROM events WHERE id IN (?, ?)", nil, [[nil, 1], [nil, 2]]) # (0.1ms) SELECT * FROM events WHERE id IN (?, ?) [[nil, 1], [nil, 2]] # casted binds conn.select_all("SELECT * FROM events WHERE id IN (?, ?)", nil, [1, 2]) # (0.1ms) SELECT * FROM events WHERE id IN (?, ?) [[nil, 1], [nil, 2]] ``` To improve the performance of generating IN clause, 72fd0ba avoids `build_bind_attribute` for each values, so now binds has become casted values. ```ruby conn.select_all(Event.where(id: [1, 2])) # (0.1ms) SELECT * FROM events WHERE id IN (?, ?) [[nil, 1], [nil, 2]] ``` Regardless of whether 72fd0ba avoids `build_bind_attribute` or not, the logging format for the binds of casted values is odd (at least not pretty to me). I'd like to concise the logging format to just use casted values. ```ruby conn.select_all("SELECT * FROM events WHERE id IN (?, ?)", nil, [1, 2]) # (0.1ms) SELECT * FROM events WHERE id IN (?, ?) [1, 2] conn.select_all(Event.where(id: [1, 2])) # (0.1ms) SELECT * FROM events WHERE id IN (?, ?) [1, 2] ```
- Loading branch information
Showing
2 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters