query_reviewer 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 374e1e04da1ecd76345bc0d2d5fa27b271353d82
4
+ data.tar.gz: fba57820f216e24ee0e761cbfe7288b3009114c2
5
+ SHA512:
6
+ metadata.gz: 01928b657a61a7d6e01f6a8540299c706d2a3484faff16936b473e0262f8e7d264a70873990d65e0d01faa3be01486268ce9eafc2c2db56aff1209ea262b5a0f
7
+ data.tar.gz: 333bb606fafad2f1bf5db506335e1f364437d426ec64d2f6ee4ac97396eae838b7705ead69be8cbb1caba57468bc00fc5e4208f56f3bf5739d816d690921fb71
data/README.md CHANGED
@@ -11,8 +11,8 @@ QueryReviewer is an advanced SQL query analyzer. It accomplishes the following
11
11
 
12
12
  ## Use This Fork ##
13
13
 
14
- I use this utility for most of my MySQL-backed Rails projects. Still the best out there in my opinion for analyzing and understanding your generated SQL queries.
15
- I forked the original [query_reviewer](https://github.com/dsboulder/query_reviewer) and applied a collection of patches that have been made since the plugin was created.
14
+ I use this utility for most of my MySQL-backed Rails projects. Still the best out there in my opinion for analyzing and understanding your generated SQL queries.
15
+ I forked the original [query_reviewer](https://github.com/dsboulder/query_reviewer) and applied a collection of patches that have been made since the plugin was created.
16
16
  A list of the biggest additions below:
17
17
 
18
18
  * Snazzed up the README into markdown for better readability
@@ -24,8 +24,8 @@ A list of the biggest additions below:
24
24
  * Fixes for deprecation warnings and for 1.9 compatiblity
25
25
  * Converts templates to more modern foo.html.erb naming
26
26
 
27
- As of August 2011, This has become the "official" version to use. David has deprecated the [original repo](https://github.com/dsboulder/query_reviewer) and recommends that people looking for this utility use this fork instead.
28
- This fork compiles a variety of patches that were made since that time along with additional work to support compatibility with 1.9 and Rails 3.
27
+ As of August 2011, This has become the "official" version to use. David has deprecated the [original repo](https://github.com/dsboulder/query_reviewer) and recommends that people looking for this utility use this fork instead.
28
+ This fork compiles a variety of patches that were made since that time along with additional work to support compatibility with 1.9 and Rails 3.
29
29
  **Also:** If anyone else creates generally useful enhancements to this utility please start by forking this and then issue me a pull request.
30
30
 
31
31
  **Note:** This plugin should work for Rails 2.X and Rails 3. If you run into issues, please file a bug report or send a pull request. I consider this new fork to be a group effort
@@ -33,7 +33,7 @@ so if you want to be added as a contributor to help maintain this, please let me
33
33
 
34
34
  ## Database Limitations ##
35
35
 
36
- As of right now, this plugin supports analyzing queries **only for MySQL**. I consider this the primary **limitation** of this gem.
36
+ As of right now, this plugin supports analyzing queries **only for MySQL**. I consider this the primary **limitation** of this gem.
37
37
  I am now using PostgreSQL for a number of my projects and the "EXPLAIN" output is totally different. Several people have started a PostgreSQL adapter for
38
38
  this plugin, but none that are mature enough to include here.
39
39
 
@@ -49,7 +49,12 @@ All you have to do is install it into your Rails 2 or 3 project.
49
49
  Right now if you use bundler, simply add this to your Gemfile:
50
50
 
51
51
  # Gemfile
52
- gem "query_reviewer", :git => "git://github.com/nesquena/query_reviewer.git"
52
+ gem "query_reviewer"
53
+
54
+ or to use the latest from github:
55
+
56
+ # Gemfile
57
+ gem "query_reviewer", :github => "nesquena/query_reviewer"
53
58
 
54
59
  If you are not using bundler, you might want to [start using it](http://gembundler.com/rails23.html). You can also install this as a plugin:
55
60
 
@@ -129,8 +134,7 @@ Know of a better alternative? Let me know!
129
134
 
130
135
  ## Acknowledgements ##
131
136
 
132
- Created by Kongregate & David Stevenson.
133
- Refactorings and compilations of all fixes since was done by Nathan Esquenazi.
134
- Also, ajvargo for helping with some fixes.
137
+ Created by Kongregate & David Stevenson. Refactorings and maintenance done by Nathan Esquenazi.
138
+ Also [@ajvargo](http://github.com/ajvargo) helped with several fixes.
135
139
 
136
140
  Copyright (c) 2007-2008 Kongregate & David Stevenson, released under the MIT license
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
- require 'rake/rdoctask'
3
+ require 'rdoc/task'
4
4
  require 'bundler'
5
5
  Bundler::GemHelper.install_tasks
6
6
 
@@ -17,11 +17,14 @@ module QueryReviewer
17
17
  result
18
18
  end
19
19
 
20
- def insert_with_review(sql, *args)
20
+ def insert_with_review(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
21
+ bind_params = binds.clone
22
+
21
23
  t1 = Time.now
22
- result = insert_without_review(sql, *args)
24
+ result = insert_without_review(arel, name, pk, id_value, sequence_name, binds)
23
25
  t2 = Time.now
24
26
 
27
+ sql = to_sql(arel, bind_params)
25
28
  create_or_add_query_to_query_reviewer!(sql, nil, t2 - t1, nil, "INSERT")
26
29
 
27
30
  result
@@ -34,7 +34,7 @@ module QueryReviewer
34
34
  def analyze_key!
35
35
  if self.key == "const"
36
36
  praise "Way to go!"
37
- elsif self.key.blank? && !self.extra.include?("select tables optimized away")
37
+ elsif self.key.blank? && !self.extra.include?("select tables optimized away") && !self.extra.include?("impossible where noticed after reading const tables")
38
38
  warn :severity => 6, :field => "key", :desc => "No index was used here. In this case, that meant scanning #{self.rows} rows."
39
39
  end
40
40
  end
@@ -23,7 +23,7 @@ module QueryReviewer
23
23
  end
24
24
 
25
25
  def add(sql, duration, profile)
26
- sql << sql
26
+ sqls << sql
27
27
  durations << duration
28
28
  profiles << profile
29
29
  end
@@ -65,7 +65,7 @@ module QueryReviewer
65
65
  end
66
66
 
67
67
  def table
68
- @subqueries.first.table
68
+ @subqueries.first.try(:table)
69
69
  end
70
70
 
71
71
  def analyze!
@@ -12,12 +12,15 @@
12
12
  <%= query_with_warning.count %> identical queries
13
13
  </b>
14
14
  <% end %>
15
- <i>Table <%= (query_with_warning.warnings.detect {|w| !w.table.blank? } || query_with_warning.warnings.last).table %>:</i>
16
- <% query_with_warning.warnings.sort{|a,b| a.severity <=> b.severity}.reverse.each_with_index do |warn, index| %>
17
- <span style="color: <%= severity_color warn.severity%>;" title="<%= warn.desc%>"><%= warn.problem %></span><%= ", " if index < query_with_warning.warnings.length - 1 %>
18
- <% end %>
19
- <a href="#" onclick="query_review_toggle('warning_<%= query_with_warning.id %>_desc')" title="show/hide warning message">MSG</a>
20
- <a href="#" onclick="query_review_toggle('warning_<%= query_with_warning.id %>_sql')" title="show/hide sql">SQL</a>
15
+ <i>Table <%= (query_with_warning.warnings.detect {|w| !w.table.blank? } || query_with_warning.warnings.last).table.presence || 'unknown'%>:</i>
16
+ <% query_with_warning.warnings.sort{|a,b| a.severity <=> b.severity}.reverse.each_with_index do |warn, index| %>
17
+ <span style = "color: <%= severity_color warn.severity%>;" title="<%= warn.desc%>"><%= warn.problem %></span><%= ", " if index < query_with_warning.warnings.length - 1 %>
18
+ <% end %>
19
+ <% if query_with_warning.warnings.any?{|w|w.desc.present?} %>
20
+ <a href = "#" onclick="query_review_toggle('warning_<%= query_with_warning.id %>_desc')" title="show/hide warning message">MSG</a>
21
+ <% end %>
22
+ <a href = "#" onclick="query_review_toggle('warning_<%= query_with_warning.id %>_sql')" title="show/hide sql">SQL</a>
23
+
21
24
  <% if query_with_warning.select? %>
22
25
  <a href="#" onclick="query_review_toggle('warning_<%= query_with_warning.id %>_explain')" title="show/hide explain output">EXPLN</a>
23
26
  <% end %>
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: query_reviewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - dsboulder, nesquena
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-08 00:00:00.000000000 Z
11
+ date: 2013-09-16 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Runs explain before each select query and displays results in an overlayed
15
14
  div
@@ -52,27 +51,27 @@ files:
52
51
  homepage: https://github.com/nesquena/query_reviewer
53
52
  licenses:
54
53
  - MIT
54
+ metadata: {}
55
55
  post_install_message:
56
56
  rdoc_options: []
57
57
  require_paths:
58
58
  - lib
59
59
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
60
  requirements:
62
- - - ! '>='
61
+ - - '>='
63
62
  - !ruby/object:Gem::Version
64
63
  version: '0'
65
64
  required_rubygems_version: !ruby/object:Gem::Requirement
66
- none: false
67
65
  requirements:
68
- - - ! '>='
66
+ - - '>='
69
67
  - !ruby/object:Gem::Version
70
68
  version: '0'
71
69
  requirements: []
72
70
  rubyforge_project:
73
- rubygems_version: 1.8.24
71
+ rubygems_version: 2.0.6
74
72
  signing_key:
75
- specification_version: 3
73
+ specification_version: 4
76
74
  summary: Runs explain before each select query and displays results in an overlayed
77
75
  div
78
76
  test_files: []
77
+ has_rdoc: