scout_apm 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +5 -1
- data/lib/scout_apm/utils/sql_sanitizer.rb +4 -0
- data/lib/scout_apm/version.rb +1 -1
- data/test/unit/sql_sanitizer_test.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da3e8194a4123e62f0a2ecc81cdcd0e34a8c59f8
|
4
|
+
data.tar.gz: 3f1b5006c5b01ff013237bd3d1049e94e2aea2d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23a1b46036c8b7597f148b1a48b57c6015bb6ba6b95ec99fd4c83f0c76aad186989a12ee8a5a24ab56d02aa02f33a5a5dff7dfd382c87a1b5e771fa105f415d7
|
7
|
+
data.tar.gz: 5f0e06ed2699252ff6eb07581e76cf5e2283b5f459521249b29546caa9c58271257766f6d320b8087c171983d5f8da09e91bc97d6101181a90ce0ab3ff66145f
|
data/CHANGELOG.markdown
CHANGED
@@ -32,12 +32,14 @@ module ScoutApm
|
|
32
32
|
PSQL_REMOVE_STRINGS = /'(?:[^']|'')*'/.freeze
|
33
33
|
PSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
|
34
34
|
PSQL_PLACEHOLDER = /\$\d+/.freeze
|
35
|
+
PSQL_IN_CLAUSE = /IN\s+\((\s*\?,?\s*)*\)/.freeze
|
35
36
|
|
36
37
|
def to_s_postgres
|
37
38
|
sql.gsub!(PSQL_PLACEHOLDER, '?')
|
38
39
|
sql.gsub!(PSQL_VAR_INTERPOLATION, '')
|
39
40
|
sql.gsub!(PSQL_REMOVE_STRINGS, '?')
|
40
41
|
sql.gsub!(PSQL_REMOVE_INTEGERS, '?')
|
42
|
+
sql.gsub!(PSQL_IN_CLAUSE, 'IN (?)')
|
41
43
|
sql.gsub!(MULTIPLE_SPACES, ' ')
|
42
44
|
sql.gsub!(TRAILING_SPACES, '')
|
43
45
|
sql
|
@@ -47,12 +49,14 @@ module ScoutApm
|
|
47
49
|
MYSQL_REMOVE_INTEGERS = /(?<!LIMIT )\b\d+\b/.freeze
|
48
50
|
MYSQL_REMOVE_SINGLE_QUOTE_STRINGS = /'(?:[^']|'')*'/.freeze
|
49
51
|
MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS = /"(?:[^"]|"")*"/.freeze
|
52
|
+
MYSQL_IN_CLAUSE = /IN\s+\((\s*\?,?\s*)*\)/.freeze
|
50
53
|
|
51
54
|
def to_s_mysql
|
52
55
|
sql.gsub!(MYSQL_VAR_INTERPOLATION, '')
|
53
56
|
sql.gsub!(MYSQL_REMOVE_SINGLE_QUOTE_STRINGS, '?')
|
54
57
|
sql.gsub!(MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS, '?')
|
55
58
|
sql.gsub!(MYSQL_REMOVE_INTEGERS, '?')
|
59
|
+
sql.gsub!(MYSQL_IN_CLAUSE, '?')
|
56
60
|
sql.gsub!(MULTIPLE_QUESTIONS, '?')
|
57
61
|
sql.gsub!(TRAILING_SPACES, '')
|
58
62
|
sql
|
data/lib/scout_apm/version.rb
CHANGED
@@ -35,6 +35,12 @@ module ScoutApm
|
|
35
35
|
assert_equal %q|SELECT "blogs".* FROM "blogs" WHERE (view_count > ?)|, ss.to_s
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_postgres_collapse_in_clause
|
39
|
+
sql = %q|SELECT "blogs".* FROM "blogs" WHERE id IN (?, ?, ?)|
|
40
|
+
ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :postgres }
|
41
|
+
assert_equal %q|SELECT "blogs".* FROM "blogs" WHERE id IN (?)|, ss.to_s
|
42
|
+
end
|
43
|
+
|
38
44
|
def test_mysql_where
|
39
45
|
sql = %q|SELECT `users`.* FROM `users` WHERE `users`.`name` = ? [["name", "chris"]]|
|
40
46
|
ss = SqlSanitizer.new(sql).tap{ |it| it.database_engine = :mysql }
|