You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sql="SELECT \"game_types\".* FROM \"game_types\" WHERE \"game_types\".\"game_id\" IN (1162)"
21
24
result=AppOpticsAPM::Util.sanitize_sql(sql)
22
25
result.must_equal"SELECT \"game_types\".* FROM \"game_types\" WHERE \"game_types\".\"game_id\" IN (?)"
23
-
24
-
AppOpticsAPM::Config[:sanitize_sql]=false
25
26
end
26
27
27
28
deftest_sanitize_sql3
@@ -30,8 +31,6 @@ def test_sanitize_sql3
30
31
sql="SELECT \"comments\".* FROM \"comments\" WHERE \"comments\".\"commentable_id\" = 2798 AND \"comments\".\"commentable_type\" = 'Video' AND \"comments\".\"parent_id\" IS NULL ORDER BY comments.created_at DESC"
31
32
result=AppOpticsAPM::Util.sanitize_sql(sql)
32
33
result.must_equal"SELECT \"comments\".* FROM \"comments\" WHERE \"comments\".\"commentable_id\" = ? AND \"comments\".\"commentable_type\" = ? AND \"comments\".\"parent_id\" IS ? ORDER BY comments.created_at DESC"
33
-
34
-
AppOpticsAPM::Config[:sanitize_sql]=false
35
34
end
36
35
37
36
deftest_sanitize_sql4
@@ -40,8 +39,25 @@ def test_sanitize_sql4
40
39
sql="SELECT `assets`.* FROM `assets` WHERE `assets`.`type` IN ('Picture') AND (updated_at >= '2015-07-08 19:22:00') AND (updated_at <= '2015-07-08 19:23:00') LIMIT 31 OFFSET 0"
41
40
result=AppOpticsAPM::Util.sanitize_sql(sql)
42
41
result.must_equal"SELECT `assets`.* FROM `assets` WHERE `assets`.`type` IN (?) AND (updated_at >= ?) AND (updated_at <= ?) LIMIT ? OFFSET ?"
42
+
end
43
43
44
-
AppOpticsAPM::Config[:sanitize_sql]=false
44
+
deftest_sanitize_quoted_stuff1
45
+
AppOpticsAPM::Config[:sanitize_sql]=true
46
+
47
+
sql="SELECT `users`.* FROM `users` WHERE (mobile IN ('234 234 234') AND email IN ('a_b_c@hotmail.co.uk'))"
48
+
result=AppOpticsAPM::Util.sanitize_sql(sql)
49
+
result.must_equal"SELECT `users`.* FROM `users` WHERE (mobile IN (?) AND email IN (?))"
50
+
end
51
+
52
+
deftest_sanitize_quoted_stuff2
53
+
AppOpticsAPM::Config[:sanitize_sql]=true
54
+
55
+
56
+
# trying to reproduce "SELECT `users`.* FROM `users` WHERE (mobile IN (?a_b_c@hotmail.co.uk') LIMIT ?"
57
+
sql="SELECT `users`.* FROM `users` WHERE (mobile IN ('\\\'1454545') AND email IN ('a_b_c@hotmail.co.uk')) LIMIT 5"
58
+
# sql = "SELECT `users`.* FROM `users` WHERE (mobile IN ('2342423') AND email IN ('a_b_c@hotmail.co.uk')) LIMIT 5"
59
+
result=AppOpticsAPM::Util.sanitize_sql(sql)
60
+
result.must_equal"SELECT `users`.* FROM `users` WHERE (mobile IN (?) AND email IN (?)) LIMIT ?"
0 commit comments