skylight 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/skylight/instrumenter.rb +12 -1
- data/lib/skylight/normalizers/active_record/sql.rb +1 -1
- data/lib/skylight/version.rb +1 -1
- data/lib/sql_lexer/lexer.rb +32 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01262f190b63ef103a1e1bc671f3a98ff12798f6
|
4
|
+
data.tar.gz: d0fcae9d16a2fcff34cad93d33f16a4fcb4b8113
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acbb99369ebb3807ac990756d6606d99d86a716cf81b6bf0f6a4cc83d0832916da010d374e926435c3012044c572b4222e480bfba8f3bfcabf9a740538edb1ee
|
7
|
+
data.tar.gz: 8ed42b17470c205f40ef6c37c45572b1d84449d914ac9047bff2c7707b47e23bd537bf158bcce6f6898340d5342776992686fde8109538b59f795ee3e273b314
|
data/CHANGELOG.md
CHANGED
@@ -60,7 +60,18 @@ module Skylight
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
at_exit
|
63
|
+
at_exit do
|
64
|
+
if RUBY_VERSION == '1.9.2'
|
65
|
+
# workaround for MRI bug losing exit status in at_exit block
|
66
|
+
# http://bugs.ruby-lang.org/issues/5218
|
67
|
+
exit_status = $!.status if $!.is_a?(SystemExit)
|
68
|
+
stop!
|
69
|
+
exit exit_status if exit_status
|
70
|
+
else
|
71
|
+
stop!
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
64
75
|
|
65
76
|
attr_reader :config, :gc, :trace_info
|
66
77
|
|
@@ -39,7 +39,7 @@ module Skylight
|
|
39
39
|
|
40
40
|
private
|
41
41
|
def extract_binds(payload, precalculated)
|
42
|
-
title, sql, binds = SqlLexer::Lexer.bindify(payload[:sql], precalculated)
|
42
|
+
title, sql, binds = SqlLexer::Lexer.bindify(payload[:sql], precalculated, true)
|
43
43
|
[ title, sql, binds, nil ]
|
44
44
|
rescue => e
|
45
45
|
group = "sql_parse"
|
data/lib/skylight/version.rb
CHANGED
data/lib/sql_lexer/lexer.rb
CHANGED
@@ -108,9 +108,9 @@ module SqlLexer
|
|
108
108
|
array: :process_array
|
109
109
|
}
|
110
110
|
|
111
|
-
def self.bindify(string, binds=nil)
|
111
|
+
def self.bindify(string, binds=nil, strip_comments=false)
|
112
112
|
scanner = instance(string)
|
113
|
-
scanner.process(binds)
|
113
|
+
scanner.process(binds, strip_comments)
|
114
114
|
[scanner.title, scanner.output, scanner.binds]
|
115
115
|
end
|
116
116
|
|
@@ -176,8 +176,8 @@ module SqlLexer
|
|
176
176
|
PLACEHOLDER = "?".freeze
|
177
177
|
UNKNOWN = "<unknown>".freeze
|
178
178
|
|
179
|
-
def process(binds)
|
180
|
-
process_comments
|
179
|
+
def process(binds, strip_comments)
|
180
|
+
process_comments(strip_comments)
|
181
181
|
|
182
182
|
@operation = nil
|
183
183
|
@provided_binds = binds
|
@@ -220,9 +220,33 @@ module SqlLexer
|
|
220
220
|
nil
|
221
221
|
end
|
222
222
|
|
223
|
-
|
223
|
+
def replace_comment(pos, length, strip)
|
224
|
+
if strip
|
225
|
+
# Dup the string if necessary so we aren't destructive to the original value
|
226
|
+
if @input == @original_input
|
227
|
+
@input = @input.dup
|
228
|
+
@scanner.string = @input
|
229
|
+
end
|
230
|
+
|
231
|
+
# Replace the comment with a space to ensure valid SQL
|
232
|
+
# Updating the input also updates the scanner
|
233
|
+
@input[pos, length] = SPACE
|
234
|
+
@output[pos, length] = SPACE
|
235
|
+
|
236
|
+
# Move back to start of removed string
|
237
|
+
@scanner.pos = pos
|
238
|
+
else
|
239
|
+
# Dup the string if necessary so we aren't destructive to the original value
|
240
|
+
@scanner.string = @input.dup if @scanner.string == @original_input
|
241
|
+
|
242
|
+
# Replace the comment with spaces
|
243
|
+
@scanner.string[pos, length] = SPACE*length
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def process_comments(strip_comments)
|
248
|
+
@original_input = @input
|
224
249
|
|
225
|
-
def process_comments
|
226
250
|
# SQL treats comments as similar to whitespace
|
227
251
|
# Here we replace all comments with spaces of the same length so as to not affect binds
|
228
252
|
|
@@ -256,10 +280,7 @@ module SqlLexer
|
|
256
280
|
if count == 0
|
257
281
|
# We've closed all comments
|
258
282
|
length = @scanner.charpos - pos
|
259
|
-
|
260
|
-
@scanner.string = @input.dup if @scanner.string == @input
|
261
|
-
# Replace the comment with spaces
|
262
|
-
@scanner.string[pos, length] = SPACE*length
|
283
|
+
replace_comment(pos, length, strip_comments)
|
263
284
|
break
|
264
285
|
end
|
265
286
|
end
|
@@ -271,10 +292,7 @@ module SqlLexer
|
|
271
292
|
while @scanner.skip_until(TkComment)
|
272
293
|
pos = @scanner.charpos
|
273
294
|
len = @scanner.matched_size
|
274
|
-
|
275
|
-
@scanner.string = @input.dup if @scanner.string == @input
|
276
|
-
# Replace the comment with spaces
|
277
|
-
@scanner.string[pos-len, len] = SPACE*len
|
295
|
+
replace_comment(pos-len, len, strip_comments)
|
278
296
|
end
|
279
297
|
|
280
298
|
@scanner.reset
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skylight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilde, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|