@@ -43,7 +43,7 @@ def detect_sql_injection(sql, adapter_name)
4343 end
4444 end
4545
46- # patch for all adapters in ActiveRecord >= 7.1
46+ # patch for mysql2, sqlite3, and postgres+jdbc adapters in ActiveRecord >= 7.1
4747 module InternalExecQueryAdapterPatch
4848 def internal_exec_query ( sql , *args , **rest )
4949 Instrumentation . detect_sql_injection ( sql , adapter_name )
@@ -52,37 +52,36 @@ def internal_exec_query(sql, *args, **rest)
5252 end
5353 end
5454
55- # patch for postgres adapter in ActiveRecord < 7.1
56- module ExecuteAndClearAdapterPatch
57- def execute_and_clear ( sql , *args , **rest )
55+ # patch for mysql2, sqlite3, and postgres+jdbc adapters in ActiveRecord < 7.1
56+ module ExecQueryAdapterPatch
57+ def exec_query ( sql , *args , **rest )
5858 Instrumentation . detect_sql_injection ( sql , adapter_name )
5959
6060 super
6161 end
6262 end
6363
64- # patch for postgres adapter in ActiveRecord 4
65- module Rails4ExecuteAndClearAdapterPatch
66- def execute_and_clear ( sql , name , binds )
64+ # patch for mysql2, sqlite3, and postgres+jdbc db adapters in ActiveRecord 4
65+ module Rails4ExecQueryAdapterPatch
66+ def exec_query ( sql , * args )
6767 Instrumentation . detect_sql_injection ( sql , adapter_name )
6868
6969 super
7070 end
7171 end
7272
73- # patch for mysql2 and sqlite3 adapters in ActiveRecord < 7.1
74- # also used for postgres adapter in ActiveRecord >= 7.1 when used together with JDBC adapter
75- module ExecQueryAdapterPatch
76- def exec_query ( sql , *args , **rest )
73+ # patch for non-jdbc postgres adapter in ActiveRecord > 4
74+ module ExecuteAndClearAdapterPatch
75+ def execute_and_clear ( sql , *args , **rest )
7776 Instrumentation . detect_sql_injection ( sql , adapter_name )
7877
7978 super
8079 end
8180 end
8281
83- # patch for mysql2 and sqlite3 db adapters in ActiveRecord 4
84- module Rails4ExecQueryAdapterPatch
85- def exec_query ( sql , * args )
82+ # patch for non-jdbc postgres adapter in ActiveRecord 4
83+ module Rails4ExecuteAndClearAdapterPatch
84+ def execute_and_clear ( sql , name , binds )
8685 Instrumentation . detect_sql_injection ( sql , adapter_name )
8786
8887 super
0 commit comments