mysql2_query_filter-plugin-casual_log 0.0.3 → 0.0.4
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/README.md +1 -1
- data/lib/mysql2_query_filter/plugin/casual_log.rb +13 -6
- data/mysql2_query_filter-plugin-casual_log.gemspec +1 -1
- 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: 3cfe55984109099b401f0b3cc98786f4ab6eaaa6
|
4
|
+
data.tar.gz: 9b69c8cf7911fd2897ae53b401f2938456fa5708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e01cd2f06f4821463611675e43af7356950fe9c0c739c853a616f9eb70d40ff3f629da81f1182786154f35127ce30aa2c609b60df680a19348ca83ab68930aa8
|
7
|
+
data.tar.gz: 6b564245e72b78e0c8650ed88d09d9b6aaa0ad654223afb7532a0696c5d373ae3522bd64c225b6f2811381fdc7c443084a7341e4cbb9e38f4c6c2cf6e5410bb8
|
data/README.md
CHANGED
@@ -38,9 +38,16 @@ module Mysql2QueryFilter::Plugin
|
|
38
38
|
|
39
39
|
def filter(sql, query_options)
|
40
40
|
if sql =~ /\A\s*SELECT\b/i and @matcher.call(sql, query_options)
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
explains = []
|
42
|
+
|
43
|
+
@client.query("EXPLAIN #{sql}").each do |result|
|
44
|
+
badquery = colorize_explain(result)
|
45
|
+
explains << format_explain(sql, result) if badquery
|
46
|
+
end
|
47
|
+
|
48
|
+
unless explains.empty?
|
49
|
+
@out << "# #{sql}\n" + explains.join("\n") + "\n"
|
50
|
+
end
|
44
51
|
end
|
45
52
|
end
|
46
53
|
|
@@ -65,15 +72,15 @@ module Mysql2QueryFilter::Plugin
|
|
65
72
|
Term::ANSIColor.red(Term::ANSIColor.bold(str))
|
66
73
|
end
|
67
74
|
|
68
|
-
def
|
69
|
-
message = "
|
75
|
+
def format_explain(sql, explain)
|
76
|
+
message = "---\n"
|
70
77
|
max_key_length = explain.keys.map(&:length).max
|
71
78
|
|
72
79
|
explain.each do |key, value|
|
73
80
|
message << "%*s: %s\n" % [max_key_length, key, value]
|
74
81
|
end
|
75
82
|
|
76
|
-
|
83
|
+
message
|
77
84
|
end
|
78
85
|
end
|
79
86
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = 'mysql2_query_filter-plugin-casual_log'
|
4
|
-
spec.version = '0.0.
|
4
|
+
spec.version = '0.0.4'
|
5
5
|
spec.authors = ['Genki Sugawara']
|
6
6
|
spec.email = ['sgwr_dts@yahoo.co.jp']
|
7
7
|
spec.summary = %q{Plug-in that colorize the bad query for Mysql2QueryFilter.}
|