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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eadc6cf693f387c94fdbbaa5bc96a759c80be140
4
- data.tar.gz: e6c9465cde1d1589f72e6c46f95a9e45ba54f627
3
+ metadata.gz: da3e8194a4123e62f0a2ecc81cdcd0e34a8c59f8
4
+ data.tar.gz: 3f1b5006c5b01ff013237bd3d1049e94e2aea2d8
5
5
  SHA512:
6
- metadata.gz: 77a3ee7b7e4fd8b1c3ee62231d4566d1bf9937ea4d48498194b991d7ffb55782c13baaae1021aa127325dccc9ccd2a200722b5b5ae7a341825a2acf45f5c854b
7
- data.tar.gz: 2aa25dca40e455d4463676c77f6bd105d07402c6358d9e479ba6033b143464e8d546ff39a4ea50e82f0b9e9c92959bb393f69ba9cec3d50ba3d35c67268591a9
6
+ metadata.gz: 23a1b46036c8b7597f148b1a48b57c6015bb6ba6b95ec99fd4c83f0c76aad186989a12ee8a5a24ab56d02aa02f33a5a5dff7dfd382c87a1b5e771fa105f415d7
7
+ data.tar.gz: 5f0e06ed2699252ff6eb07581e76cf5e2283b5f459521249b29546caa9c58271257766f6d320b8087c171983d5f8da09e91bc97d6101181a90ce0ab3ff66145f
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.1.5
2
+
3
+ * SQL sanitization now collapses IN (?,?,?) to a single (?)
4
+
1
5
  # 0.1.4
2
6
 
3
7
  * Tweaks to Postgres query parsing
@@ -28,4 +32,4 @@
28
32
 
29
33
  # 0.1.0
30
34
 
31
- * Boom.
35
+ * Boom.
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ScoutApm
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -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 }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Haynes