File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
lib/rails_semantic_logger/active_record Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -165,13 +165,13 @@ def type_casted_binds_v5_1_5(casted_binds)
165
165
if Rails ::VERSION ::MAJOR == 5 && Rails ::VERSION ::MINOR . zero? && Rails ::VERSION ::TINY <= 2 # 5.0.0 - 5.0.2
166
166
alias bind_values bind_values_v5_0_0
167
167
alias render_bind render_bind_v5_0_0
168
- elsif Rails ::VERSION ::MAJOR > = 5 &&
168
+ elsif Rails ::VERSION ::MAJOR = = 5 &&
169
169
( ( Rails ::VERSION ::MINOR . zero? && Rails ::VERSION ::TINY <= 6 ) ||
170
170
( Rails ::VERSION ::MINOR == 1 && Rails ::VERSION ::TINY <= 4 ) ) # 5.0.3 - 5.0.6 && 5.1.0 - 5.1.4
171
171
alias bind_values bind_values_v5_0_3
172
172
alias render_bind render_bind_v5_0_3
173
173
alias type_casted_binds type_casted_binds_v5_0_3
174
- elsif Rails ::VERSION ::MAJOR >= 5 # ~> 5.1.5 && ~> 5.0.7
174
+ elsif Rails ::VERSION ::MAJOR >= 5 # ~> 5.1.5 && ~> 5.0.7 && 6.x.x
175
175
alias bind_values bind_values_v5_1_5
176
176
alias render_bind render_bind_v5_0_3
177
177
alias type_casted_binds type_casted_binds_v5_1_5
Original file line number Diff line number Diff line change @@ -30,6 +30,22 @@ class ActiveRecordTest < Minitest::Test
30
30
assert actual [ :payload ] [ :sql ] , actual [ :payload ]
31
31
end
32
32
33
+ it 'sql with query cache' do
34
+ Sample . cache { 2 . times { Sample . where ( name : 'foo' ) . first } }
35
+
36
+ SemanticLogger . flush
37
+ actual = @mock_logger . message
38
+
39
+ if Rails . version . to_f >= 5.1
40
+ assert actual [ :message ] . include? ( 'Sample' ) , actual [ :message ]
41
+ else
42
+ assert actual [ :message ] . include? ( 'CACHE' ) , actual [ :message ]
43
+ end
44
+
45
+ assert actual [ :payload ] , actual
46
+ assert actual [ :payload ] [ :sql ] , actual [ :payload ]
47
+ end
48
+
33
49
it 'single bind value' do
34
50
Sample . where ( name : 'Jack' ) . first
35
51
You can’t perform that action at this time.
0 commit comments