activerecord-pedantmysql2-adapter 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/README.md +7 -1
- data/Rakefile +6 -1
- data/activerecord-pedantmysql2-adapter.gemspec +2 -0
- data/lib/active_record/connection_adapters/pedant_mysql2_adapter.rb +11 -0
- data/lib/pedant_mysql2/version.rb +1 -1
- data/shipit.rubygems.yml +1 -0
- data/spec/adapter_spec.rb +13 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/database.rb +1 -3
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df26d0bd1e7762f5394a6bbb0268f3c450c3802e
|
4
|
+
data.tar.gz: 0b3b997d9687a4bbad0b0b672e06406a6902c63e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce22c43b5e38358782c96c0ae9989b07e20e395a1d821c7605a374cb9d507c8c136d085b00debb66080e7a18b6697ead0513125b8c16212681ae5b7de434b205
|
7
|
+
data.tar.gz: 90c27520d20f79dc3b1a7ec97fce529fe85915414ebe14c823064edf040140340662e10b8e6507c7bed4780427b52afe11f520c97cd2a3ac14922e49fd4e0be8
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Activerecord::PedantMysql2
|
2
2
|
|
3
|
+
[![Build Status](https://secure.travis-ci.org/Shopify/activerecord-pedantmysql2-adapter.png)](http://travis-ci.org/Shopify/activerecord-pedantmysql2-adapter)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/Shopify/activerecord-pedantmysql2-adapter.png)](https://codeclimate.com/github/Shopify/activerecord-pedantmysql2-adapter)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/Shopify/activerecord-pedantmysql2-adapter/badge.png)](https://coveralls.io/r/Shopify/activerecord-pedantmysql2-adapter)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/activerecord-pedantmysql2-adapter.png)](http://badge.fury.io/rb/activerecord-pedantmysql2-adapter)
|
7
|
+
|
8
|
+
|
3
9
|
ActiveRecord adapter for MySQL that report warnings.
|
4
10
|
|
5
11
|
The main usage is to progressively identify and fix MySQL warnings generated by legacy rails applications, and ultimately enable strict mode.
|
@@ -51,7 +57,7 @@ end
|
|
51
57
|
|
52
58
|
## Contributing
|
53
59
|
|
54
|
-
1. Fork it ( http://github.com
|
60
|
+
1. Fork it ( http://github.com/Shopify/activerecord-pedantmysql2-adapter/fork )
|
55
61
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
62
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
57
63
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -22,4 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'mysql2', '>= 0.3.11'
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
24
24
|
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'coveralls'
|
25
27
|
end
|
@@ -39,12 +39,23 @@ end
|
|
39
39
|
|
40
40
|
class ActiveRecord::ConnectionAdapters::PedantMysql2Adapter < ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
41
41
|
|
42
|
+
alias_method :original_execute, :execute
|
43
|
+
|
42
44
|
def execute(sql, name = nil)
|
43
45
|
value = super
|
44
46
|
log_warnings(sql)
|
45
47
|
value
|
46
48
|
end
|
47
49
|
|
50
|
+
def exec_delete(sql, name, binds)
|
51
|
+
original_execute to_sql(sql, binds), name
|
52
|
+
affected_rows = @connection.affected_rows
|
53
|
+
log_warnings(sql)
|
54
|
+
affected_rows
|
55
|
+
end
|
56
|
+
|
57
|
+
alias :exec_update :exec_delete
|
58
|
+
|
48
59
|
private
|
49
60
|
|
50
61
|
def log_warnings(sql)
|
data/shipit.rubygems.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# using the default shipit config
|
data/spec/adapter_spec.rb
CHANGED
@@ -5,6 +5,9 @@ describe PedantMysql2 do
|
|
5
5
|
let(:connection) { ActiveRecord::Base.connection }
|
6
6
|
|
7
7
|
before :each do
|
8
|
+
connection.execute('SET SESSION binlog_format = "STATEMENT"')
|
9
|
+
connection.execute('CREATE TABLE IF NOT EXISTS comment (id int)')
|
10
|
+
connection.execute('TRUNCATE TABLE comment')
|
8
11
|
@original_callback = PedantMysql2.on_warning
|
9
12
|
end
|
10
13
|
|
@@ -23,6 +26,16 @@ describe PedantMysql2 do
|
|
23
26
|
expect(result.to_a).to be == [[1.0]]
|
24
27
|
end
|
25
28
|
|
29
|
+
it 'do not change the returned value of exec_update' do
|
30
|
+
result = connection.update('UPDATE comment SET id = 1 LIMIT 1')
|
31
|
+
expect(result).to be_zero
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'do not change the returned value of exec_delete' do
|
35
|
+
result = connection.delete('DELETE FROM comment LIMIT 1')
|
36
|
+
expect(result).to be_zero
|
37
|
+
end
|
38
|
+
|
26
39
|
it 'can easily be raised' do
|
27
40
|
PedantMysql2.on_warning = lambda { |warning| raise warning }
|
28
41
|
expect {
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
lib = File.expand_path('../lib', __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
7
|
+
SimpleCov::Formatter::HTMLFormatter,
|
8
|
+
Coveralls::SimpleCov::Formatter
|
9
|
+
]
|
10
|
+
SimpleCov.start
|
11
|
+
|
3
12
|
require 'activerecord-pedantmysql2-adapter'
|
4
13
|
|
5
14
|
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each { |f| require f }
|
data/spec/support/database.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-pedantmysql2-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
description: Gives a hook on MySQL warnings that allow you to either raise or log
|
70
98
|
them.
|
71
99
|
email:
|
@@ -76,6 +104,7 @@ extra_rdoc_files: []
|
|
76
104
|
files:
|
77
105
|
- ".gitignore"
|
78
106
|
- ".rspec"
|
107
|
+
- ".travis.yml"
|
79
108
|
- Gemfile
|
80
109
|
- LICENSE.txt
|
81
110
|
- README.md
|
@@ -85,6 +114,7 @@ files:
|
|
85
114
|
- lib/activerecord-pedantmysql2-adapter.rb
|
86
115
|
- lib/pedant_mysql2.rb
|
87
116
|
- lib/pedant_mysql2/version.rb
|
117
|
+
- shipit.rubygems.yml
|
88
118
|
- spec/adapter_spec.rb
|
89
119
|
- spec/spec_helper.rb
|
90
120
|
- spec/support/database.rb
|