dblint 0.1.0 → 0.1.1
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/.travis.yml +15 -1
- data/CHANGELOG.md +10 -0
- data/README.md +14 -2
- data/dblint.gemspec +1 -1
- data/lib/dblint/checks/base.rb +4 -2
- data/lib/dblint/checks/long_held_lock.rb +1 -1
- data/lib/dblint/checks/missing_index.rb +1 -1
- data/lib/dblint/rails_integration.rb +1 -1
- data/lib/dblint/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5882547f7ba7be4f29dfbd2e4fc685168e656036
|
4
|
+
data.tar.gz: 1171ff0b3c9bdd3f8fb3d94d48fdff3ff041fb35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72f796d6ddf84cf2ccb305e6e182b4172b0ced77455ed1377d563a65fe851ee731b6538386b3ad25b97b4e7467a45e993b321cc7bbf25bb36a31439ecabd8845
|
7
|
+
data.tar.gz: 4734c644bb32a0f13a61cce0e2235351516ab241c3e403f65fe035f2e2f571c80b7da91a676281d317aca882948aa944dfa43a1fca74dbca29fe0c76a413e12b
|
data/.travis.yml
CHANGED
@@ -1,3 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
-
|
3
|
+
- 1.9.3-p551
|
4
|
+
- 2.0.0-p648
|
5
|
+
- 2.1.8
|
6
|
+
- 2.2.4
|
7
|
+
- 2.3.1
|
8
|
+
- rbx-3.20
|
9
|
+
addons:
|
10
|
+
postgresql: 9.4
|
11
|
+
env:
|
12
|
+
- DATABASE_URL=postgresql://postgres@localhost:5432/dblint
|
13
|
+
before_install:
|
14
|
+
- gem install bundler
|
15
|
+
before_script:
|
16
|
+
- createdb dblint
|
17
|
+
script: bundle exec rake
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
# dblint [ ](https://rubygems.org/gems/dblint) [ ](https://rubygems.org/gems/dblint) [ ](https://travis-ci.org/lfittl/dblint)
|
2
2
|
|
3
3
|
Automatically checks all SQL queries that are executed during your tests, to find common mistakes, including missing indices and locking issues due to long transactions.
|
4
4
|
|
5
|
+
|
5
6
|
## Installation
|
6
7
|
|
7
8
|
Add this line to your application's Gemfile:
|
@@ -27,7 +28,7 @@ Note that it will check the callstack for the problematic query, and only count
|
|
27
28
|
```
|
28
29
|
Failures:
|
29
30
|
|
30
|
-
1) FeedsController#show
|
31
|
+
1) FeedsController#show
|
31
32
|
Failure/Error: get :show, format: :atom
|
32
33
|
Dblint::Checks::MissingIndex::Error:
|
33
34
|
Missing index on oauth_applications for '((twitter_app_name)::text = 'My Feed App'::text)' in 'SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."twitter_app_name" = $1 LIMIT 1', called by app/controllers/feeds_controller.rb:6:in `show'
|
@@ -89,3 +90,14 @@ application, also included in the error message for the check.
|
|
89
90
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
90
91
|
4. Push to the branch (`git push origin my-new-feature`)
|
91
92
|
5. Create a new Pull Request
|
93
|
+
|
94
|
+
|
95
|
+
## Authors
|
96
|
+
|
97
|
+
- [Lukas Fittl](mailto:lukas@fittl.com)
|
98
|
+
|
99
|
+
|
100
|
+
## License
|
101
|
+
|
102
|
+
Copyright (c) 2015, Lukas Fittl <lukas@fittl.com><br>
|
103
|
+
dblint is licensed under the MIT license, see LICENSE.txt file for details.
|
data/dblint.gemspec
CHANGED
@@ -26,6 +26,6 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'rspec-rails'
|
27
27
|
spec.add_development_dependency 'sqlite3'
|
28
28
|
spec.add_development_dependency 'dotenv'
|
29
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
29
|
+
spec.add_development_dependency 'rubocop', '~> 0.39'
|
30
30
|
spec.add_development_dependency 'rubocop-rspec'
|
31
31
|
end
|
data/lib/dblint/checks/base.rb
CHANGED
@@ -8,10 +8,12 @@ module Dblint
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def find_main_app_caller(callstack)
|
11
|
-
main_app_caller = callstack.find { |f| f.start_with?(Rails.root.to_s) }
|
11
|
+
main_app_caller = callstack.find { |f| f.start_with?(Rails.root.to_s) && !f.include?('/vendor/bundle') }
|
12
12
|
main_app_caller.slice!(Rails.root.to_s + '/')
|
13
|
-
|
13
|
+
|
14
|
+
main_app_dir = main_app_caller[/^\w+/]
|
14
15
|
return if %w(spec test).include?(main_app_dir)
|
16
|
+
|
15
17
|
main_app_caller
|
16
18
|
end
|
17
19
|
|
@@ -83,7 +83,7 @@ module Dblint
|
|
83
83
|
|
84
84
|
# We need an explicit begin here since we're interrupting the transaction flow
|
85
85
|
ActiveRecord::Base.connection.execute('BEGIN')
|
86
|
-
|
86
|
+
raise Error, error_msg
|
87
87
|
|
88
88
|
# TODO: Add a config setting for enabling this as a warning
|
89
89
|
# puts format('Warning: %s', error_msg)
|
@@ -34,7 +34,7 @@ module Dblint
|
|
34
34
|
|
35
35
|
error_msg = format("Missing index on %s for '%s' in '%s', called by %s",
|
36
36
|
plan['Relation Name'], plan['Filter'], payload[:sql], main_app_caller)
|
37
|
-
|
37
|
+
raise Error, error_msg
|
38
38
|
end
|
39
39
|
|
40
40
|
(plan['Plans'] || []).each do |subplan|
|
data/lib/dblint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dblint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Fittl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0.
|
145
|
+
version: '0.39'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '0.
|
152
|
+
version: '0.39'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rubocop-rspec
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- ".rspec"
|
177
177
|
- ".rubocop.yml"
|
178
178
|
- ".travis.yml"
|
179
|
+
- CHANGELOG.md
|
179
180
|
- CODE_OF_CONDUCT.md
|
180
181
|
- Gemfile
|
181
182
|
- LICENSE.txt
|
@@ -208,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
209
|
version: '0'
|
209
210
|
requirements: []
|
210
211
|
rubyforge_project:
|
211
|
-
rubygems_version: 2.
|
212
|
+
rubygems_version: 2.5.1
|
212
213
|
signing_key:
|
213
214
|
specification_version: 4
|
214
215
|
summary: Automatically tests your Rails app for common database query mistakes
|